Skip to content

The agent engineering platform.

community[patch]: invoke callback prior to yielding token (fireworks) (#19388)

aditya thomas49e932cd2441
diff --git a/libs/community/langchain_community/llms/fireworks.py b/libs/community/langchain_community/llms/fireworks.py
index c12733480c..1bf40264d5 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(