From 49e932cd2441dafc6f7c249e63738b2694102564 Mon Sep 17 00:00:00 2001 From: aditya thomas Date: Sat, 23 Mar 2024 05:14:06 +0530 Subject: [PATCH] community[patch]: invoke callback prior to yielding token (fireworks) (#19388) **Description:** Invoke callback prior to yielding token for Fireworks **Issue:** [Callback for on_llm_new_token should be invoked before the token is yielded by the model #16913](https://github.com/langchain-ai/langchain/issues/16913) **Dependencies:** None --- libs/community/langchain_community/llms/fireworks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/llms/fireworks.py b/libs/community/langchain_community/llms/fireworks.py index c12733480c9..1bf40264d59 100644 --- a/libs/community/langchain_community/llms/fireworks.py +++ b/libs/community/langchain_community/llms/fireworks.py @@ -186,9 +186,9 @@ class Fireworks(BaseLLM): self, self.use_retry, run_manager=run_manager, stop=stop, **params ): chunk = _stream_response_to_generation_chunk(stream_resp) - yield chunk if run_manager: run_manager.on_llm_new_token(chunk.text, chunk=chunk) + yield chunk async def _astream( self, @@ -207,9 +207,9 @@ class Fireworks(BaseLLM): self, self.use_retry, run_manager=run_manager, stop=stop, **params ): chunk = _stream_response_to_generation_chunk(stream_resp) - yield chunk if run_manager: await run_manager.on_llm_new_token(chunk.text, chunk=chunk) + yield chunk def conditional_decorator(