Spaces:
Build error
Build error
Daniel Marques
commited on
Commit
·
866cbc1
1
Parent(s):
ff06cd6
fix: add websocket in handlerToken
Browse files
main.py
CHANGED
|
@@ -259,22 +259,18 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
| 259 |
|
| 260 |
await websocket.accept()
|
| 261 |
|
| 262 |
-
|
| 263 |
|
| 264 |
try:
|
| 265 |
-
prompt = await websocket.receive_text()
|
| 266 |
-
res = QA(prompt)
|
| 267 |
-
|
| 268 |
while True:
|
|
|
|
| 269 |
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
|
|
|
| 273 |
|
| 274 |
-
print(
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
print(res)
|
| 278 |
|
| 279 |
except WebSocketDisconnect:
|
| 280 |
print('disconnect')
|
|
|
|
| 259 |
|
| 260 |
await websocket.accept()
|
| 261 |
|
| 262 |
+
oldReceiveText = ''
|
| 263 |
|
| 264 |
try:
|
|
|
|
|
|
|
|
|
|
| 265 |
while True:
|
| 266 |
+
prompt = await websocket.receive_text()
|
| 267 |
|
| 268 |
+
if(oldReceiveText != prompt):
|
| 269 |
+
tokenMessageLLM.after_update(lambda now, old: websocket.send_text(now))
|
| 270 |
+
oldReceiveText = prompt
|
| 271 |
+
res = QA(prompt)
|
| 272 |
|
| 273 |
+
print(prompt)
|
|
|
|
|
|
|
|
|
|
| 274 |
|
| 275 |
except WebSocketDisconnect:
|
| 276 |
print('disconnect')
|