Skip to content

Commit

Permalink
community[patch]: invoke callback prior to yielding token (fireworks) (
Browse files Browse the repository at this point in the history
…langchain-ai#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
langchain-ai#16913](langchain-ai#16913)
**Dependencies:** None
  • Loading branch information
sepiatone authored and gkorland committed Mar 30, 2024
1 parent 28f62f1 commit cb71e37
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/community/langchain_community/llms/fireworks.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ def _stream(
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,
Expand All @@ -207,9 +207,9 @@ async def _astream(
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(
Expand Down

0 comments on commit cb71e37

Please sign in to comment.