Skip to content

Commit

Permalink
community[patch]: Invoke callback prior to yielding token (replicate) (
Browse files Browse the repository at this point in the history
…langchain-ai#18626)

## PR title
community[patch]: Invoke callback prior to yielding token

## PR message
- Description: Invoke callback prior to yielding token in _stream_
method in llms/replicate.
- Issue: langchain-ai#16913 
- Dependencies: None
  • Loading branch information
Lord-Haji authored and chrispy-snps committed Mar 30, 2024
1 parent c6bc7b6 commit 1e62e07
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libs/community/langchain_community/llms/replicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ def _stream(
if not output:
break
if output:
yield GenerationChunk(text=output)
if run_manager:
run_manager.on_llm_new_token(
output,
verbose=self.verbose,
)
yield GenerationChunk(text=output)
if stop_condition_reached:
break

Expand Down

0 comments on commit 1e62e07

Please sign in to comment.