From b61fb9846614a6c84b61aede41c1adcbbbc2a9cb Mon Sep 17 00:00:00 2001 From: Subhrajyoty Roy Date: Wed, 25 Sep 2024 19:01:12 +0530 Subject: [PATCH] community[patch]: callback before yield for friendli (#26842) **Description:** Moves yield to after callback for `_stream` and `_astream` function for the friendli model in the community package **Issue:** #16913 --- libs/community/langchain_community/llms/friendli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/llms/friendli.py b/libs/community/langchain_community/llms/friendli.py index e6d13155cd8..74b1ef7d199 100644 --- a/libs/community/langchain_community/llms/friendli.py +++ b/libs/community/langchain_community/llms/friendli.py @@ -233,9 +233,9 @@ class Friendli(LLM, BaseFriendli): ) for line in stream: chunk = _stream_response_to_generation_chunk(line) - yield chunk if run_manager: run_manager.on_llm_new_token(line.text, chunk=chunk) + yield chunk async def _astream( self, @@ -250,9 +250,9 @@ class Friendli(LLM, BaseFriendli): ) async for line in stream: chunk = _stream_response_to_generation_chunk(line) - yield chunk if run_manager: await run_manager.on_llm_new_token(line.text, chunk=chunk) + yield chunk def _generate( self,