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:
Subhrajyoty Roy 2024-09-24 23:25:52 +05:30 committed by GitHub
parent de70a64e3a
commit b1da532522
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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