themissingCRAM
commited on
Commit
·
9d155c8
1
Parent(s):
fd9420f
stream_to_gradio
Browse files
app.py
CHANGED
@@ -131,24 +131,20 @@ if __name__ == "__main__":
|
|
131 |
max_steps=1,
|
132 |
verbosity_level=1,
|
133 |
)
|
134 |
-
# agent.run("What is the average each customer paid?")
|
135 |
# GradioUI(agent).launch()
|
136 |
-
# print(
|
137 |
-
# "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx test:", sql_engine_tool("SELECT * FROM receipts")
|
138 |
-
# )
|
139 |
|
140 |
-
def enter_message(
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
yield
|
145 |
-
for msg in stream_to_gradio(agent,
|
146 |
-
|
147 |
-
yield
|
148 |
|
149 |
with gr.Blocks() as b:
|
150 |
-
chatbot = gr.Chatbot(type="messages")
|
151 |
textbox = gr.Textbox()
|
152 |
button = gr.Button("reply")
|
153 |
-
button.click(enter_message, [textbox], [chatbot])
|
154 |
b.launch(debug=True)
|
|
|
131 |
max_steps=1,
|
132 |
verbosity_level=1,
|
133 |
)
|
|
|
134 |
# GradioUI(agent).launch()
|
|
|
|
|
|
|
135 |
|
136 |
+
def enter_message(new_message, conversation_history):
|
137 |
|
138 |
+
conversation_history = []
|
139 |
+
conversation_history.append(gr.ChatMessage(role="user", content=new_message))
|
140 |
+
yield "", conversation_history
|
141 |
+
for msg in stream_to_gradio(agent, new_message):
|
142 |
+
conversation_history.append(msg)
|
143 |
+
yield "", conversation_history
|
144 |
|
145 |
with gr.Blocks() as b:
|
146 |
+
chatbot = gr.Chatbot(type="messages", height=1000)
|
147 |
textbox = gr.Textbox()
|
148 |
button = gr.Button("reply")
|
149 |
+
button.click(enter_message, [textbox, chatbot], [textbox, chatbot])
|
150 |
b.launch(debug=True)
|