Ganesh Chintalapati commited on
Commit
e86c932
·
1 Parent(s): a44283e

modular code apsssjjjadfdrfe

Browse files
Files changed (1) hide show
  1. app.py +27 -34
app.py CHANGED
@@ -1,41 +1,34 @@
1
  import gradio as gr
2
- from core import submit_query, clear_history
3
-
4
- with gr.Blocks(theme=gr.themes.Soft(), css=\"\"\"
5
- .full-height { height: 100%; display: flex; align-items: stretch; min-height: 40px; }
6
- .full-height button { height: 100%; padding: 8px 16px; }
7
- .providers-row { height: 100%; display: flex; align-items: stretch; min-height: 40px; }
8
- .providers-row .checkbox-group { height: 100%; display: flex; flex-direction: row; align-items: center; gap: 10px; }
9
- \"\"\") as demo:
10
- gr.Markdown("# Multi-Model Chat")
11
- gr.Markdown("Chat with OpenAI, Anthropic, or Gemini. Select providers and compare responses side by side!")
12
-
13
- with gr.Row(elem_classes="providers-row"):
14
- providers = gr.CheckboxGroup(choices=["OpenAI", "Anthropic", "Gemini"], label="Select Providers", value=["OpenAI"], elem_classes="checkbox-group")
15
-
16
- with gr.Row(elem_classes="full-height"):
17
- query = gr.Textbox(label="Enter your query", placeholder="e.g., What is the capital of the United States?", scale=4)
18
- submit_button = gr.Button("Submit", scale=1)
19
 
 
 
 
 
 
20
  with gr.Row():
21
- clear_button = gr.Button("Clear History")
22
-
23
- with gr.Row():
24
- openai_chatbot = gr.Chatbot(label="OpenAI", type="messages", scale=1)
25
- anthropic_chatbot = gr.Chatbot(label="Anthropic", type="messages", scale=1)
26
- gemini_chatbot = gr.Chatbot(label="Gemini", type="messages", scale=1)
27
-
28
- chat_history = gr.State([]) # 👈 State to maintain history across submissions
29
-
30
- submit_button.click(
 
 
 
31
  fn=submit_query,
32
- inputs=[query, providers, chat_history],
33
- outputs=[query, openai_chatbot, anthropic_chatbot, gemini_chatbot, chat_history]
34
  )
35
- clear_button.click(
36
- fn=clear_history,
37
- inputs=[],
38
- outputs=[openai_chatbot, anthropic_chatbot, gemini_chatbot, chat_history]
 
39
  )
40
 
41
- demo.launch()
 
1
  import gradio as gr
2
+ from core import submit_query
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
+ with gr.Blocks(theme=gr.themes.Soft(), css="""
5
+ .gradio-container {background-color: #f0f4f8;}
6
+ .chatbot {border-radius: 10px;}
7
+ """) as demo:
8
+ gr.Markdown("# Multi-Provider AI Chatbot")
9
  with gr.Row():
10
+ with gr.Column(scale=1):
11
+ provider_select = gr.CheckboxGroup(
12
+ choices=["OpenAI", "Anthropic", "Gemini"],
13
+ value=["OpenAI", "Anthropic", "Gemini"],
14
+ label="Select Providers"
15
+ )
16
+ with gr.Column(scale=3):
17
+ chatbot = gr.Chatbot(label="Chatbot Responses")
18
+ query_input = gr.Textbox(label="Enter your query", placeholder="Type your question here...")
19
+ submit_btn = gr.Button("Submit")
20
+ clear_btn = gr.Button("Clear")
21
+
22
+ submit_btn.click(
23
  fn=submit_query,
24
+ inputs=[query_input, provider_select],
25
+ outputs=chatbot
26
  )
27
+ clear_btn.click(
28
+ fn=lambda: None,
29
+ inputs=None,
30
+ outputs=[chatbot, query_input],
31
+ _js="() => ['', '']"
32
  )
33
 
34
+ demo.launch()