diff --git a/libs/community/langchain_community/chat_models/mlx.py b/libs/community/langchain_community/chat_models/mlx.py index 1bd9f740d782f..e3a28c73c7fce 100644 --- a/libs/community/langchain_community/chat_models/mlx.py +++ b/libs/community/langchain_community/chat_models/mlx.py @@ -186,9 +186,9 @@ def _stream( # yield text, if any if text: chunk = ChatGenerationChunk(message=AIMessageChunk(content=text)) - yield chunk if run_manager: run_manager.on_llm_new_token(text, chunk=chunk) + yield chunk # break if stop sequence found if token == eos_token_id or (stop is not None and text in stop):