Daniel Marques commited on
Commit
6f321e8
1 Parent(s): c287747

fix: add asyncio

Browse files
Files changed (1) hide show
  1. main.py +3 -2
main.py CHANGED
@@ -3,6 +3,7 @@ import glob
3
  import shutil
4
  import subprocess
5
  import contextvars
 
6
 
7
  from typing import Any, Dict, List
8
 
@@ -36,9 +37,9 @@ class Delete(BaseModel):
36
  websocketClient = contextvars.ContextVar("websocketClient")
37
 
38
  class MyCustomHandler(AsyncCallbackHandler):
39
- async def on_llm_new_token(self, token: str, **kwargs) -> None:
40
  ws = websocketClient.get()
41
- await ws.send_text(f"Message text was: {token}")
42
 
43
  print(f" token: {token}")
44
 
 
3
  import shutil
4
  import subprocess
5
  import contextvars
6
+ import asyncio
7
 
8
  from typing import Any, Dict, List
9
 
 
37
  websocketClient = contextvars.ContextVar("websocketClient")
38
 
39
  class MyCustomHandler(AsyncCallbackHandler):
40
+ def on_llm_new_token(self, token: str, **kwargs) -> None:
41
  ws = websocketClient.get()
42
+ asyncio.run(ws.send_text(f"Message text was: {token}"))
43
 
44
  print(f" token: {token}")
45