mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 03:26:17 +00:00
community[patch]: callback before yield for _stream/_astream (#17907)
- Description: callback on_llm_new_token before yield chunk for _stream/_astream for some chat models, make all chat models in a consistent behaviour. - Issue: N/A - Dependencies: N/A
This commit is contained in:
@@ -325,13 +325,13 @@ class GPTRouter(BaseChatModel):
|
||||
chunk.data, default_chunk_class
|
||||
)
|
||||
|
||||
yield chunk
|
||||
|
||||
if run_manager:
|
||||
run_manager.on_llm_new_token(
|
||||
token=chunk.message.content, chunk=chunk.message
|
||||
)
|
||||
|
||||
yield chunk
|
||||
|
||||
async def _astream(
|
||||
self,
|
||||
messages: List[BaseMessage],
|
||||
@@ -358,13 +358,13 @@ class GPTRouter(BaseChatModel):
|
||||
chunk.data, default_chunk_class
|
||||
)
|
||||
|
||||
yield chunk
|
||||
|
||||
if run_manager:
|
||||
await run_manager.on_llm_new_token(
|
||||
token=chunk.message.content, chunk=chunk.message
|
||||
)
|
||||
|
||||
yield chunk
|
||||
|
||||
def _create_message_dicts(
|
||||
self, messages: List[BaseMessage], stop: Optional[List[str]]
|
||||
) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]:
|
||||
|
Reference in New Issue
Block a user