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

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

## PR message
- Description: Invoke callback prior to yielding token in _stream method
in chat_models/perplexity.
- Issue: https://github.com/langchain-ai/langchain/issues/16913
- Dependencies: None
This commit is contained in:
William De Vena 2024-03-03 23:14:00 +01:00 committed by GitHub
parent eb04d0d3e2
commit 2087cbae64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -230,9 +230,9 @@ class ChatPerplexity(BaseChatModel):
)
default_chunk_class = chunk.__class__
chunk = ChatGenerationChunk(message=chunk, generation_info=generation_info)
yield chunk
if run_manager:
run_manager.on_llm_new_token(chunk.text, chunk=chunk)
yield chunk
def _generate(
self,