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
This commit is contained in:
Subhrajyoty Roy
2024-09-25 19:01:12 +05:30
committed by GitHub
parent 13acf9e6b0
commit b61fb98466

View File

@@ -233,9 +233,9 @@ class Friendli(LLM, BaseFriendli):
) )
for line in stream: for line in stream:
chunk = _stream_response_to_generation_chunk(line) chunk = _stream_response_to_generation_chunk(line)
yield chunk
if run_manager: if run_manager:
run_manager.on_llm_new_token(line.text, chunk=chunk) run_manager.on_llm_new_token(line.text, chunk=chunk)
yield chunk
async def _astream( async def _astream(
self, self,
@@ -250,9 +250,9 @@ class Friendli(LLM, BaseFriendli):
) )
async for line in stream: async for line in stream:
chunk = _stream_response_to_generation_chunk(line) chunk = _stream_response_to_generation_chunk(line)
yield chunk
if run_manager: if run_manager:
await run_manager.on_llm_new_token(line.text, chunk=chunk) await run_manager.on_llm_new_token(line.text, chunk=chunk)
yield chunk
def _generate( def _generate(
self, self,