From 893eb612d4be1a94c33268a4f7e3dd4e13550fe7 Mon Sep 17 00:00:00 2001 From: Subhrajyoty Roy Date: Fri, 27 Sep 2024 04:37:02 +0000 Subject: [PATCH] community[patch]: callback before yield for titan takeoff --- libs/community/langchain_community/llms/titan_takeoff.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/llms/titan_takeoff.py b/libs/community/langchain_community/llms/titan_takeoff.py index f89a1f5e3ac76..7f1d765a0d698 100644 --- a/libs/community/langchain_community/llms/titan_takeoff.py +++ b/libs/community/langchain_community/llms/titan_takeoff.py @@ -252,13 +252,13 @@ def _stream( if buffer: # Ensure that there's content to process. chunk = GenerationChunk(text=buffer) buffer = "" # Reset buffer for the next set of data. - yield chunk if run_manager: run_manager.on_llm_new_token(token=chunk.text) + yield chunk # Yield any remaining content in the buffer. if buffer: chunk = GenerationChunk(text=buffer.replace("", "")) - yield chunk if run_manager: run_manager.on_llm_new_token(token=chunk.text) + yield chunk