Closed MA3CIN closed 1 month ago
If i try to call the await cl.Message function directly from the FastAPI file, i get "chainlit.context.ChainlitContextException: Chainlit context not found" And if i call it via a function imported from the ChainLit file, i get the "coroutine 'send_message' was never awaited" error
Take a look at this documentation pointer on how to integrate HTTP and websocket context into FastAPI. Without appropriate websocket context, emitter won't know what to do.
https://docs.chainlit.io/deploy/api#use-chainlit-apis-in-your-endpoint
Closing this for now as I consider the question answered. @MA3CIN If you have more trouble with this, feel free to open again (providing additional clarification for reproduction).
I'm running FastAPI with Chainlit, and running into issues when trying to enable UI updates (sending messages) via a FastAPI Endpoint. The examples in documentation are non-existent, and a cookbook example with fastAPI also doesn't exist. I'm trying to serve endpoints via FastAPI (for example, display message) that would update the UI, but whenever i try to call a function (wrapped in run_sync) that would update the ui (await cl.Message(...).send()), either the routine is not awaited 'coroutine 'send_message' was never awaited', or i get a LookupError:
To Reproduce chain.py:
main.py:
Expected behavior More documentation on updating the UI via FastAPI endpoints (or on run_sync) is needed