community[patch]: Invoke callback prior to yielding token (#18288)

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

PR message
Description: Invoke on_llm_new_token callback prior to yielding token in
_stream and _astream methods.
Issue: https://github.com/langchain-ai/langchain/issues/16913
Dependencies: None
Twitter handle: None
pull/18289/head
William De Vena 4 months ago committed by GitHub
parent ca4f5e2408
commit 6b58943917
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -175,6 +175,6 @@ class VolcEngineMaasLLM(LLM, VolcEngineMaasBase):
chunk = GenerationChunk(
text=res.get("choice", {}).get("message", {}).get("content", "")
)
yield chunk
if run_manager:
run_manager.on_llm_new_token(chunk.text, chunk=chunk)
yield chunk

Loading…
Cancel
Save