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

**Description:** Moves yield to after callback for `_stream` function
for the cloudfare workersai model in the community llm package
**Issue:** #16913
This commit is contained in:
Subhrajyoty Roy 2024-09-27 18:12:01 +05:30 committed by GitHub
parent 2d9a09dfa4
commit 7f37fd8b80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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