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
…#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](#16913)
**Dependencies:** None
  • Loading branch information
sepiatone authored and hinthornw committed Apr 26, 2024
1 parent 974728f commit c1e5319
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 c1e5319

Please sign in to comment.