themissingCRAM
commited on
Commit
·
104e584
1
Parent(s):
086f897
stream_to_gradio
Browse files
app.py
CHANGED
@@ -133,25 +133,22 @@ if __name__ == "__main__":
|
|
133 |
)
|
134 |
# agent.run("What is the average each customer paid?")
|
135 |
# GradioUI(agent).launch()
|
136 |
-
print(
|
137 |
-
|
138 |
-
)
|
|
|
|
|
139 |
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
chat_history.append({"role": "user", "content": message})
|
147 |
-
x = stream_to_gradio(agent, message)
|
148 |
-
print(type(x))
|
149 |
-
print("\n\n\n", x, "\n\n\n")
|
150 |
-
return "", x
|
151 |
|
152 |
with gr.Blocks() as b:
|
153 |
chatbot = gr.Chatbot(type="messages")
|
154 |
-
|
155 |
button = gr.Button("reply")
|
156 |
-
button.click(enter_message, [
|
157 |
b.launch(debug=True)
|
|
|
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(message):
|
141 |
|
142 |
+
messages = []
|
143 |
+
messages.append(gr.ChatMessage(role="user", context=message))
|
144 |
+
yield messages
|
145 |
+
for msg in stream_to_gradio(agent, message):
|
146 |
+
messages.append(msg)
|
147 |
+
yield messages
|
|
|
|
|
|
|
|
|
|
|
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)
|