mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-25 12:33:39 +00:00
community[patch]: Invoke callback prior to yielding token (#23638)
- **Description:** Invoke callback prior to yielding token in stream and astream methods for ChatZhipuAI. - **Issue:** the issue #16913
This commit is contained in:
parent
b5aef4cf97
commit
96af8f31ae
@ -496,9 +496,10 @@ class ChatZhipuAI(BaseChatModel):
|
||||
chunk = ChatGenerationChunk(
|
||||
message=chunk, generation_info=generation_info
|
||||
)
|
||||
yield chunk
|
||||
if run_manager:
|
||||
run_manager.on_llm_new_token(chunk.text, chunk=chunk)
|
||||
yield chunk
|
||||
|
||||
if finish_reason is not None:
|
||||
break
|
||||
|
||||
@ -582,8 +583,9 @@ class ChatZhipuAI(BaseChatModel):
|
||||
chunk = ChatGenerationChunk(
|
||||
message=chunk, generation_info=generation_info
|
||||
)
|
||||
yield chunk
|
||||
if run_manager:
|
||||
await run_manager.on_llm_new_token(chunk.text, chunk=chunk)
|
||||
yield chunk
|
||||
|
||||
if finish_reason is not None:
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user