mirror of
https://github.com/langchain-ai/langserve.git
synced 2026-07-18 19:04:27 -04:00
servery.py on_event deprecated #116
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @albertoecf on GitHub (Feb 5, 2024).
Originally assigned to: @eyurtsev on GitHub.
Issue Description:
The on_event decorator used in langserve/server.py is deprecated. As of the current FastAPI version, lifespan event handlers should be used instead of on_event. This change is in line with the deprecation warning message.
Recommendation:
Please consider updating the code to use the new lifespan event handlers. You can find more information about lifespan events in the FastAPI documentation.
Motivation
While writing tests for our Langchain app, we encountered deprecation warnings related to the usage of the on_event decorator in the test setup.
warnings:
DeprecationWarning: on_event is deprecated, use lifespan event handlers instead.
Read more about it in the FastAPI docs for Lifespan Events.
@eyurtsev commented on GitHub (Feb 5, 2024):
Thanks for reporting the issue!
We unfortunately can't use life-span events. They require the ability to instantiate FastAPI app, which LangServe doesn't have since instantiation is controlled by the user.
We use on_event to display the splash screen when the server is loaded.
We will revisit this issue when the functionality will be deleted from FastAPI (rather than only marked for deprecation).
@albertoecf commented on GitHub (Feb 6, 2024):
Thanks @eyurtsev , make sense!
Should we close the issue and re open it when we are facing deletion from FastAPI?
@eyurtsev commented on GitHub (Feb 6, 2024):
hmm let's actually keep open for now -- changed my mind, we should probably start thinking about this before the fast api actually deletes functionality