JDhruv14 commited on
Commit
0d61b36
·
verified ·
1 Parent(s): 81e7721

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -67,7 +67,8 @@ with gr.Blocks() as demo:
67
  "<h1 style='text-align:center'>Gita Assistant (Qwen2.5-3B + LoRA)</h1>"
68
  "<p style='text-align:center'>Ask in English / हिंदी / ગુજરાતી. The assistant cites verses when relevant.</p>"
69
  )
70
- system_box = gr.Textbox(
 
71
  value="Reply in the user’s language with 2–3 concrete points (200–400 words); cite Gita verses when relevant.",
72
  label="System prompt",
73
  )
@@ -76,11 +77,20 @@ with gr.Blocks() as demo:
76
  max_new = gr.Slider(64, 1024, value=512, step=16, label="max_new_tokens")
77
  min_new = gr.Slider(0, 512, value=160, step=8, label="min_new_tokens")
78
 
 
79
  gr.ChatInterface(
80
- fn=lambda m, h: chat_fn(m, h, system_box.value, temperature.value, top_p.value, max_new.value, min_new.value),
81
  additional_inputs=[system_box, temperature, top_p, max_new, min_new],
82
- queue=True
 
 
 
 
 
83
  )
84
 
 
 
85
  if __name__ == "__main__":
86
  demo.launch()
 
 
67
  "<h1 style='text-align:center'>Gita Assistant (Qwen2.5-3B + LoRA)</h1>"
68
  "<p style='text-align:center'>Ask in English / हिंदी / ગુજરાતી. The assistant cites verses when relevant.</p>"
69
  )
70
+
71
+ system_box = gr.Textbox(
72
  value="Reply in the user’s language with 2–3 concrete points (200–400 words); cite Gita verses when relevant.",
73
  label="System prompt",
74
  )
 
77
  max_new = gr.Slider(64, 1024, value=512, step=16, label="max_new_tokens")
78
  min_new = gr.Slider(0, 512, value=160, step=8, label="min_new_tokens")
79
 
80
+ # IMPORTANT: keep fn=chat_fn directly, and pass components via additional_inputs
81
  gr.ChatInterface(
82
+ fn=chat_fn,
83
  additional_inputs=[system_box, temperature, top_p, max_new, min_new],
84
+ chatbot=gr.Chatbot(height=520),
85
+ examples=[
86
+ "How do I practice Nishkama Karma at work?",
87
+ "What does 3.19 teach about duty without attachment?",
88
+ "How to overcome fear of failure according to the Gita?"
89
+ ],
90
  )
91
 
92
+ # For Spaces (and ZeroGPU), queue outside the interface for broad compatibility
93
+ demo.queue(concurrency_count=2) # keep for ZeroGPU; harmless on normal GPU
94
  if __name__ == "__main__":
95
  demo.launch()
96
+