Spaces:
Sleeping
Sleeping
thoristhor
commited on
Commit
•
0235a56
1
Parent(s):
e26b4b7
Update app.py
Browse files
app.py
CHANGED
@@ -28,21 +28,22 @@ memory = ConversationBufferMemory(memory_key="chat_history")
|
|
28 |
llm=OpenAI(temperature=0)
|
29 |
agent_chain = initialize_agent(tools, llm, agent="conversational-react-description", memory=memory)
|
30 |
|
31 |
-
def
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
with gr.Blocks() as demo:
|
35 |
chatbot = gr.Chatbot()
|
|
|
36 |
|
37 |
with gr.Row():
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
state = gr.State()
|
45 |
-
submit.click(run_something, inputs=[message], outputs=[chatbot, state])
|
46 |
-
message.submit(run_something, inputs=[message], outputs=[chatbot, state])
|
47 |
-
|
48 |
-
demo.launch(debug=True)
|
|
|
28 |
llm=OpenAI(temperature=0)
|
29 |
agent_chain = initialize_agent(tools, llm, agent="conversational-react-description", memory=memory)
|
30 |
|
31 |
+
def predict(input, history=[]):
|
32 |
+
response = agent_chain.run(input)
|
33 |
+
history = history + [(input, response)]
|
34 |
+
response = history
|
35 |
+
# response = [response]
|
36 |
+
# return response, response
|
37 |
+
return response, response
|
38 |
|
39 |
with gr.Blocks() as demo:
|
40 |
chatbot = gr.Chatbot()
|
41 |
+
state = gr.State([])
|
42 |
|
43 |
with gr.Row():
|
44 |
+
txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter").style(container=False)
|
45 |
+
|
46 |
+
txt.submit(predict, [txt, state], [chatbot, state])
|
47 |
+
# txt.submit(agent_executor.run, [txt, state], [chatbot, state])
|
48 |
+
|
49 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|