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

modular code apsssjjjadfdrfes

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -14,21 +14,30 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
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()
 
14
  label="Select Providers"
15
  )
16
  with gr.Column(scale=3):
17
+ chatbot = gr.Chatbot(label="Chatbot Responses", type="messages")
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
+ # State to maintain chat history
23
+ history = gr.State([])
24
+
25
  submit_btn.click(
26
  fn=submit_query,
27
+ inputs=[query_input, provider_select, history],
28
+ outputs=[chatbot, history],
29
+ _js=None # Remove unsupported _js
30
+ ).then(
31
+ fn=lambda x: x, # Return history unchanged
32
+ inputs=history,
33
+ outputs=history
34
  )
35
+
36
  clear_btn.click(
37
+ fn=lambda: ([], ""),
38
  inputs=None,
39
  outputs=[chatbot, query_input],
40
+ js="() => [null, '']" # Use js instead of _js
41
  )
42
 
43
  demo.launch()