mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-18 16:16:33 +00:00
langchain_mistralai[patch]: Invoke callback prior to yielding token (#16986)
- **Description:** Invoke callback prior to yielding token in stream and astream methods for ChatMistralAI. - **Issue:** https://github.com/langchain-ai/langchain/issues/16913
This commit is contained in:
@@ -317,9 +317,9 @@ class ChatMistralAI(BaseChatModel):
|
||||
continue
|
||||
chunk = _convert_delta_to_message_chunk(delta, default_chunk_class)
|
||||
default_chunk_class = chunk.__class__
|
||||
yield ChatGenerationChunk(message=chunk)
|
||||
if run_manager:
|
||||
run_manager.on_llm_new_token(token=chunk.content, chunk=chunk)
|
||||
yield ChatGenerationChunk(message=chunk)
|
||||
|
||||
async def _astream(
|
||||
self,
|
||||
@@ -342,9 +342,9 @@ class ChatMistralAI(BaseChatModel):
|
||||
continue
|
||||
chunk = _convert_delta_to_message_chunk(delta, default_chunk_class)
|
||||
default_chunk_class = chunk.__class__
|
||||
yield ChatGenerationChunk(message=chunk)
|
||||
if run_manager:
|
||||
await run_manager.on_llm_new_token(token=chunk.content, chunk=chunk)
|
||||
yield ChatGenerationChunk(message=chunk)
|
||||
|
||||
async def _agenerate(
|
||||
self,
|
||||
|
Reference in New Issue
Block a user