-
After installation, I met this error when using examples (local ollama, api based model both will cause). I am a newer in LLM using, can someone help me solve this ;-; |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @SixJohn, I'm here to assist you with any bugs, questions, or contributions you have. Let's work together to solve this issue! The error "asyncio.run() cannot be called from a running event loop" occurs when you try to use To resolve this, you can use an alternative approach to run your asynchronous functions. Instead of import asyncio
async def main():
# Your asynchronous code here
pass
# If you're in an async function or a running event loop
loop = asyncio.get_event_loop()
loop.run_until_complete(main()) This approach should help you run the examples without encountering the error. If you're using a Jupyter notebook, you can also use the import nest_asyncio
nest_asyncio.apply() Then, you can use To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
Hey @SixJohn, I'm here to assist you with any bugs, questions, or contributions you have. Let's work together to solve this issue!
The error "asyncio.run() cannot be called from a running event loop" occurs when you try to use
asyncio.run()
inside an already running event loop. This is common in environments like Jupyter notebooks or certain web frameworks.To resolve this, you can use an alternative approach to run your asynchronous functions. Instead of
asyncio.run()
, you can useawait
directly if you're in an async function, or useasyncio.create_task()
orasyncio.gather()
to manage your coroutines. Here's a basic example of how you might adjust your code: