From 5ac18604846aed84ac3b95741e8e3c19f7014997 Mon Sep 17 00:00:00 2001 From: Yudhajit Sinha Date: Wed, 20 Mar 2024 20:27:27 +0530 Subject: [PATCH] community[patch]: Invoke callback prior to yielding token (replicate) (#18626) ## PR title community[patch]: Invoke callback prior to yielding token ## PR message - Description: Invoke callback prior to yielding token in _stream_ method in llms/replicate. - Issue: #16913 - Dependencies: None --- libs/community/langchain_community/llms/replicate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/community/langchain_community/llms/replicate.py b/libs/community/langchain_community/llms/replicate.py index b086aed3489..91f9ce4e75f 100644 --- a/libs/community/langchain_community/llms/replicate.py +++ b/libs/community/langchain_community/llms/replicate.py @@ -177,12 +177,12 @@ class Replicate(LLM): if not output: break if output: - yield GenerationChunk(text=output) if run_manager: run_manager.on_llm_new_token( output, verbose=self.verbose, ) + yield GenerationChunk(text=output) if stop_condition_reached: break