diff --git a/libs/community/langchain_community/llms/cloudflare_workersai.py b/libs/community/langchain_community/llms/cloudflare_workersai.py index 314a32223e877..0fb6ac6053d3d 100644 --- a/libs/community/langchain_community/llms/cloudflare_workersai.py +++ b/libs/community/langchain_community/llms/cloudflare_workersai.py @@ -105,9 +105,9 @@ def _stream( logger.debug(chunk) raise e if data is not None and "response" in data: + if run_manager: + run_manager.on_llm_new_token(data["response"]) yield GenerationChunk(text=data["response"]) - if run_manager: - run_manager.on_llm_new_token(data["response"]) logger.debug("stream end") self.streaming = original_steaming