🔧 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:
parent
0b2cfb3bbe
commit
79334a10de
1 changed files with 2 additions and 0 deletions
|
|
@ -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="")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue