From 5f2cc4ecb26cddc48faf177cbdc64dfcb64a0279 Mon Sep 17 00:00:00 2001 From: Subhrajyoty Roy Date: Fri, 27 Sep 2024 18:10:22 +0530 Subject: [PATCH] community[patch]: callback before yield for titan takeoff (#26930) **Description:** Moves yield to after callback for `_stream` function for the titan takeoff model in the community llm package **Issue:** #16913 --- 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 f89a1f5e3ac..7f1d765a0d6 100644 --- a/libs/community/langchain_community/llms/titan_takeoff.py +++ b/libs/community/langchain_community/llms/titan_takeoff.py @@ -252,13 +252,13 @@ class TitanTakeoff(LLM): 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