Spaces:
Running
Running
test
Browse files- app/main.py +8 -1
app/main.py
CHANGED
@@ -72,6 +72,12 @@ async def websocket_endpoint(websocket: WebSocket, client_id: int):
|
|
72 |
await manager.broadcast(json.dumps(message))
|
73 |
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
async def astreamer(generator):
|
76 |
try:
|
77 |
print("streaming........")
|
@@ -88,7 +94,8 @@ async def process_input(text: str):
|
|
88 |
if text and len(text.strip()) > 0:
|
89 |
text = text.strip()
|
90 |
streaming_response = session_assistant.ask(text)
|
91 |
-
return StreamingResponse(
|
|
|
92 |
|
93 |
|
94 |
@app.post("/upload")
|
|
|
72 |
await manager.broadcast(json.dumps(message))
|
73 |
|
74 |
|
75 |
+
async def fake_data_streamer():
|
76 |
+
for i in range(10):
|
77 |
+
yield b'some fake data\n\n'
|
78 |
+
await asyncio.sleep(0.5)
|
79 |
+
|
80 |
+
|
81 |
async def astreamer(generator):
|
82 |
try:
|
83 |
print("streaming........")
|
|
|
94 |
if text and len(text.strip()) > 0:
|
95 |
text = text.strip()
|
96 |
streaming_response = session_assistant.ask(text)
|
97 |
+
return StreamingResponse(fake_data_streamer(), media_type='text/event-stream')
|
98 |
+
# return StreamingResponse(astreamer(streaming_response.response_gen), media_type='text/event-stream')
|
99 |
|
100 |
|
101 |
@app.post("/upload")
|