From 79334a10deea5bb2b1810fdc29ec409bf2d5167b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 4 Oct 2023 17:42:12 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(callback.py):=20refactor?= =?UTF-8?q?=20StreamingLLMCallbackHandler=20constructor=20to=20improve=20c?= =?UTF-8?q?ode=20readability=20and=20maintainability=20=F0=9F=90=9B=20fix(?= =?UTF-8?q?callback.py):=20assign=20websocket=20attribute=20from=20chat=5F?= =?UTF-8?q?service.active=5Fconnections=20to=20self.websocket=20to=20avoid?= =?UTF-8?q?=20potential=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/callback.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/langflow/api/v1/callback.py b/src/backend/langflow/api/v1/callback.py index 7387e1dd5..787ca9680 100644 --- a/src/backend/langflow/api/v1/callback.py +++ b/src/backend/langflow/api/v1/callback.py @@ -124,7 +124,9 @@ class StreamingLLMCallbackHandler(BaseCallbackHandler): """Callback handler for streaming LLM responses.""" def __init__(self, client_id: str): + self.chat_service = get_chat_service() self.client_id = client_id + self.websocket = self.chat_service.active_connections[self.client_id] def on_llm_new_token(self, token: str, **kwargs: Any) -> None: resp = ChatResponse(message=token, type="stream", intermediate_steps="")