Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394"""Devrayog AI - HF Space App v0.3.0Simple, fast, reliable chat with knowledge base"""import gradio as grKB = {"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.","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","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","tat": "TAT: See 12 blurry pictures, write a story in 4 minutes each. Include a hero, problem, and positive resolution.","wat": "WAT: 60 words, 15 seconds each. Write the first sentence that comes to mind. Keep it positive.","srt": "SRT: 60 situations, 30 seconds each. Write what YOU would do. Be practical and quick.","oir": "OIR: Verbal and non-verbal reasoning. Practice analogies, coding, series, patterns daily.","ppdt": "PPDT: See blurry picture for 30s, write story in 4min, then group discussion. Day 1 screening.","gto": "GTO Tasks: Group Discussion, Group Planning, Progressive Group Task, Half Group Task, Command Task, Final Group Task.","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","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).","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?'",}def get_response(msg):msg = msg.lower().strip()for key, val in KB.items():if key in msg:return valif any(w in msg for w in ["hi","hello","hey","namaste"]):return KB["hello"]if any(w in msg for w in ["nda","national defence"]):return KB["what is nda"]if any(w in msg for w in ["ssb","services selection"]):return KB["ssb process"] + "\n\n" + KB["ssb tips"]if "tat" in msg:return KB["tat"]if "wat" in msg:return KB["wat"]if "srt" in msg:return KB["srt"]if "oir" in msg:return KB["oir"]if "ppdt" in msg:return KB["ppdt"]if "gto" in msg:return KB["gto"]if any(w in msg for w in ["olq","officer like","qualities"]):return KB["15 olqs"]if any(w in msg for w in ["devrayog","hermes","founder","about"]):return KB["devrayog"]if any(w in msg for w in ["help","what can","how to use"]):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!"return f"Thanks for asking about '{msg}'! Try: SSB, NDA, TAT, WAT, SRT, PPDT, GTO, 15 OLQs"def respond(message, model):"""Simple respond function - takes message and model, returns response"""if not message.strip():return ""prefix = {"Agni": "[Agni] ", "Vayu": "[Vayu] ", "Akash": "[Akash] "}.get(model, "[Agni] ")response = get_response(message)return prefix + responsewith gr.Blocks(title="Devrayog AI") as demo:gr.Markdown("# Devrayog AI")gr.Markdown("*India's First Solo-Built AI | Hermes, 18, Rajasthan*")model = gr.Radio(["Agni", "Vayu", "Akash"], value="Agni", label="Model")with gr.Row():with gr.Column(scale=3):msg = gr.Textbox(placeholder="Ask about SSB, NDA, TAT...", container=False, autofocus=True, label="Your Question")output = gr.Textbox(lines=10, label="Devrayog AI Response", interactive=True)send = gr.Button("Send", variant="primary")with gr.Column(scale=1):gr.Markdown("### Quick Topics")b1 = gr.Button("SSB Process")b2 = gr.Button("NDA Info")b3 = gr.Button("SSB Tips")b4 = gr.Button("15 OLQs")b5 = gr.Button("TAT Tips")b6 = gr.Button("WAT Tips")gr.Markdown("### Models: Agni (Fast) | Vayu (Creative) | Akash (Powerful)")send.click(fn=respond, inputs=[msg, model], outputs=[output])msg.submit(fn=respond, inputs=[msg, model], outputs=[output])b1.click(fn=lambda m: respond("What is SSB process?", m), inputs=[model], outputs=[output])b2.click(fn=lambda m: respond("What is NDA?", m), inputs=[model], outputs=[output])b3.click(fn=lambda m: respond("SSB tips", m), inputs=[model], outputs=[output])b4.click(fn=lambda m: respond("15 OLQs", m), inputs=[model], outputs=[output])b5.click(fn=lambda m: respond("TAT tips", m), inputs=[model], outputs=[output])b6.click(fn=lambda m: respond("WAT tips", m), inputs=[model], outputs=[output])demo.launch(server_name="0.0.0.0", server_port=7860)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495"""Devrayog AI - HF Space App v0.3.1Ultra-simple - no Chatbot component issues"""import gradio as grKB = {"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.","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","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","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.","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.","srt": "SRT (Situation Reaction Test): 60 situations, 30 seconds each. Write what YOU would actually do. Be practical, quick, and show leadership.","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.","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.","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","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","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","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!",}def respond(message, model):"""Simple keyword-based response"""if not message or not message.strip():return "", "Please type a question!"msg = message.lower().strip()result = None# Direct keyword matchingfor key in KB:if key in msg:result = KB[key]break# Fallback keyword matchingif not result:if any(w in msg for w in ["hi", "hello", "hey", "namaste", "hola"]):result = KB["hello"]elif any(w in msg for w in ["nda", "national defence", "defense academy"]):result = KB["nda"]elif any(w in msg for w in ["ssb", "services selection board"]):result = KB["ssb"] + "\n\n" + KB["ssb tips"]elif "tat" in msg:result = KB["tat"]elif "wat" in msg or "word association" in msg:result = KB["wat"]elif "srt" in msg or "situation reaction" in msg:result = KB["srt"]elif "oir" in msg:result = KB["oir"]elif "ppdt" in msg:result = KB["ppdt"]elif "gto" in msg:result = KB["gto"]elif any(w in msg for w in ["olq", "officer like", "qualities", "officer-like"]):result = KB["olqs"]elif any(w in msg for w in ["devrayog", "hermes", "founder", "about you", "who are you"]):result = KB["devrayog"]elif any(w in msg for w in ["help", "what can you"]):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!"else: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"# Add model prefixprefix = {"Agni": "[Agni - Fast] ", "Vayu": "[Vayu - Creative] ", "Akash": "[Akash - Deep] "}.get(model, "[Agni] ")return message, prefix + result# Create simple Interfacedemo = gr.Interface(fn=respond,inputs=[gr.Textbox(label="✏️ Your Question", placeholder="Ask about SSB, NDA, TAT, WAT...", lines=2),gr.Radio(["Agni", "Vayu", "Akash"], value="Agni", label="🤖 Model")],outputs=[gr.Textbox(label="📝 Your Question", lines=2),gr.Textbox(label="🤖 Devrayog AI Response", lines=10)],title="🇮🇳 Devrayog AI",description="India's First Solo-Built AI | Hermes, 18, Rajasthan",examples=[["What is the SSB interview process?", "Agni"],["How to prepare for TAT?", "Vayu"],["What is NDA exam?", "Akash"],["15 Officer-Like Qualities", "Akash"],["SSB preparation tips", "Agni"],["Tips for WAT test", "Vayu"],],allow_flagging="never")demo.launch(server_name="0.0.0.0", server_port=7860)
app.py+79-78