From 2087cbae64655a6094d4c432eccab88dfb985516 Mon Sep 17 00:00:00 2001 From: William De Vena <60664495+williamdevena@users.noreply.github.com> Date: Sun, 3 Mar 2024 23:14:00 +0100 Subject: [PATCH] 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 --- libs/community/langchain_community/chat_models/perplexity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/community/langchain_community/chat_models/perplexity.py b/libs/community/langchain_community/chat_models/perplexity.py index 479b3fd4780..23d7c9e09a6 100644 --- a/libs/community/langchain_community/chat_models/perplexity.py +++ b/libs/community/langchain_community/chat_models/perplexity.py @@ -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,