FastChat
FastChat copied to clipboard
asyncio.run() error with cilent.Completion in jupyter
it appears that the api can't be used in a jupyther notebook:
RuntimeError Traceback (most recent call last) Cell In[5], line 6 2 from fastchat import client 4 client.set_baseurl('http://127.0.0.1:8000/') When attempting to run in a jupyter notebook the python code from the Client SDK section i'm getting this error: ----> 6 completion = client.ChatCompletion.create( 7 model="vicuna-7b-v1.1", 8 messages=[ 9 {"role": "user", "content": "Hello!"} 10 ] 11 ) 13 print(completion.choices[0].message)
File /usr/local/lib/python3.8/dist-packages/fastchat/client/api.py:48, in ChatCompletion.create(cls, *args, **kwargs)
42 @classmethod
43 def create(cls, *args, **kwargs) -> ChatCompletionResponse:
44 """Creates a new chat completion for the provided messages and parameters.
45
46 See acreate
for more details.
47 """
---> 48 return asyncio.run(cls.acreate(*args, **kwargs))
File /usr/lib/python3.8/asyncio/runners.py:33, in run(main, debug) 9 """Execute the coroutine and return the result. 10 ... 34 "asyncio.run() cannot be called from a running event loop") 36 if not coroutines.iscoroutine(main): 37 raise ValueError("a coroutine was expected, got {!r}".format(main))
RuntimeError: asyncio.run() cannot be called from a running event loop
Are there any plans to release a client api which will work in jupyter? thanks.