Skip to content

The agent engineering platform.

community[patch]: callback before yield for mlx pipeline (#26928)

Subhrajyoty Roy7037ba0f06dd
diff --git a/libs/community/langchain_community/llms/mlx_pipeline.py b/libs/community/langchain_community/llms/mlx_pipeline.py
index 3856a80658..1e320a24f9 100644
--- a/libs/community/langchain_community/llms/mlx_pipeline.py
+++ b/libs/community/langchain_community/llms/mlx_pipeline.py
@@ -232,9 +232,9 @@ class MLXPipeline(LLM):
# yield text, if any
if text:
chunk = GenerationChunk(text=text)
- yield chunk
if run_manager:
run_manager.on_llm_new_token(chunk.text)
+ yield chunk
# break if stop sequence found
if token == eos_token_id or (stop is not None and text in stop):