dev2089 commited on
Commit
50353bd
Β·
verified Β·
1 Parent(s): 5d6399b

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -57,7 +57,8 @@ def chat(message, history, model):
57
  history = history or []
58
  prefix = {"Agni": "πŸ”₯ ", "Vayu": "🌊 ", "Akash": "🌌 "}.get(model, "πŸ”₯ ")
59
  response = get_response(message)
60
- history.append((message, prefix + response))
 
61
  return history, ""
62
 
63
  with gr.Blocks(title="Devrayog AI") as demo:
@@ -67,19 +68,24 @@ with gr.Blocks(title="Devrayog AI") as demo:
67
  with gr.Row():
68
  with gr.Column(scale=3):
69
  model = gr.Radio(["Agni", "Vayu", "Akash"], value="Agni", label="Model")
70
- chatbot = gr.Chatbot(height=350, show_label=False)
71
  with gr.Row():
72
  msg = gr.Textbox(placeholder="Ask about SSB, NDA, TAT...", scale=4, container=False, autofocus=True)
73
  send = gr.Button("Send", scale=1, variant="primary")
74
  with gr.Row():
75
- gr.Button("🎯 SSB", size="sm").click(lambda h: chat("What is SSB process?", h, "Agni"), inputs=[chatbot], outputs=[chatbot, msg])
76
- gr.Button("πŸ“š NDA", size="sm").click(lambda h: chat("What is NDA?", h, "Agni"), inputs=[chatbot], outputs=[chatbot, msg])
77
- gr.Button("πŸ’‘ Tips", size="sm").click(lambda h: chat("SSB tips", h, "Agni"), inputs=[chatbot], outputs=[chatbot, msg])
78
- gr.Button("⭐ OLQs", size="sm").click(lambda h: chat("15 OLQs", h, "Agni"), inputs=[chatbot], outputs=[chatbot, msg])
79
  with gr.Column(scale=1):
80
- gr.Markdown("### Models\nπŸ”₯ **Agni** - Fast\n🌊 **Vayu** - Creative\n🌌 **Agni** - Powerful\n\n### Topics\nβ€’ SSB Process\nβ€’ TAT/WAT/SRT\nβ€’ NDA Exam\nβ€’ 15 OLQs\nβ€’ GTO Tasks")
81
 
82
  send.click(fn=chat, inputs=[msg, chatbot, model], outputs=[chatbot, msg])
83
  msg.submit(fn=chat, inputs=[msg, chatbot, model], outputs=[chatbot, msg])
 
 
 
 
 
84
 
85
  demo.launch(server_name="0.0.0.0", server_port=7860)
 
57
  history = history or []
58
  prefix = {"Agni": "πŸ”₯ ", "Vayu": "🌊 ", "Akash": "🌌 "}.get(model, "πŸ”₯ ")
59
  response = get_response(message)
60
+ history.append({"role": "user", "content": message})
61
+ history.append({"role": "assistant", "content": prefix + response})
62
  return history, ""
63
 
64
  with gr.Blocks(title="Devrayog AI") as demo:
 
68
  with gr.Row():
69
  with gr.Column(scale=3):
70
  model = gr.Radio(["Agni", "Vayu", "Akash"], value="Agni", label="Model")
71
+ chatbot = gr.Chatbot(height=350, show_label=False, type="messages")
72
  with gr.Row():
73
  msg = gr.Textbox(placeholder="Ask about SSB, NDA, TAT...", scale=4, container=False, autofocus=True)
74
  send = gr.Button("Send", scale=1, variant="primary")
75
  with gr.Row():
76
+ b1 = gr.Button("🎯 SSB", size="sm")
77
+ b2 = gr.Button("πŸ“š NDA", size="sm")
78
+ b3 = gr.Button("πŸ’‘ Tips", size="sm")
79
+ b4 = gr.Button("⭐ OLQs", size="sm")
80
  with gr.Column(scale=1):
81
+ gr.Markdown("### Models\nπŸ”₯ **Agni** - Fast\n🌊 **Vayu** - Creative\n🌌 **Akash** - Powerful\n\n### Topics\nβ€’ SSB Process\nβ€’ TAT/WAT/SRT\nβ€’ NDA Exam\nβ€’ 15 OLQs\nβ€’ GTO Tasks")
82
 
83
  send.click(fn=chat, inputs=[msg, chatbot, model], outputs=[chatbot, msg])
84
  msg.submit(fn=chat, inputs=[msg, chatbot, model], outputs=[chatbot, msg])
85
+
86
+ b1.click(fn=lambda h, m: chat("What is SSB process?", h, m), inputs=[chatbot, model], outputs=[chatbot, msg])
87
+ b2.click(fn=lambda h, m: chat("What is NDA?", h, m), inputs=[chatbot, model], outputs=[chatbot, msg])
88
+ b3.click(fn=lambda h, m: chat("SSB tips", h, m), inputs=[chatbot, model], outputs=[chatbot, msg])
89
+ b4.click(fn=lambda h, m: chat("15 OLQs", h, m), inputs=[chatbot, model], outputs=[chatbot, msg])
90
 
91
  demo.launch(server_name="0.0.0.0", server_port=7860)