Open Sara2823 opened 4 days ago
How to add a FastAPI BackgroundTask to a LangServe endpoint?
We need to save chat history to a database after each request, and not block the user input until the messages are saved.
This is how we add the endpoint to the app:
add_routes( app, agent, path="/agent", per_req_config_modifier=per_request_config_modifier, config_keys=["configurable", "metadata"] )
Thanks
Hi @Sara2823 you can use the APIHandler directly if you need fine grained control over the endpoint definition (e.g., to expose background tasks).
APIHandler
How to add a FastAPI BackgroundTask to a LangServe endpoint?
We need to save chat history to a database after each request, and not block the user input until the messages are saved.
This is how we add the endpoint to the app:
Thanks