support: yield sse_starlette.ServerSentEvent in /stream#701
support: yield sse_starlette.ServerSentEvent in /stream#701Takuya Igei (itok01) wants to merge 4 commits intolangchain-ai:mainfrom
sse_starlette.ServerSentEvent in /stream#701Conversation
This commit adds support for Server-Sent Events (SSE) in the APIHandler class. It imports the necessary modules from `sse_starlette` and includes a check for the `ServerSentEvent` class. If SSE is supported and the chunk is an instance of `ServerSentEvent`, it yields the chunk. This change improves the functionality of the APIHandler by enabling SSE support.
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the username Takuya Igei (@itok01) on file. In order for us to review and merge your code, please complete the Individual Contributor License Agreement here https://forms.gle/AQFbtkWRoHXUgipM6 . This process is done manually on our side, so after signing the form one of the maintainers will add you to the contributors list. For more details about why we have a CLA and other contribution guidelines please see: https://github.com/langchain-ai/langserve/blob/main/CONTRIBUTING.md. |
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the username Takuya Igei (@itok01) on file. In order for us to review and merge your code, please complete the Individual Contributor License Agreement here https://forms.gle/AQFbtkWRoHXUgipM6 . This process is done manually on our side, so after signing the form one of the maintainers will add you to the contributors list. For more details about why we have a CLA and other contribution guidelines please see: https://github.com/langchain-ai/langserve/blob/main/CONTRIBUTING.md. |
Allows the
/streamendpoint to returnsse_starlette.ServerSentEventfrom runnable, allowing you to return custom events such asevent: error.The reason for not using
langserve.server_sent_events.ServerSentEventis that is unbable to check withisinstance()whether an object is alangserve.server_sent_events.ServerSentEvent.Example
Run ./examples/custom_events/server.py
/stream:/invoke: