Skip to content

feat: Add mlflow filter pipeline#602

Open
WeichenXu123 wants to merge 10 commits into
open-webui:mainfrom
WeichenXu123:mlflow-filter
Open

feat: Add mlflow filter pipeline#602
WeichenXu123 wants to merge 10 commits into
open-webui:mainfrom
WeichenXu123:mlflow-filter

Conversation

@WeichenXu123
Copy link
Copy Markdown

@WeichenXu123 WeichenXu123 commented Apr 20, 2026

MLflow Filter Pipeline

Adds a filter pipeline that integrates https://mlflow.org/ tracing with Open WebUI, enabling observability for multi-turn chat sessions.

What it does

  • inlet: Captures the last user message and session context before each request
  • outlet: Logs a complete trace per turn — user input, assistant response, model name, and token usage — grouped under the same session in the MLflow UI

Features

  • Multi-turn session grouping — all turns of a conversation are linked via mlflow.trace.session, viewable with "Group by session" in the MLflow UI
  • Per-turn tracing — each request/response pair is logged as a separate MLflow trace with latency and status
  • Token usage tracking — input/output token counts are captured when provided by the backend, automatically aggregated at the trace level
  • User attribution — traces are tagged with the authenticated user's email via mlflow.trace.user

Requirements

  • MLflow tracking server running and accessible: mlflow server --host 0.0.0.0 --port 5000
  • requirements: mlflow>=2.14.0

Configuration (Valves)

  • mlflow_tracking_uri (default: http://localhost:5000) — MLflow tracking server URI
  • mlflow_experiment_name (default: open-webui) — Experiment name in MLflow
  • debug (default: false) — Enable debug logging

Setup

  1. Start MLflow: mlflow server --disable-security-middleware
  2. Upload this pipeline in Open WebUI → Admin → Pipelines
  3. Set MLFLOW_TRACKING_URI env var (Docker users: http://host.docker.internal:5000)
  4. Open the MLflow UI and enable "Group by session" to view full conversations

end-to-end test in local machine:

Launch Mlflow server

MLFLOW_LOGGING_LEVEL=DEBUG mlflow server --disable-security-middleware

Launch Openweb UI server

open-webui serve

Launch pipeline service by docker

  1. build a dockerfile and save it as Dockerfile.mlflow in current directory.
FROM ghcr.io/open-webui/pipelines:main
RUN pip install --no-cache-dir mlflow
  1. build image:
docker build -f Dockerfile.mlflow -t pipelines-mlflow .
  1. launch the docker container:
docker run -p 9099:9099 --add-host=host.docker.internal:host-gateway -v pipelines:/app/pipelines --name pipelines --restart always -e MLFLOW_TRACKING_URI=http://host.docker.internal:5000/  -e DEBUG_MODE=true pipelines-mlflow

OpenWebUI pipeline configure:

image

OpenWebUI chat:

image

MLflow traces:

single traces:
image
image
chat session:
image

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Copilot AI review requested due to automatic review settings April 20, 2026 15:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new example filter pipeline that integrates MLflow tracing with Open WebUI to provide per-turn traces grouped by multi-turn chat session.

Changes:

  • Introduces an MLflow filter pipeline with configurable valves (tracking URI, experiment name, debug).
  • Captures the latest user message on inlet and logs the corresponding assistant response + token usage on outlet.
  • Groups turns into a single MLflow session via mlflow.trace.session and tags traces with the authenticated user email.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/filters/mlflow_filter_pipeline.py Outdated
Comment thread examples/filters/mlflow_filter_pipeline.py Outdated
Comment thread examples/filters/mlflow_filter_pipeline.py Outdated
Comment thread examples/filters/mlflow_filter_pipeline.py
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
@WeichenXu123
Copy link
Copy Markdown
Author

CC @tjbck would you take a look ? thanks!

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants