sonald commited on
Commit
905c20f
1 Parent(s): ee0a8b3
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -33,24 +33,25 @@ def demo8():
33
  agent=AgentType.CONVERSATIONAL_REACT_DESCRIPTION,
34
  memory=memory)
35
  # resp = conversation_agent("what is (4.5*2.1)^2.2?")
36
- def answer(question, history=[]):
37
- history.append(question)
38
- resp = conversation_agent(question)
39
- print(f"resp: {resp}")
40
- history.append(resp['output'])
41
- dial = [(u, v) for u, v in zip(history[::2], history[1::2])]
42
- return {
43
- chatbot: dial,
44
- state: history
45
- }
46
-
47
 
48
  with gr.Blocks() as demo:
49
- chatbot = gr.Chatbot(elem_id="chatbot")
50
  state = gr.State([])
51
 
 
52
  with gr.Row():
53
  text = gr.Textbox(show_label=False, placeholder="enter your prompt")
 
 
 
 
 
 
 
 
 
 
 
 
54
  text.submit(answer, inputs=[text, state], outputs=[chatbot, state])
55
 
56
  demo.launch()
 
33
  agent=AgentType.CONVERSATIONAL_REACT_DESCRIPTION,
34
  memory=memory)
35
  # resp = conversation_agent("what is (4.5*2.1)^2.2?")
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  with gr.Blocks() as demo:
 
38
  state = gr.State([])
39
 
40
+ chatbot = gr.Chatbot(elem_id="chatbot")
41
  with gr.Row():
42
  text = gr.Textbox(show_label=False, placeholder="enter your prompt")
43
+
44
+ def answer(question, history=[]):
45
+ history.append(question)
46
+ resp = conversation_agent(question)
47
+ print(f"resp: {resp}")
48
+ history.append(resp['output'])
49
+ dial = [(u, v) for u, v in zip(history[::2], history[1::2])]
50
+ return {
51
+ chatbot: dial,
52
+ state: history
53
+ }
54
+
55
  text.submit(answer, inputs=[text, state], outputs=[chatbot, state])
56
 
57
  demo.launch()