wlchee commited on
Commit
9bc79ad
·
verified ·
1 Parent(s): f1431ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -3,8 +3,6 @@ import requests
3
  import sseclient
4
  import json
5
 
6
- # Corrected streaming function for Tiny Agent
7
-
8
  def chat(message, history):
9
  url = "https://wlchee-mcp-sentiment.hf.space/gradio_api/mcp/sse"
10
  headers = {
@@ -22,9 +20,11 @@ def chat(message, history):
22
  if event.data == "[DONE]":
23
  break
24
  output += event.data
25
- yield output
 
26
  except Exception as e:
27
- yield f"Error: {e}"
 
 
 
28
 
29
- # Launch Tiny Agent UI
30
- gr.ChatInterface(fn=chat, title="Sentiment Tiny Agent").launch()
 
3
  import sseclient
4
  import json
5
 
 
 
6
  def chat(message, history):
7
  url = "https://wlchee-mcp-sentiment.hf.space/gradio_api/mcp/sse"
8
  headers = {
 
20
  if event.data == "[DONE]":
21
  break
22
  output += event.data
23
+ # Yield as a list of message dicts in the new format
24
+ yield [{"role": "assistant", "content": output}]
25
  except Exception as e:
26
+ yield [{"role": "assistant", "content": f"Error: {e}"}]
27
+
28
+ # Launch with type="messages" to use the new message format
29
+ gr.ChatInterface(fn=chat, title="Sentiment Tiny Agent", type="messages").launch(share=True)
30