mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-03 18:24:10 +00:00
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:
parent
13acf9e6b0
commit
b61fb98466
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user