community[patch]: Invoke callback prior to yielding token (replicate) (#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: #16913 
- Dependencies: None
This commit is contained in:
Yudhajit Sinha 2024-03-20 20:27:27 +05:30 committed by GitHub
parent 9525e392de
commit 5ac1860484
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -177,12 +177,12 @@ class Replicate(LLM):
if not output: if not output:
break break
if output: if output:
yield GenerationChunk(text=output)
if run_manager: if run_manager:
run_manager.on_llm_new_token( run_manager.on_llm_new_token(
output, output,
verbose=self.verbose, verbose=self.verbose,
) )
yield GenerationChunk(text=output)
if stop_condition_reached: if stop_condition_reached:
break break