Skip to content

The agent engineering platform.

community[patch]: callback before yield for deepsparse llm (#26822)

Subhrajyoty Royb1da532522f3
diff --git a/libs/community/langchain_community/llms/deepsparse.py b/libs/community/langchain_community/llms/deepsparse.py
index 9375a3f772..6a743cd506 100644
--- a/libs/community/langchain_community/llms/deepsparse.py
+++ b/libs/community/langchain_community/llms/deepsparse.py
@@ -190,10 +190,10 @@ class DeepSparse(LLM):
)
for token in inference:
chunk = GenerationChunk(text=token.generations[0].text)
- yield chunk
if run_manager:
run_manager.on_llm_new_token(token=chunk.text)
+ yield chunk
async def _astream(
self,
@@ -228,7 +228,7 @@ class DeepSparse(LLM):
)
for token in inference:
chunk = GenerationChunk(text=token.generations[0].text)
- yield chunk
if run_manager:
await run_manager.on_llm_new_token(token=chunk.text)
+ yield chunk