mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-03 12:07:36 +00:00
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:
@@ -252,13 +252,13 @@ class TitanTakeoff(LLM):
|
|||||||
if buffer: # Ensure that there's content to process.
|
if buffer: # Ensure that there's content to process.
|
||||||
chunk = GenerationChunk(text=buffer)
|
chunk = GenerationChunk(text=buffer)
|
||||||
buffer = "" # Reset buffer for the next set of data.
|
buffer = "" # Reset buffer for the next set of data.
|
||||||
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
|
||||||
|
|
||||||
# Yield any remaining content in the buffer.
|
# Yield any remaining content in the buffer.
|
||||||
if buffer:
|
if buffer:
|
||||||
chunk = GenerationChunk(text=buffer.replace("</s>", ""))
|
chunk = GenerationChunk(text=buffer.replace("</s>", ""))
|
||||||
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
|
||||||
|
Reference in New Issue
Block a user