-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Add MLflow Prompt Registry provider #4170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
williamcaban
wants to merge
2
commits into
llamastack:main
Choose a base branch
from
williamcaban:feat/mlflow-prompt-registry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,598
−229
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| name: MLflow Prompts Integration Tests | ||
|
|
||
| run-name: Run the integration test suite with MLflow Prompt Registry provider | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - 'release-[0-9]+.[0-9]+.x' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - 'release-[0-9]+.[0-9]+.x' | ||
| paths: | ||
| - 'src/llama_stack/providers/remote/prompts/mlflow/**' | ||
| - 'tests/integration/providers/remote/prompts/mlflow/**' | ||
| - 'tests/unit/providers/remote/prompts/mlflow/**' | ||
| - 'uv.lock' | ||
| - 'pyproject.toml' | ||
| - 'requirements.txt' | ||
| - '.github/workflows/integration-mlflow-tests.yml' # This workflow | ||
| schedule: | ||
| - cron: '0 0 * * *' # Daily at 12 AM UTC | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| test-mlflow: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ${{ github.event.schedule == '0 0 * * *' && fromJSON('["3.12", "3.13"]') || fromJSON('["3.12"]') }} | ||
| fail-fast: false | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | ||
|
|
||
| - name: Install dependencies | ||
| uses: ./.github/actions/setup-runner | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Setup MLflow Server | ||
| run: | | ||
| docker run --rm -d --pull always \ | ||
| --name mlflow \ | ||
| -p 5555:5555 \ | ||
| ghcr.io/mlflow/mlflow:latest \ | ||
| mlflow server \ | ||
| --host 0.0.0.0 \ | ||
| --port 5555 \ | ||
| --backend-store-uri sqlite:///mlflow.db \ | ||
| --default-artifact-root ./mlruns | ||
|
|
||
| - name: Wait for MLflow to be ready | ||
| run: | | ||
| echo "Waiting for MLflow to be ready..." | ||
| for i in {1..60}; do | ||
| if curl -s http://localhost:5555/health | grep -q '"status": "OK"'; then | ||
| echo "MLflow is ready!" | ||
| exit 0 | ||
| fi | ||
| echo "Not ready yet... ($i/60)" | ||
| sleep 2 | ||
| done | ||
| echo "MLflow failed to start" | ||
| docker logs mlflow | ||
| exit 1 | ||
|
|
||
| - name: Verify MLflow API | ||
| run: | | ||
| echo "Testing MLflow API..." | ||
| curl -X GET http://localhost:5555/api/2.0/mlflow/experiments/list | ||
| echo "" | ||
| echo "MLflow API is responding!" | ||
|
|
||
| - name: Build Llama Stack | ||
| run: | | ||
| uv run --no-sync llama stack list-deps ci-tests | xargs -L1 uv pip install | ||
|
|
||
| - name: Install MLflow Python client | ||
| run: | | ||
| uv pip install 'mlflow>=3.4.0' | ||
|
|
||
| - name: Check Storage and Memory Available Before Tests | ||
| if: ${{ always() }} | ||
| run: | | ||
| free -h | ||
| df -h | ||
|
|
||
| - name: Run MLflow Integration Tests | ||
| env: | ||
| MLFLOW_TRACKING_URI: http://localhost:5555 | ||
| run: | | ||
| uv run --no-sync \ | ||
| pytest -sv \ | ||
| tests/integration/providers/remote/prompts/mlflow/ | ||
|
|
||
| - name: Check Storage and Memory Available After Tests | ||
| if: ${{ always() }} | ||
| run: | | ||
| free -h | ||
| df -h | ||
|
|
||
| - name: Write MLflow logs to file | ||
| if: ${{ always() }} | ||
| run: | | ||
| docker logs mlflow > mlflow.log 2>&1 || true | ||
|
|
||
| - name: Upload all logs to artifacts | ||
| if: ${{ always() }} | ||
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | ||
| with: | ||
| name: mlflow-logs-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.python-version }} | ||
| path: | | ||
| *.log | ||
| retention-days: 1 | ||
|
|
||
| - name: Stop MLflow container | ||
| if: ${{ always() }} | ||
| run: | | ||
| docker stop mlflow || true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| --- | ||
| sidebar_label: Prompts | ||
| title: Prompts | ||
| --- | ||
|
|
||
| # Prompts | ||
|
|
||
| ## Overview | ||
|
|
||
| This section contains documentation for all available providers for the **prompts** API. | ||
|
|
||
| The Prompts API enables centralized management of prompt templates with versioning, variable handling, and team collaboration capabilities. | ||
|
|
||
| ## Available Providers | ||
|
|
||
| ### Inline Providers | ||
|
|
||
| Inline providers run in the same process as the Llama Stack server and require no external dependencies: | ||
|
|
||
| - **[inline::reference](inline_reference.mdx)** - Reference implementation using KVStore backend (SQLite, PostgreSQL, etc.) | ||
| - Zero external dependencies | ||
| - Supports local SQLite or PostgreSQL storage | ||
| - Full CRUD operations including deletion | ||
| - Ideal for local development and single-server deployments | ||
|
|
||
| ### Remote Providers | ||
|
|
||
| Remote providers connect to external services for centralized prompt management: | ||
|
|
||
| - **[remote::mlflow](remote_mlflow.mdx)** - MLflow Prompt Registry integration (requires MLflow 3.4+) | ||
| - Centralized prompt management across teams | ||
| - Built-in versioning and audit trail | ||
| - Supports authentication (per-request, config, or environment variables) | ||
| - Integrates with Databricks and enterprise MLflow deployments | ||
| - Ideal for team collaboration and production environments | ||
|
|
||
| ## Choosing a Provider | ||
|
|
||
| ### Use `inline::reference` when: | ||
| - Developing locally or deploying to a single server | ||
| - You want zero external dependencies | ||
| - SQLite or PostgreSQL storage is sufficient | ||
| - You need full CRUD operations (including deletion) | ||
| - You prefer simple configuration | ||
|
|
||
| ### Use `remote::mlflow` when: | ||
| - Working in a team environment with multiple users | ||
| - You need centralized prompt management | ||
| - Integration with existing MLflow infrastructure | ||
| - You need authentication and multi-tenant support | ||
| - Advanced versioning and audit trail capabilities are required | ||
|
|
||
| ## Quick Start Examples | ||
|
|
||
| ### Using inline::reference | ||
|
|
||
| ```yaml | ||
| prompts: | ||
| - provider_id: local-prompts | ||
| provider_type: inline::reference | ||
| config: | ||
| run_config: | ||
| storage: | ||
| stores: | ||
| prompts: | ||
| type: sqlite | ||
| db_path: ./prompts.db | ||
| ``` | ||
|
|
||
| ### Using remote::mlflow | ||
|
|
||
| ```yaml | ||
| prompts: | ||
| - provider_id: mlflow-prompts | ||
| provider_type: remote::mlflow | ||
| config: | ||
| mlflow_tracking_uri: http://localhost:5555 | ||
| experiment_name: llama-stack-prompts | ||
| auth_credential: ${env.MLFLOW_TRACKING_TOKEN} | ||
| ``` | ||
|
|
||
| ## Common Features | ||
|
|
||
| All prompt providers support: | ||
| - Create and store prompts with version control | ||
| - Retrieve prompts by ID and version | ||
| - Update prompts (creates new versions) | ||
| - List all prompts or versions of a specific prompt | ||
| - Set default version for a prompt | ||
| - Automatic variable extraction from `{{ variable }}` templates | ||
|
|
||
| For detailed documentation on each provider, see the individual provider pages linked above. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for adding the prompts docs!!
we also have this in the UI, maybe we should mention it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to making it available in the UI? If so, could that be a follow-up PR? I would prefer to avoid adding more to this one.