mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 19:47:13 +00:00
community[patch]: callback before yield for deepsparse llm (#26822)
**Description:** Moves yield to after callback for `_stream` and `_astream` function for the deepsparse model in the community package **Issue:** #16913
This commit is contained in:
@@ -190,10 +190,10 @@ class DeepSparse(LLM):
|
|||||||
)
|
)
|
||||||
for token in inference:
|
for token in inference:
|
||||||
chunk = GenerationChunk(text=token.generations[0].text)
|
chunk = GenerationChunk(text=token.generations[0].text)
|
||||||
yield chunk
|
|
||||||
|
|
||||||
if run_manager:
|
if run_manager:
|
||||||
run_manager.on_llm_new_token(token=chunk.text)
|
run_manager.on_llm_new_token(token=chunk.text)
|
||||||
|
yield chunk
|
||||||
|
|
||||||
async def _astream(
|
async def _astream(
|
||||||
self,
|
self,
|
||||||
@@ -228,7 +228,7 @@ class DeepSparse(LLM):
|
|||||||
)
|
)
|
||||||
for token in inference:
|
for token in inference:
|
||||||
chunk = GenerationChunk(text=token.generations[0].text)
|
chunk = GenerationChunk(text=token.generations[0].text)
|
||||||
yield chunk
|
|
||||||
|
|
||||||
if run_manager:
|
if run_manager:
|
||||||
await run_manager.on_llm_new_token(token=chunk.text)
|
await run_manager.on_llm_new_token(token=chunk.text)
|
||||||
|
yield chunk
|
||||||
|
Reference in New Issue
Block a user