dev2089 commited on
Commit
025edac
·
verified ·
1 Parent(s): e082696

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +79 -78
app.py CHANGED
@@ -1,94 +1,95 @@
1
  """
2
- Devrayog AI - HF Space App v0.3.0
3
- Simple, fast, reliable chat with knowledge base
4
  """
5
 
6
  import gradio as gr
7
 
8
  KB = {
9
- "what is nda": "NDA (National Defence Academy) is India's premier joint services training institution in Khadakwasla, Pune. The exam is conducted by UPSC twice a year. Training: 3 years at NDA + 1 year at service academy.",
10
- "ssb process": "SSB is a 5-day selection process:\nDay 1: Screening (OIR + PPDT)\nDay 2: Psychology (TAT, WAT, SRT, SD)\nDay 3-4: GTO Tasks (GD, GPE, PGT, HGT, Command Task, FGT)\nDay 5: Conference",
11
- "ssb tips": "SSB Prep Tips:\n1. Practice OIR daily\n2. Write 6 TAT stories daily\n3. Practice WAT (60 words, 15s each)\n4. Practice SRT (60 situations, 30s each)\n5. Be yourself - don't fake\n6. Stay updated with current affairs\n7. Maintain physical fitness",
12
- "tat": "TAT: See 12 blurry pictures, write a story in 4 minutes each. Include a hero, problem, and positive resolution.",
13
- "wat": "WAT: 60 words, 15 seconds each. Write the first sentence that comes to mind. Keep it positive.",
14
- "srt": "SRT: 60 situations, 30 seconds each. Write what YOU would do. Be practical and quick.",
15
- "oir": "OIR: Verbal and non-verbal reasoning. Practice analogies, coding, series, patterns daily.",
16
- "ppdt": "PPDT: See blurry picture for 30s, write story in 4min, then group discussion. Day 1 screening.",
17
- "gto": "GTO Tasks: Group Discussion, Group Planning, Progressive Group Task, Half Group Task, Command Task, Final Group Task.",
18
- "15 olqs": "15 Officer-Like Qualities:\n1. Effective Intelligence\n2. Reasoning Ability\n3. Organizing Ability\n4. Power of Expression\n5. Social Adaptability\n6. Cooperation\n7. Sense of Responsibility\n8. Initiative\n9. Self Confidence\n10. Speed of Decision\n11. Ability to Influence\n12. Liveliness\n13. Determination\n14. Courage\n15. Stamina",
19
- "devrayog": "Devrayog AI is India's first solo-built AI, founded by Devanshu Sharma (Hermes), 18, from Neem Ka Thana, Rajasthan. 3 models: Agni (Fast), Vayu (Creative), Akash (Powerful).",
20
- "hello": "Hello! I'm Devrayog AI, India's first solo-built AI. I can help with:\n- SSB Interview Prep\n- NDA Exam Info\n- TAT/WAT/SRT/PPDT Tips\n- Current Affairs\n\nTry: 'What is SSB?', 'SSB tips', '15 OLQs', 'What is NDA?'",
21
  }
22
 
23
- def get_response(msg):
24
- msg = msg.lower().strip()
25
- for key, val in KB.items():
26
- if key in msg:
27
- return val
28
- if any(w in msg for w in ["hi","hello","hey","namaste"]):
29
- return KB["hello"]
30
- if any(w in msg for w in ["nda","national defence"]):
31
- return KB["what is nda"]
32
- if any(w in msg for w in ["ssb","services selection"]):
33
- return KB["ssb process"] + "\n\n" + KB["ssb tips"]
34
- if "tat" in msg:
35
- return KB["tat"]
36
- if "wat" in msg:
37
- return KB["wat"]
38
- if "srt" in msg:
39
- return KB["srt"]
40
- if "oir" in msg:
41
- return KB["oir"]
42
- if "ppdt" in msg:
43
- return KB["ppdt"]
44
- if "gto" in msg:
45
- return KB["gto"]
46
- if any(w in msg for w in ["olq","officer like","qualities"]):
47
- return KB["15 olqs"]
48
- if any(w in msg for w in ["devrayog","hermes","founder","about"]):
49
- return KB["devrayog"]
50
- if any(w in msg for w in ["help","what can","how to use"]):
51
- return "I can help with:\n- SSB Process & Tips\n- NDA Exam Info\n- TAT/WAT/SRT/PPDT\n- 15 OLQs\n- Current Affairs\n\nJust ask!"
52
- return f"Thanks for asking about '{msg}'! Try: SSB, NDA, TAT, WAT, SRT, PPDT, GTO, 15 OLQs"
53
-
54
  def respond(message, model):
55
- """Simple respond function - takes message and model, returns response"""
56
- if not message.strip():
57
- return ""
58
- prefix = {"Agni": "[Agni] ", "Vayu": "[Vayu] ", "Akash": "[Akash] "}.get(model, "[Agni] ")
59
- response = get_response(message)
60
- return prefix + response
61
-
62
- with gr.Blocks(title="Devrayog AI") as demo:
63
- gr.Markdown("# Devrayog AI")
64
- gr.Markdown("*India's First Solo-Built AI | Hermes, 18, Rajasthan*")
65
 
66
- model = gr.Radio(["Agni", "Vayu", "Akash"], value="Agni", label="Model")
 
67
 
68
- with gr.Row():
69
- with gr.Column(scale=3):
70
- msg = gr.Textbox(placeholder="Ask about SSB, NDA, TAT...", container=False, autofocus=True, label="Your Question")
71
- output = gr.Textbox(lines=10, label="Devrayog AI Response", interactive=True)
72
- send = gr.Button("Send", variant="primary")
73
- with gr.Column(scale=1):
74
- gr.Markdown("### Quick Topics")
75
- b1 = gr.Button("SSB Process")
76
- b2 = gr.Button("NDA Info")
77
- b3 = gr.Button("SSB Tips")
78
- b4 = gr.Button("15 OLQs")
79
- b5 = gr.Button("TAT Tips")
80
- b6 = gr.Button("WAT Tips")
81
 
82
- gr.Markdown("### Models: Agni (Fast) | Vayu (Creative) | Akash (Powerful)")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
- send.click(fn=respond, inputs=[msg, model], outputs=[output])
85
- msg.submit(fn=respond, inputs=[msg, model], outputs=[output])
86
 
87
- b1.click(fn=lambda m: respond("What is SSB process?", m), inputs=[model], outputs=[output])
88
- b2.click(fn=lambda m: respond("What is NDA?", m), inputs=[model], outputs=[output])
89
- b3.click(fn=lambda m: respond("SSB tips", m), inputs=[model], outputs=[output])
90
- b4.click(fn=lambda m: respond("15 OLQs", m), inputs=[model], outputs=[output])
91
- b5.click(fn=lambda m: respond("TAT tips", m), inputs=[model], outputs=[output])
92
- b6.click(fn=lambda m: respond("WAT tips", m), inputs=[model], outputs=[output])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
  demo.launch(server_name="0.0.0.0", server_port=7860)
 
1
  """
2
+ Devrayog AI - HF Space App v0.3.1
3
+ Ultra-simple - no Chatbot component issues
4
  """
5
 
6
  import gradio as gr
7
 
8
  KB = {
9
+ "nda": "NDA (National Defence Academy) is India's premier joint services training institution in Khadakwasla, Pune. The exam is conducted by UPSC twice a year (April & September). Training: 3 years at NDA + 1 year at service academy. Age: 16.5-19.5 years. 12th pass/appearing.",
10
+ "ssb": "SSB is a 5-day selection process:\nDay 1: Screening (OIR + PPDT)\nDay 2: Psychology (TAT, WAT, SRT, SD)\nDay 3-4: GTO Tasks (GD, GPE, PGT, HGT, Command Task, FGT)\nDay 5: Conference + Results",
11
+ "ssb tips": "SSB Prep Tips:\n1. Practice OIR daily - analogies, coding, series\n2. Write 6 TAT stories daily - hero, problem, resolution\n3. Practice WAT - 60 words, 15s each, stay positive\n4. Practice SRT - 60 situations, 30s each, be practical\n5. Be yourself - assessors spot faking\n6. Stay updated with current affairs\n7. Maintain physical fitness - running, pushups",
12
+ "tat": "TAT (Thematic Apperception Test): See 12 blurry pictures + 1 blank. Write a story in 4 minutes each. Structure: What led up, what's happening, outcome. Include a hero, problem, and positive resolution.",
13
+ "wat": "WAT (Word Association Test): 60 words shown, 15 seconds each. Write the FIRST sentence that comes to your mind. Keep it positive, clear, and original.",
14
+ "srt": "SRT (Situation Reaction Test): 60 situations, 30 seconds each. Write what YOU would actually do. Be practical, quick, and show leadership.",
15
+ "oir": "OIR (Officer Intelligence Rating): Verbal and non-verbal reasoning. Topics: analogies, coding-decoding, series completion, blood relations, directions, patterns. Practice daily from RS Aggarwal.",
16
+ "ppdt": "PPDT (Picture Perception & Discussion Test): Day 1 screening. See a blurry picture for 30 seconds, write a story in 4 minutes, then group discussion in groups of 15.",
17
+ "gto": "GTO (Group Testing Officer) Tasks:\n- Group Discussion (GD)\n- Group Planning Exercise (GPE)\n- Progressive Group Task (PGT)\n- Half Group Task (HGT)\n- Command Task\n- Final Group Task (FGT)\n- Individual Obstacles",
18
+ "olqs": "15 Officer-Like Qualities (OLQs):\n1. Effective Intelligence\n2. Reasoning Ability\n3. Organizing Ability\n4. Power of Expression\n5. Social Adaptability\n6. Cooperation\n7. Sense of Responsibility\n8. Initiative\n9. Self Confidence\n10. Speed of Decision\n11. Ability to Influence\n12. Liveliness\n13. Determination\n14. Courage\n15. Stamina",
19
+ "devrayog": "Devrayog AI is India's first solo-built AI platform, founded by Devanshu Sharma (Hermes), 18, from Neem Ka Thana, Rajasthan. Models: Agni (Fast/3.8B), Vayu (Creative/9B), Akash (Powerful/8B). Website: huggingface.co/spaces/dev2089/devrayog-api",
20
+ "hello": "Namaste! I'm Devrayog AI, India's first solo-built AI. I can help with:\n- SSB Interview Prep\n- NDA Exam Info\n- TAT/WAT/SRT/PPDT Tips\n- 15 Officer-Like Qualities\n- Current Affairs & Defence\n\nJust type your question!",
21
  }
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  def respond(message, model):
24
+ """Simple keyword-based response"""
25
+ if not message or not message.strip():
26
+ return "", "Please type a question!"
 
 
 
 
 
 
 
27
 
28
+ msg = message.lower().strip()
29
+ result = None
30
 
31
+ # Direct keyword matching
32
+ for key in KB:
33
+ if key in msg:
34
+ result = KB[key]
35
+ break
 
 
 
 
 
 
 
 
36
 
37
+ # Fallback keyword matching
38
+ if not result:
39
+ if any(w in msg for w in ["hi", "hello", "hey", "namaste", "hola"]):
40
+ result = KB["hello"]
41
+ elif any(w in msg for w in ["nda", "national defence", "defense academy"]):
42
+ result = KB["nda"]
43
+ elif any(w in msg for w in ["ssb", "services selection board"]):
44
+ result = KB["ssb"] + "\n\n" + KB["ssb tips"]
45
+ elif "tat" in msg:
46
+ result = KB["tat"]
47
+ elif "wat" in msg or "word association" in msg:
48
+ result = KB["wat"]
49
+ elif "srt" in msg or "situation reaction" in msg:
50
+ result = KB["srt"]
51
+ elif "oir" in msg:
52
+ result = KB["oir"]
53
+ elif "ppdt" in msg:
54
+ result = KB["ppdt"]
55
+ elif "gto" in msg:
56
+ result = KB["gto"]
57
+ elif any(w in msg for w in ["olq", "officer like", "qualities", "officer-like"]):
58
+ result = KB["olqs"]
59
+ elif any(w in msg for w in ["devrayog", "hermes", "founder", "about you", "who are you"]):
60
+ result = KB["devrayog"]
61
+ elif any(w in msg for w in ["help", "what can you"]):
62
+ result = "I can help with:\n- SSB Process & Tips\n- NDA Exam Info\n- TAT/WAT/SRT/PPDT\n- 15 OLQs\n- GTO Tasks\n\nJust type your question!"
63
+ else:
64
+ result = f"I don't have specific info on '{message}' yet. Try asking about:\n- SSB Process\n- NDA Exam\n- TAT/WAT/SRT/PPDT\n- 15 OLQs\n- GTO Tasks"
65
 
66
+ # Add model prefix
67
+ prefix = {"Agni": "[Agni - Fast] ", "Vayu": "[Vayu - Creative] ", "Akash": "[Akash - Deep] "}.get(model, "[Agni] ")
68
 
69
+ return message, prefix + result
70
+
71
+ # Create simple Interface
72
+ demo = gr.Interface(
73
+ fn=respond,
74
+ inputs=[
75
+ gr.Textbox(label="✏️ Your Question", placeholder="Ask about SSB, NDA, TAT, WAT...", lines=2),
76
+ gr.Radio(["Agni", "Vayu", "Akash"], value="Agni", label="🤖 Model")
77
+ ],
78
+ outputs=[
79
+ gr.Textbox(label="📝 Your Question", lines=2),
80
+ gr.Textbox(label="🤖 Devrayog AI Response", lines=10)
81
+ ],
82
+ title="🇮🇳 Devrayog AI",
83
+ description="India's First Solo-Built AI | Hermes, 18, Rajasthan",
84
+ examples=[
85
+ ["What is the SSB interview process?", "Agni"],
86
+ ["How to prepare for TAT?", "Vayu"],
87
+ ["What is NDA exam?", "Akash"],
88
+ ["15 Officer-Like Qualities", "Akash"],
89
+ ["SSB preparation tips", "Agni"],
90
+ ["Tips for WAT test", "Vayu"],
91
+ ],
92
+ allow_flagging="never"
93
+ )
94
 
95
  demo.launch(server_name="0.0.0.0", server_port=7860)