Sazid2 commited on
Commit
dc6d852
·
verified ·
1 Parent(s): ecbdca4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -62
app.py CHANGED
@@ -1,74 +1,39 @@
1
  """
2
- Jajabor Minimal Working Version for Hugging Face Spaces
3
  """
4
 
5
  import gradio as gr
6
- import os
7
 
8
- def simple_chat(message, history):
9
- """Simple echo function for testing"""
10
- if not message.strip():
11
- return history, "অনুগ্ৰহ কৰি প্ৰশ্ন লিখক।"
12
-
13
- responses = [
14
- "আপোনাৰ প্ৰশ্নটো বুজিলোঁ। অধ্যয়নৰ বাবে শুভেচ্ছা!",
15
- "এই বিষয়টো মনোযোগেৰে পঢ়িবলৈ চেষ্টা কৰক।",
16
- "আপোনাৰ পাঠ্যপুথিৰ সংশ্লিষ্ট অধ্যায়টো চাওক।",
17
- "জাজাবৰ আপোনাক সহায় কৰিবলৈ সদায় সাজু আছে!",
18
- "এই প্ৰশ্নটোৰ বাবে আপোনাৰ শিক্ষকৰ সহায় ল'ব পাৰে।"
19
- ]
20
-
21
- import random
22
- response = random.choice(responses)
23
-
24
  if history is None:
25
  history = []
26
 
27
- history.append([message, response])
28
- return history, ""
29
-
30
- # Create minimal interface
31
- with gr.Blocks(title="Jajabor – SEBA Tutor") as demo:
32
- gr.Markdown("# 🧭 জাজাবৰ – SEBA Class 10 Tutor")
33
- gr.Markdown("অসমীয়া মাধ্যমৰ দশম শ্ৰেণীৰ ছাত্ৰ-ছাত্ৰীৰ বাবে AI টিউটাৰ")
34
-
35
- with gr.Row():
36
- with gr.Column(scale=1):
37
- gr.Markdown("### 👤 লগিন")
38
- username = gr.Textbox(label="আপোনাৰ নাম", placeholder="নাম লিখক...")
39
- gr.Markdown("""
40
- ### 💡 টিপছ
41
- - নাম লিখি প্ৰশ্ন সোধক
42
- - পাঠ্যপুথিৰ PDF ফাইলসমূহ `pdfs/class10` ত ৰাখক
43
- - জাজাবৰ আপোনাক সহায় কৰিব!
44
- """)
45
-
46
- with gr.Column(scale=2):
47
- chatbot = gr.Chatbot(label="কথোপকথন", height=400)
48
- message = gr.Textbox(label="প্ৰশ্ন", placeholder="প্ৰশ্ন লিখক...", lines=2)
49
-
50
- with gr.Row():
51
- submit_btn = gr.Button("📤 প্ৰশ্ন পঠিয়াওক", variant="primary")
52
- clear_btn = gr.Button("🧹 পৰিষ্কাৰ কৰক", variant="secondary")
53
-
54
- # Simple event handlers
55
- def process_message(msg, hist, user):
56
- return simple_chat(msg, hist)
57
-
58
- submit_btn.click(
59
- fn=process_message,
60
- inputs=[message, chatbot, username],
61
- outputs=[chatbot, message]
62
- )
63
-
64
- message.submit(
65
- fn=process_message,
66
- inputs=[message, chatbot, username],
67
- outputs=[chatbot, message]
68
- )
69
 
70
- clear_btn.click(lambda: ([], ""), outputs=[chatbot, message])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
- # Launch with minimal settings
73
  if __name__ == "__main__":
74
  demo.launch(share=False)
 
1
  """
2
+ Jajabor - Absolute Minimal Working Version
3
  """
4
 
5
  import gradio as gr
 
6
 
7
+ def chat_fn(message, history):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  if history is None:
9
  history = []
10
 
11
+ if not message.strip():
12
+ history.append(("", "অনুগ্ৰহ কৰি প্ৰশ্ন লিখক।"))
13
+ return history
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ # Simple echo with Assamese response
16
+ response = f"ধন্যবাদ! আপোনাৰ প্ৰশ্ন: '{message}'\n\nমই জাজাবৰ, আপোনাৰ SEBA Class 10 AI টিউটাৰ। PDF আপলোড কৰি RAG চিস্টেম সক্ৰিয় কৰক।"
17
+ history.append((message, response))
18
+ return history
19
+
20
+ # Minimal interface
21
+ with gr.Blocks() as demo:
22
+ gr.Markdown("# 🧭 জাজাবৰ - SEBA Class 10 Tutor")
23
+ chatbot = gr.Chatbot()
24
+ msg = gr.Textbox(label="প্ৰশ্ন লিখক")
25
+ clear = gr.Button("পৰিষ্কাৰ কৰক")
26
+
27
+ def user(user_message, history):
28
+ return "", history + [[user_message, None]]
29
+
30
+ def bot(history):
31
+ response = "জাজাবৰই আপোনাক সহায় কৰিবলৈ সাজু! PDF পাঠ্যপুথি আপলোড কৰি সম্পূৰ্ণ RAG চিস্টেম সক্ৰিয় কৰক।"
32
+ history[-1][1] = response
33
+ return history
34
+
35
+ msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(bot, chatbot, chatbot)
36
+ clear.click(lambda: None, None, chatbot, queue=False)
37
 
 
38
  if __name__ == "__main__":
39
  demo.launch(share=False)