From 3d5514af0442426927029a68e15f25b21e8da6b1 Mon Sep 17 00:00:00 2001 From: Meenakshi Ruia Date: Wed, 25 Dec 2024 23:28:58 +0530 Subject: [PATCH] community/chat_models/bedrock.py - added yield after callback --- libs/community/langchain_community/chat_models/bedrock.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/chat_models/bedrock.py b/libs/community/langchain_community/chat_models/bedrock.py index 6b36208390379..35ad534c165d4 100644 --- a/libs/community/langchain_community/chat_models/bedrock.py +++ b/libs/community/langchain_community/chat_models/bedrock.py @@ -264,7 +264,10 @@ def _stream( **kwargs, ): delta = chunk.text - yield ChatGenerationChunk(message=AIMessageChunk(content=delta)) + cg_chunk = ChatGenerationChunk(message=AIMessageChunk(content=delta)) + if run_manager: + run_manager.on_llm_new_token(delta, chunk = cg_chunk ) + yield cg_chunk def _generate( self,