Daniel Marques commited on
Commit
880c11d
1 Parent(s): 03ebafe

fix: add callback

Browse files
Files changed (1) hide show
  1. main.py +11 -11
main.py CHANGED
@@ -241,17 +241,17 @@ async def websocket_endpoint(websocket: WebSocket, client_id: int):
241
  pubsub = redisClient.pubsub()
242
  pubsub.subscribe(f'{client_id}')
243
 
244
- with concurrent.futures.ThreadPoolExecutor() as executor:
245
- executor.submit(QA(inputs=prompt, return_only_outputs=True, tags=f'{client_id}', include_run_info=True, callbacks=[handleCallback]))
246
-
247
- i = 0
248
- for item in pubsub.listen():
249
- if item["type"] == "message":
250
- message = item["data"].decode('utf-8')
251
- if message == "end": pubsub.unsubscribe({client_id})
252
- if(i == 10): pubsub.unsubscribe({client_id})
253
- await websocket.send_text(f'{message}')
254
- i+=1
255
 
256
 
257
  except WebSocketDisconnect:
 
241
  pubsub = redisClient.pubsub()
242
  pubsub.subscribe(f'{client_id}')
243
 
244
+ response = QA(inputs=prompt, return_only_outputs=True, tags=f'{client_id}', include_run_info=True, callbacks=[handleCallback])
245
+ await websocket.send_text(f'{response}')
246
+
247
+ # with concurrent.futures.ThreadPoolExecutor() as executor:
248
+ # executor.submit(QA(inputs=prompt, return_only_outputs=True, tags=f'{client_id}', include_run_info=True, callbacks=[handleCallback]))
249
+
250
+ # for item in pubsub.listen():
251
+ # if item["type"] == "message":
252
+ # message = item["data"].decode('utf-8')
253
+ # if message == "end": pubsub.unsubscribe({client_id})
254
+ # await websocket.send_text(f'{message}')
255
 
256
 
257
  except WebSocketDisconnect: