agents
agents copied to clipboard
Running agents in uvicorn
Can you provide an example of how can I run the agents in uvicorn app? I am using fastapi on the backend and when a post request is made, I setup agents and run to the worker but unfortunately, it is not working.
It may due to the event loop used by uvicorn, since by default uvicorn uses uvloop, not asyncio.
You can try to swap uvloop with asyncio as event loop to be used, either from the cli when launching the app
uvicorn main:app --loop asyncio
or in the main function
uvicorn.run("main:app", loop='asyncio')
Another possible solution is to make asyncio use the uvloop event loop by default, as explained here
import asyncio
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())