""" Devrayog AI - HF Space App v0.3.1 Ultra-simple - no Chatbot component issues """ import gradio as gr KB = { "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 matching for key in KB: if key in msg: result = KB[key] break # Fallback keyword matching if 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 prefix prefix = {"Agni": "[Agni - Fast] ", "Vayu": "[Vayu - Creative] ", "Akash": "[Akash - Deep] "}.get(model, "[Agni] ") return message, prefix + result # Create simple Interface demo = 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"], ], ) demo.launch(server_name="0.0.0.0", server_port=7860)