Skip to content

The agent engineering platform.

community[patch]: callback before yield for cloudflare (#26927)

Subhrajyoty Roy7f37fd8b80b2
diff --git a/libs/community/langchain_community/llms/cloudflare_workersai.py b/libs/community/langchain_community/llms/cloudflare_workersai.py
index 314a32223e..0fb6ac6053 100644
--- a/libs/community/langchain_community/llms/cloudflare_workersai.py
+++ b/libs/community/langchain_community/llms/cloudflare_workersai.py
@@ -105,9 +105,9 @@ class CloudflareWorkersAI(LLM):
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