themissingCRAM commited on
Commit
104e584
·
1 Parent(s): 086f897

stream_to_gradio

Browse files
Files changed (1) hide show
  1. app.py +13 -16
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
- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx test:", sql_engine_tool("SELECT * FROM receipts")
138
- )
 
 
139
 
140
- def enter_message(message, chat_history):
141
- print()
142
- print("enter_message debug")
143
- print("engine", engine)
144
- print("message:", message)
145
- print("chat_history", chat_history)
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
- input = gr.Textbox()
155
  button = gr.Button("reply")
156
- button.click(enter_message, [input, chatbot], [input, chatbot])
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)