The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community[patch]: Invoke on_llm_new_token callback before yielding chunk (#24938)
Anneli Samuel2204d8cb7d28
diff --git a/libs/community/langchain_community/chat_models/mlx.py b/libs/community/langchain_community/chat_models/mlx.pyindex 1bd9f740d7..e3a28c73c7 100644--- a/libs/community/langchain_community/chat_models/mlx.py+++ b/libs/community/langchain_community/chat_models/mlx.py@@ -186,9 +186,9 @@ class ChatMLX(BaseChatModel):# yield text, if anyif text:chunk = ChatGenerationChunk(message=AIMessageChunk(content=text))- yield chunkif run_manager:run_manager.on_llm_new_token(text, chunk=chunk)+ yield chunk# break if stop sequence foundif token == eos_token_id or (stop is not None and text in stop):