From 5a616b1860ac6128b330c5687ebc14936ca9da86 Mon Sep 17 00:00:00 2001 From: Subhrajyoty Roy Date: Thu, 26 Sep 2024 02:30:08 +0000 Subject: [PATCH] community[patch]: callback before yield for gigachat --- libs/community/langchain_community/llms/gigachat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/llms/gigachat.py b/libs/community/langchain_community/llms/gigachat.py index 468d68cd9f4a8..a867bc1943786 100644 --- a/libs/community/langchain_community/llms/gigachat.py +++ b/libs/community/langchain_community/llms/gigachat.py @@ -311,9 +311,9 @@ def _stream( for chunk in self._client.stream(payload): if chunk.choices: content = chunk.choices[0].delta.content - yield GenerationChunk(text=content) if run_manager: run_manager.on_llm_new_token(content) + yield GenerationChunk(text=content) async def _astream( self, @@ -327,9 +327,9 @@ async def _astream( async for chunk in self._client.astream(payload): if chunk.choices: content = chunk.choices[0].delta.content - yield GenerationChunk(text=content) if run_manager: await run_manager.on_llm_new_token(content) + yield GenerationChunk(text=content) model_config = ConfigDict( extra="allow",