File ~/anaconda3/envs/tedia/lib/python3.11/asyncio/runners.py:186, in run(main, debug)
161 """Execute the coroutine and return the result.
162163 This function runs the passed coroutine, taking care of
(...)
182 asyncio.run(main())
183 """
184 if events._get_running_loop() is not None:
185 # fail fast with short traceback
--> 186 raise RuntimeError(
187 "asyncio.run() cannot be called from a running event loop")
189 with Runner(debug=debug) as runner:
190 return runner.run(main)
RuntimeError: asyncio.run() cannot be called from a running event loop
I am using python 3.11.7 and the latest version of the Ollama pythons SDKs to run the sample code about AsyncClient
I got an error as below.
RuntimeError Traceback (most recent call last) Cell In[7], line 8 5 message ={ "role":"user","content":"why people smile?"} 6 response = await AsyncClient().chat(model="llama2",message=[message]) ----> 8 asyncio.run(chat())
File ~/anaconda3/envs/tedia/lib/python3.11/asyncio/runners.py:186, in run(main, debug) 161 """Execute the coroutine and return the result. 162 163 This function runs the passed coroutine, taking care of (...) 182 asyncio.run(main()) 183 """ 184 if events._get_running_loop() is not None: 185 # fail fast with short traceback --> 186 raise RuntimeError( 187 "asyncio.run() cannot be called from a running event loop") 189 with Runner(debug=debug) as runner: 190 return runner.run(main)
RuntimeError: asyncio.run() cannot be called from a running event loop