mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-26 07:20:57 +08:00
🔧 chore(callback.py): refactor StreamingLLMCallbackHandler constructor to improve code readability and maintainability
🐛 fix(callback.py): assign websocket attribute from chat_service.active_connections to self.websocket to avoid potential bugs
This commit is contained in:
@ -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="")
|
||||
|
||||
Reference in New Issue
Block a user