community[patch]: callback before yield for titan takeoff (#26930)

**Description:** Moves yield to after callback for `_stream` function
for the titan takeoff model in the community llm package
**Issue:** #16913
This commit is contained in:
Subhrajyoty Roy 2024-09-27 18:10:22 +05:30 committed by GitHub
parent c6350d636e
commit 5f2cc4ecb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -252,13 +252,13 @@ class TitanTakeoff(LLM):
if buffer: # Ensure that there's content to process.
chunk = GenerationChunk(text=buffer)
buffer = "" # Reset buffer for the next set of data.
yield chunk
if run_manager:
run_manager.on_llm_new_token(token=chunk.text)
yield chunk
# Yield any remaining content in the buffer.
if buffer:
chunk = GenerationChunk(text=buffer.replace("</s>", ""))
yield chunk
if run_manager:
run_manager.on_llm_new_token(token=chunk.text)
yield chunk