Vedashiv commited on
Commit
afd55f0
·
verified ·
1 Parent(s): c3eae6e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+
4
+ # Simple AI brain (you can upgrade later)
5
+ def ai_teacher(message, history):
6
+ responses = {
7
+ "physics": "In physics, always understand *why* something happens, not just formulas. What topic should I explain?",
8
+ "coding": "Coding becomes easy when you break big problems into tiny steps. What language do you want to learn?",
9
+ "math": "Math is logical. Show me the problem and I will guide you step-by-step.",
10
+ "hello": "Hello! I am T-Reacher, your AI Teacher. Ask me anything!",
11
+ "default": "Great question! Let me help you understand that clearly."
12
+ }
13
+
14
+ message_low = message.lower()
15
+
16
+ if "physics" in message_low:
17
+ return responses["physics"]
18
+ if "code" in message_low or "python" in message_low or "program" in message_low:
19
+ return responses["coding"]
20
+ if "math" in message_low:
21
+ return responses["math"]
22
+ if "hello" in message_low:
23
+ return responses["hello"]
24
+
25
+ return responses["default"]
26
+
27
+
28
+ css = """
29
+ body {
30
+ background: linear-gradient(135deg, #0e0e10, #1a1a2e);
31
+ }
32
+ #chatbox {
33
+ border-radius: 12px;
34
+ }
35
+ """
36
+
37
+ with gr.Blocks(css=css, theme=gr.themes.Monochrome()) as demo:
38
+
39
+ gr.Markdown("""
40
+ # 🧠 T-Reacher
41
+ ### Your Personal AI Teacher — Physics, Coding, Maths & More
42
+ Ask anything. I will guide you.
43
+ """)
44
+
45
+ chat = gr.ChatInterface(
46
+ fn=ai_teacher,
47
+ chatbot=gr.Chatbot(height=500),
48
+ title="T-Reacher AI Teacher",
49
+ description="Ask me anything from your 10th syllabus, physics, coding, maths, or robotics!",
50
+ retry_btn="↻ Retry",
51
+ undo_btn="⟲ Undo",
52
+ clear_btn="🗑 Clear"
53
+ )
54
+
55
+ demo.launch()