repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
mlflow | mlflow/gateway/uc_function_utils.py | .py | # TODO: Move this in mlflow/gateway/utils/uc_functions.py
import json
import re
from dataclasses import dataclass
from io import StringIO
from typing import TYPE_CHECKING, Any, Literal
if TYPE_CHECKING:
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.catalog import FunctionInfo, Functio... | 347 | 12,558 |
mlflow | mlflow/gateway/guardrails.py | .py | from __future__ import annotations
import abc
import asyncio
import json
from contextlib import nullcontext
from typing import TYPE_CHECKING, Any
from fastapi import HTTPException
import mlflow
from mlflow.entities import SpanType
from mlflow.entities.assessment import Feedback
from mlflow.entities.gateway_guardrail... | 451 | 17,038 |
mlflow | mlflow/gateway/app.py | .py | import os
from pathlib import Path
from typing import Any
from fastapi import FastAPI, HTTPException, Request
from fastapi.openapi.docs import get_swagger_ui_html
from fastapi.responses import FileResponse, RedirectResponse
from pydantic import BaseModel, ConfigDict
from slowapi import Limiter, _rate_limit_exceeded_ha... | 487 | 18,533 |
mlflow | mlflow/gateway/tracing_utils.py | .py | import dataclasses
import functools
import inspect
import json
import logging
from collections.abc import Callable
from typing import Any
import pydantic
import mlflow
from mlflow.entities import SpanStatus, SpanType
from mlflow.entities.trace_location import MlflowExperimentLocation
from mlflow.gateway.config import... | 659 | 25,110 |
mlflow | mlflow/gateway/utils.py | .py | import base64
import functools
import json
import logging
import posixpath
import re
from typing import Any, AsyncGenerator, Iterator
from urllib.parse import urlparse
from fastapi import HTTPException
from mlflow.environment_variables import MLFLOW_GATEWAY_URI
from mlflow.exceptions import MlflowException
from mlflo... | 449 | 14,745 |
mlflow | mlflow/gateway/exceptions.py | .py | class AIGatewayConfigException(Exception):
pass
class AIGatewayException(Exception):
"""
A custom exception class for handling exceptions raised by the AI Gateway.
This will be transformed into an HTTPException before being returned to the client.
"""
def __init__(self, status_code: int, deta... | 15 | 431 |
mlflow | mlflow/gateway/runner.py | .py | import logging
import os
import subprocess
import sys
from typing import Generator
from watchfiles import watch
from mlflow.environment_variables import (
MLFLOW_GATEWAY_CONFIG,
MLFLOW_GATEWAY_RESOLVE_API_KEY_FROM_ENV,
MLFLOW_GATEWAY_RESOLVE_API_KEY_FROM_FILE,
)
from mlflow.gateway import app
from mlflow.... | 113 | 3,060 |
mlflow | mlflow/gateway/__init__.py | .py | from mlflow.gateway.utils import get_gateway_uri, set_gateway_uri
__all__ = [
"get_gateway_uri",
"set_gateway_uri",
]
| 7 | 127 |
mlflow | mlflow/gateway/base_models.py | .py | from typing import Any
from pydantic import BaseModel
class RequestModel(
BaseModel,
# Allow extra fields for pydantic request models, e.g. to support
# vendor-specific embeddings parameters
extra="allow",
):
"""
A pydantic model representing Gateway request data, such as a chat or completion... | 61 | 1,572 |
mlflow | mlflow/gateway/constants.py | .py | from enum import Enum
MLFLOW_GATEWAY_CALLER_HEADER = "X-MLflow-Gateway-Caller"
MLFLOW_GATEWAY_AUTH_HEADER = "X-MLflow-Authorization"
MLFLOW_GATEWAY_DURATION_HEADER = "X-MLflow-Gateway-Duration-Ms"
MLFLOW_GATEWAY_OVERHEAD_HEADER = "X-MLflow-Gateway-Overhead-Duration-Ms"
class GatewayCaller(str, Enum):
"""Known ca... | 51 | 2,182 |
mlflow | mlflow/gateway/provider_registry.py | .py | import logging
from mlflow import MlflowException
from mlflow.gateway.config import Provider
from mlflow.gateway.providers import BaseProvider
from mlflow.utils.plugins import get_entry_points
from mlflow.utils.provider_filter import is_provider_allowed
_logger = logging.getLogger(__name__)
class ProviderRegistry:
... | 108 | 4,890 |
mlflow | mlflow/gateway/guardrail_utils.py | .py | from __future__ import annotations
import dataclasses
import logging
from typing import TYPE_CHECKING, Any
from fastapi import Request
from mlflow.entities.gateway_guardrail import GuardrailStage
from mlflow.gateway.guardrails import JudgeGuardrail
from mlflow.gateway.schemas import chat
from mlflow.server.asgi_util... | 127 | 4,802 |
mlflow | mlflow/gateway/cli.py | .py | import click
from mlflow.environment_variables import MLFLOW_GATEWAY_CONFIG
from mlflow.gateway.config import _validate_config
from mlflow.gateway.runner import run_app
from mlflow.telemetry.events import GatewayStartEvent
from mlflow.telemetry.track import _record_event
from mlflow.utils.annotations import deprecated... | 57 | 1,624 |
mlflow | mlflow/gateway/config.py | .py | import json
import logging
import os
import pathlib
from enum import Enum
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal
import pydantic
import yaml
from pydantic import ConfigDict, ValidationError, field_validator, model_validator
from pydantic.json import pydantic_encoder
from mlflow.enviro... | 662 | 22,487 |
mlflow | mlflow/gateway/budget.py | .py | """Budget tracking and enforcement for the MLflow Gateway.
This module provides budget-related functions for recording costs, refreshing policies,
firing exceeded-budget webhooks, and creating on_complete callbacks for budget recording.
"""
import logging
from fastapi import HTTPException
import mlflow
from mlflow.... | 232 | 8,695 |
mlflow | mlflow/gateway/schemas/__init__.py | .py | from mlflow.gateway.schemas import chat, completions, embeddings
__all__ = ["chat", "completions", "embeddings"]
| 4 | 114 |
mlflow | mlflow/gateway/schemas/chat.py | .py | """
This module defines the schemas for the MLflow AI Gateway's chat endpoint.
The schemas must be compatible with OpenAI's Chat Completion API.
https://platform.openai.com/docs/api-reference/chat
NB: These Pydantic models just alias the models defined in mlflow.types.chat to avoid code
duplication, but with the ... | 137 | 4,232 |
mlflow | mlflow/gateway/schemas/embeddings.py | .py | from pydantic import ConfigDict
from mlflow.gateway.base_models import RequestModel, ResponseModel
_REQUEST_PAYLOAD_EXTRA_SCHEMA = {
"example": {
"input": ["hello", "world"],
}
}
class RequestPayload(RequestModel):
input: str | list[str] | list[int] | list[list[int]]
model_config = ConfigDi... | 89 | 2,199 |
mlflow | mlflow/gateway/schemas/completions.py | .py | from pydantic import ConfigDict
from mlflow.gateway.base_models import RequestModel, ResponseModel
from mlflow.types.chat import BaseRequestPayload
_REQUEST_PAYLOAD_EXTRA_SCHEMA = {
"example": {
"prompt": "hello",
"temperature": 0.0,
"max_tokens": 64,
"stop": ["END"],
"n": ... | 98 | 2,329 |
mlflow | mlflow/gateway/budget_tracker/__init__.py | .py | """Budget tracker for AI Gateway cost management.
Provides an abstract BudgetTracker interface and window computation helpers.
The concrete InMemoryBudgetTracker lives in ``budget_tracker.in_memory``.
"""
from __future__ import annotations
import threading
import time
from abc import ABC, abstractmethod
from datacla... | 256 | 9,435 |
mlflow | mlflow/gateway/budget_tracker/in_memory.py | .py | """In-memory budget tracker implementation."""
from __future__ import annotations
import threading
from dataclasses import dataclass, field
from datetime import datetime, timezone
from mlflow.entities.gateway_budget_policy import BudgetAction, GatewayBudgetPolicy
from mlflow.gateway.budget_tracker import (
Budge... | 165 | 6,035 |
mlflow | mlflow/gateway/budget_tracker/redis.py | .py | """Redis-backed budget tracker implementation."""
from __future__ import annotations
import json
import logging
from dataclasses import dataclass, field
from datetime import datetime, timezone
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import redis
from mlflow.entities.gateway_budget_policy import (
... | 359 | 12,137 |
mlflow | mlflow/gateway/providers/openai.py | .py | import json
import os
import warnings
from typing import TYPE_CHECKING, Any, AsyncIterable
from urllib.parse import urlparse, urlunparse
from mlflow.environment_variables import MLFLOW_ENABLE_UC_FUNCTIONS
from mlflow.exceptions import MlflowException
from mlflow.gateway.config import EndpointConfig, OpenAIAPIType, Ope... | 676 | 26,250 |
mlflow | mlflow/gateway/providers/sap_ai_core.py | .py | """SAP AI Core Orchestration v2 provider for MLflow Gateway.
URI scheme: ``sap-ai-core:/<model-name>``
The model name is embedded in the Orchestration v2 request body under
``config.modules.prompt_templating.model.name``. Auth is not handled here —
requests are routed through an HTTP egress gateway (``http://`` sche... | 173 | 6,334 |
mlflow | mlflow/gateway/providers/mosaicml.py | .py | import time
import warnings
from contextlib import contextmanager
from typing import Any
from mlflow.exceptions import MlflowException
from mlflow.gateway.config import EndpointConfig, MosaicMLConfig
from mlflow.gateway.exceptions import AIGatewayException
from mlflow.gateway.providers.base import BaseProvider
from ml... | 308 | 10,648 |
mlflow | mlflow/gateway/providers/vertex_ai.py | .py | """
Vertex AI provider for MLflow AI Gateway.
Extends the Gemini provider to use Vertex AI endpoints with Google Cloud
authentication (Application Default Credentials or service account JSON).
Three model types are supported:
- **Google models** (gemini-*, medlm-*, text-embedding-*, etc.):
Gemini API format with :... | 317 | 12,708 |
mlflow | mlflow/gateway/providers/utils.py | .py | import re
import time
from contextlib import asynccontextmanager
from contextvars import ContextVar
from typing import Any, AsyncGenerator
from urllib.parse import urlparse, urlunparse
from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS
from mlflow.gateway.constants import MLFLOW_GATEWAY_AUTH... | 245 | 10,066 |
mlflow | mlflow/gateway/providers/gemini.py | .py | import hashlib
import json
import time
from typing import Any, AsyncIterable
from mlflow.gateway.config import EndpointConfig, GeminiConfig
from mlflow.gateway.exceptions import AIGatewayException
from mlflow.gateway.providers.base import (
BaseProvider,
PassthroughAction,
ProviderAdapter,
_client_prov... | 981 | 35,829 |
mlflow | mlflow/gateway/providers/portkey.py | .py | from mlflow.gateway.config import PortkeyConfig
from mlflow.gateway.providers.openai_compatible import OpenAICompatibleProvider
class PortkeyProvider(OpenAICompatibleProvider):
DISPLAY_NAME = "Portkey"
CONFIG_TYPE = PortkeyConfig
DEFAULT_API_BASE = "https://api.portkey.ai/v1"
@property
def header... | 44 | 2,203 |
mlflow | mlflow/gateway/providers/groq.py | .py | from mlflow.gateway.config import _OpenAICompatibleConfig
from mlflow.gateway.providers.openai_compatible import OpenAICompatibleProvider
class GroqProvider(OpenAICompatibleProvider):
DISPLAY_NAME = "Groq"
CONFIG_TYPE = _OpenAICompatibleConfig
DEFAULT_API_BASE = "https://api.groq.com/openai/v1"
| 9 | 310 |
mlflow | mlflow/gateway/providers/databricks.py | .py | from collections.abc import AsyncIterable
from typing import Any
from mlflow.gateway.base_models import ConfigModel
from mlflow.gateway.config import EndpointConfig, EndpointType
from mlflow.gateway.providers.base import PassthroughAction
from mlflow.gateway.providers.openai_compatible import (
OpenAICompatibleAda... | 167 | 6,518 |
mlflow | mlflow/gateway/providers/xai.py | .py | from mlflow.gateway.config import _OpenAICompatibleConfig
from mlflow.gateway.providers.openai_compatible import OpenAICompatibleProvider
class XAIProvider(OpenAICompatibleProvider):
DISPLAY_NAME = "xAI"
CONFIG_TYPE = _OpenAICompatibleConfig
DEFAULT_API_BASE = "https://api.x.ai/v1"
| 9 | 297 |
mlflow | mlflow/gateway/providers/mlflow.py | .py | import time
from pydantic import BaseModel, StrictFloat, StrictStr, ValidationError, field_validator
from mlflow.gateway.config import EndpointConfig, MlflowModelServingConfig
from mlflow.gateway.constants import MLFLOW_SERVING_RESPONSE_KEY
from mlflow.gateway.exceptions import AIGatewayException
from mlflow.gateway.... | 240 | 8,780 |
mlflow | mlflow/gateway/providers/bedrock.py | .py | import asyncio
import json
import queue
import time
from enum import Enum
from typing import Any, AsyncIterable
from mlflow.gateway.config import (
AmazonBedrockConfig,
AWSBearerToken,
AWSIdAndKey,
AWSRole,
EndpointConfig,
)
from mlflow.gateway.constants import (
MLFLOW_AI_GATEWAY_ANTHROPIC_DEF... | 756 | 28,695 |
mlflow | mlflow/gateway/providers/__init__.py | .py | from mlflow.gateway.config import Provider
from mlflow.gateway.providers.base import BaseProvider
def get_provider(provider: Provider) -> type[BaseProvider]:
from mlflow.gateway.provider_registry import provider_registry
return provider_registry.get(provider)
| 9 | 271 |
mlflow | mlflow/gateway/providers/anthropic.py | .py | import json
import logging
import time
from typing import Any, AsyncIterable
from mlflow.gateway.config import AnthropicConfig, EndpointConfig
from mlflow.gateway.constants import (
MLFLOW_AI_GATEWAY_ANTHROPIC_DEFAULT_MAX_TOKENS,
MLFLOW_AI_GATEWAY_ANTHROPIC_MAXIMUM_MAX_TOKENS,
)
from mlflow.gateway.exceptions ... | 824 | 32,274 |
mlflow | mlflow/gateway/providers/mistral.py | .py | import json
import time
from collections.abc import AsyncIterable
from typing import Any
from mlflow.gateway.config import EndpointConfig, MistralConfig
from mlflow.gateway.providers.base import BaseProvider, ProviderAdapter
from mlflow.gateway.providers.utils import send_request, send_stream_request
from mlflow.gatew... | 299 | 10,553 |
mlflow | mlflow/gateway/providers/openai_compatible.py | .py | """
Base provider for OpenAI-compatible APIs.
Many LLM providers (Groq, DeepSeek, xAI, etc.) expose APIs that follow the
OpenAI chat/completions/embeddings format. This module provides a reusable
base class so that adding a new such provider requires only a config class,
a DISPLAY_NAME, and a default base URL.
"""
fr... | 386 | 13,935 |
mlflow | mlflow/gateway/providers/palm.py | .py | import time
import warnings
from typing import Any
from mlflow.gateway.config import EndpointConfig, PaLMConfig
from mlflow.gateway.exceptions import AIGatewayException
from mlflow.gateway.providers.base import BaseProvider
from mlflow.gateway.providers.utils import rename_payload_keys, send_request
from mlflow.gatewa... | 230 | 8,158 |
mlflow | mlflow/gateway/providers/ollama.py | .py | from mlflow.gateway.config import _OpenAICompatibleConfig
from mlflow.gateway.providers.openai_compatible import OpenAICompatibleProvider
class OllamaConfig(_OpenAICompatibleConfig):
# Ollama runs locally and doesn't require an API key by default
api_key: str = "ollama"
class OllamaProvider(OpenAICompatible... | 21 | 771 |
mlflow | mlflow/gateway/providers/togetherai.py | .py | import json
from typing import Any, AsyncGenerator, AsyncIterable
from mlflow.exceptions import MlflowException
from mlflow.gateway.config import EndpointConfig, TogetherAIConfig
from mlflow.gateway.exceptions import AIGatewayException
from mlflow.gateway.providers.base import BaseProvider, ProviderAdapter
from mlflow... | 452 | 17,148 |
mlflow | mlflow/gateway/providers/cohere.py | .py | import json
import time
import warnings
from typing import Any, AsyncGenerator, AsyncIterable
from mlflow.gateway.config import CohereConfig, EndpointConfig
from mlflow.gateway.exceptions import AIGatewayException
from mlflow.gateway.providers.base import BaseProvider, ProviderAdapter
from mlflow.gateway.providers.uti... | 465 | 16,252 |
mlflow | mlflow/gateway/providers/ai21labs.py | .py | import time
from mlflow.gateway.config import AI21LabsConfig, EndpointConfig
from mlflow.gateway.exceptions import AIGatewayException
from mlflow.gateway.providers.base import BaseProvider
from mlflow.gateway.providers.utils import rename_payload_keys, send_request
from mlflow.gateway.schemas import completions
clas... | 93 | 3,351 |
mlflow | mlflow/gateway/providers/openrouter.py | .py | from mlflow.gateway.config import _OpenAICompatibleConfig
from mlflow.gateway.providers.openai_compatible import OpenAICompatibleProvider
class OpenRouterProvider(OpenAICompatibleProvider):
DISPLAY_NAME = "OpenRouter"
CONFIG_TYPE = _OpenAICompatibleConfig
DEFAULT_API_BASE = "https://openrouter.ai/api/v1"
| 9 | 320 |
mlflow | mlflow/gateway/providers/huggingface.py | .py | import time
from typing import Any
from mlflow.gateway.config import EndpointConfig, HuggingFaceTextGenerationInferenceConfig
from mlflow.gateway.exceptions import AIGatewayException
from mlflow.gateway.providers.base import BaseProvider
from mlflow.gateway.providers.utils import (
rename_payload_keys,
send_re... | 121 | 4,810 |
mlflow | mlflow/gateway/providers/litellm.py | .py | from __future__ import annotations
import importlib.util
import json
from typing import Any, AsyncIterable
from mlflow.exceptions import MlflowException
from mlflow.gateway.config import EndpointConfig, LiteLLMConfig
from mlflow.gateway.providers.anthropic import _normalize_anthropic_input_tokens
from mlflow.gateway.... | 597 | 24,036 |
mlflow | mlflow/gateway/providers/base.py | .py | from abc import ABC, abstractmethod
from enum import Enum
from typing import Any, AsyncIterable
import numpy as np
import mlflow
from mlflow.entities import SpanType
from mlflow.entities.gateway_endpoint import FallbackStrategy
from mlflow.exceptions import MlflowException
from mlflow.gateway.base_models import Confi... | 896 | 35,606 |
mlflow | mlflow/gateway/providers/deepseek.py | .py | from mlflow.gateway.config import _OpenAICompatibleConfig
from mlflow.gateway.providers.openai_compatible import OpenAICompatibleProvider
class DeepSeekProvider(OpenAICompatibleProvider):
DISPLAY_NAME = "DeepSeek"
CONFIG_TYPE = _OpenAICompatibleConfig
DEFAULT_API_BASE = "https://api.deepseek.com/v1"
| 9 | 315 |
mlflow | mlflow/xgboost/__init__.py | .py | """
The ``mlflow.xgboost`` module provides an API for logging and loading XGBoost models.
This module exports XGBoost models with the following flavors:
XGBoost (native) format
This is the main flavor that can be loaded back into XGBoost.
:py:mod:`mlflow.pyfunc`
Produced for use by generic pyfunc-based deploym... | 924 | 38,561 |
mlflow | mlflow/xgboost/_autolog.py | .py | import logging
import xgboost
from packaging.version import Version
# Suppress a false positive pylint error: https://github.com/PyCQA/pylint/issues/1630
from mlflow.utils.autologging_utils import ExceptionSafeAbstractClass
_logger = logging.getLogger(__name__)
def _patch_metric_names(metric_dict):
# XGBoost p... | 74 | 2,774 |
mlflow | mlflow/sklearn/utils.py | .py | import inspect
import logging
import pkgutil
import platform
import warnings
from copy import deepcopy
from importlib import import_module
from numbers import Number
from operator import itemgetter
from typing import Any, Callable, NamedTuple
import numpy as np
from packaging.version import Version
from mlflow import... | 1,037 | 38,418 |
mlflow | mlflow/sklearn/__init__.py | .py | """
The ``mlflow.sklearn`` module provides an API for logging and loading scikit-learn models. This
module exports scikit-learn models with the following flavors:
Python (native) `pickle <https://scikit-learn.org/stable/modules/model_persistence.html>`_ format
This is the main flavor that can be loaded back into s... | 2,100 | 90,635 |
mlflow | mlflow/assistant/types.py | .py | import json
from enum import Enum
from typing import Any, Literal
from pydantic import BaseModel, Field
# Message interface between assistant providers and the assistant client
# Inspired by https://github.com/anthropics/claude-agent-sdk-python/blob/29c12cd80b256e88f321b2b8f1f5a88445077aa5/src/claude_agent_sdk/types.... | 138 | 4,369 |
mlflow | mlflow/assistant/gateway_connection.py | .py | """Store Assistant-managed vendor keys as Gateway LLM Connections."""
from mlflow.entities.gateway_endpoint import GatewayEndpointModelConfig, GatewayModelLinkageType
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import RESOURCE_DOES_NOT_EXIST, ErrorCode
from mlflow.tracking._tracking... | 79 | 2,774 |
mlflow | mlflow/assistant/__init__.py | .py | from functools import lru_cache
from mlflow.assistant.config import AssistantConfig
@lru_cache(maxsize=100)
def get_project_path(experiment_id: str) -> str | None:
"""Get the project path for a given experiment ID.
Args:
experiment_id: The experiment ID to look up.
Returns:
The project ... | 26 | 668 |
mlflow | mlflow/assistant/skill_installer.py | .py | """
Manage skill installation
Skills are maintained in the mlflow/assistant/skills subtree in the MLflow repository,
which points to the https://github.com/mlflow/skills repository.
"""
import shutil
from dataclasses import dataclass
from importlib import resources
from pathlib import Path
from mlflow.ai_commands.ai... | 107 | 3,239 |
mlflow | mlflow/assistant/cli.py | .py | """MLflow CLI commands for Assistant integration."""
import sys
import threading
import time
from pathlib import Path
import click
from mlflow.assistant.config import AssistantConfig, ProjectConfig, SkillsConfig
from mlflow.assistant.providers import AssistantProvider, list_providers
from mlflow.assistant.providers.... | 518 | 17,346 |
mlflow | mlflow/assistant/config.py | .py | from pathlib import Path
from typing import Literal
from pydantic import BaseModel, Field
MLFLOW_ASSISTANT_HOME = Path.home() / ".mlflow" / "assistant"
CONFIG_PATH = MLFLOW_ASSISTANT_HOME / "config.json"
class PermissionsConfig(BaseModel):
"""Permission settings for the assistant provider."""
allow_edit_fi... | 165 | 5,344 |
mlflow | mlflow/assistant/custom_view.py | .py | """Custom View delivery for structured-output providers (Claude Code and Codex).
This module converts a structured response envelope into a terminal ``client_tool_call``.
Native-tool providers use ``tool_executor`` instead.
"""
import json
import uuid
from typing import Any, Literal
from pydantic import BaseModel, C... | 159 | 6,001 |
mlflow | mlflow/assistant/providers/claude_code.py | .py | """
Claude Code provider for MLflow Assistant.
This module provides the Claude Code integration for the assistant API,
enabling AI-powered trace analysis through the Claude Code CLI.
"""
import asyncio
import json
import logging
import os
import shutil
import subprocess
import tempfile
from pathlib import Path
from t... | 852 | 38,926 |
mlflow | mlflow/assistant/providers/__init__.py | .py | import logging
from mlflow.assistant.providers.base import AssistantProvider
from mlflow.assistant.providers.claude_code import ClaudeCodeProvider
from mlflow.assistant.providers.codex import CodexProvider
from mlflow.assistant.providers.mlflow_gateway import MlflowGatewayProvider
from mlflow.assistant.providers.ollam... | 62 | 1,851 |
mlflow | mlflow/assistant/providers/mlflow_gateway.py | .py | """MLflow AI Gateway preset of the OpenAI-compatible assistant provider."""
import logging
from typing import ClassVar
from mlflow.assistant.providers.openai_compatible import OpenAICompatibleProvider
_logger = logging.getLogger(__name__)
class MlflowGatewayProvider(OpenAICompatibleProvider):
"""OpenAI-compati... | 63 | 2,330 |
mlflow | mlflow/assistant/providers/codex.py | .py | import asyncio
import json
import logging
import os
import shutil
import subprocess
import tempfile
from pathlib import Path
from typing import Any, AsyncGenerator, Callable, Literal
from mlflow.assistant.custom_view import (
STRINGIFIED_CUSTOM_VIEW_RESPONSE_SCHEMA,
STRINGIFIED_CUSTOM_VIEW_STRUCTURED_OUTPUT_IN... | 382 | 14,206 |
mlflow | mlflow/assistant/providers/openai_compatible.py | .py | """Generic OpenAI-compatible chat-completions provider for MLflow Assistant.
Drives any server that exposes `POST /v1/chat/completions` in OpenAI SSE form:
MLflow AI Gateway, Ollama (via its `/v1` shim), vLLM, LM Studio, etc.
:class:`OpenAICompatibleProvider` owns the shared streaming/tool-loop
machinery. Concrete pr... | 779 | 36,964 |
mlflow | mlflow/assistant/providers/ollama.py | .py | """Ollama preset of the OpenAI-compatible assistant provider."""
from typing import ClassVar
import requests
from mlflow.assistant.providers.openai_compatible import OpenAICompatibleProvider
class OllamaProvider(OpenAICompatibleProvider):
"""OpenAI-compatible provider for a locally running Ollama server."""
... | 39 | 1,563 |
mlflow | mlflow/assistant/providers/prompts.py | .py | """Shared system prompt for MLflow assistant providers."""
ASSISTANT_SYSTEM_PROMPT = """\
You are an MLflow assistant helping users with their MLflow projects. Users interact with
you through the MLflow UI. You can answer questions about MLflow, read and analyze data
from MLflow, integrate MLflow with a codebase, run ... | 344 | 14,632 |
mlflow | mlflow/assistant/providers/tool_executor.py | .py | import asyncio
import logging
import os
import shlex
from pathlib import Path
from typing import Any
from mlflow.assistant.config import PermissionsConfig
from mlflow.assistant.custom_view import RENDER_CUSTOM_VIEW_TOOL_NAME
_logger = logging.getLogger(__name__)
_FILE_TOOLS = {"Read", "Write", "Edit"}
# Restricted m... | 308 | 11,421 |
mlflow | mlflow/assistant/providers/base.py | .py | from abc import ABC, abstractmethod
from functools import lru_cache
from pathlib import Path
from typing import Any, AsyncGenerator, Callable, Literal
from mlflow.assistant.config import AssistantConfig, ProviderConfig
from mlflow.assistant.types import Event
ClientToolDelivery = Literal["tool", "structured", "unsupp... | 132 | 4,259 |
mlflow | mlflow/dspy/callback.py | .py | import logging
import threading
from collections import defaultdict
from functools import wraps
from typing import Any
import dspy
from dspy.utils.callback import BaseCallback
import mlflow
from mlflow.dspy.constant import FLAVOR_NAME
from mlflow.dspy.util import (
log_dspy_lm_state,
log_dspy_module_params,
... | 456 | 17,789 |
mlflow | mlflow/dspy/util.py | .py | import json
import logging
import tempfile
from collections import defaultdict
from pathlib import Path
from typing import Any
import dspy
from dspy import Example
import mlflow
from mlflow.entities import LoggedModelOutput
_logger = logging.getLogger(__name__)
EXCLUDE_LM_PARAMS = {"api_key", "api_base", "azure_ad_... | 159 | 5,166 |
mlflow | mlflow/dspy/load.py | .py | import inspect
import json
import logging
import os
import cloudpickle
from mlflow.dspy.save import (
_DSPY_SETTINGS_FILE_NAME,
_MODEL_CONFIG_FILE_NAME,
_MODEL_DATA_PATH,
)
from mlflow.dspy.wrapper import DspyChatModelWrapper, DspyModelWrapper
from mlflow.environment_variables import MLFLOW_ALLOW_PICKLE_D... | 162 | 6,374 |
mlflow | mlflow/dspy/__init__.py | .py | from mlflow.dspy.autolog import autolog
from mlflow.version import IS_TRACING_SDK_ONLY
__all__ = ["autolog"]
# Import model logging APIs only if mlflow skinny or full package is installed,
# i.e., skip if only mlflow-tracing package is installed.
if not IS_TRACING_SDK_ONLY:
from mlflow.dspy.load import _load_pyfu... | 18 | 503 |
mlflow | mlflow/dspy/autolog.py | .py | import logging
from packaging.version import Version
import mlflow
from mlflow.dspy.constant import FLAVOR_NAME
from mlflow.telemetry.events import AutologgingEvent
from mlflow.telemetry.track import _record_event
from mlflow.tracing.provider import trace_disabled
from mlflow.tracing.utils import construct_full_input... | 280 | 11,171 |
mlflow | mlflow/dspy/save.py | .py | """Functions for saving DSPY models to MLflow."""
import json
import logging
import os
from pathlib import Path
from typing import Any
import cloudpickle
import yaml
from packaging.version import Version
import mlflow
from mlflow import pyfunc
from mlflow.dspy.constant import FLAVOR_NAME
from mlflow.dspy.wrapper imp... | 438 | 16,923 |
mlflow | mlflow/dspy/wrapper.py | .py | import json
from dataclasses import asdict, is_dataclass
from typing import TYPE_CHECKING, Any
from packaging.version import Version
if TYPE_CHECKING:
import dspy
from mlflow.exceptions import INVALID_PARAMETER_VALUE, MlflowException
from mlflow.protos.databricks_pb2 import (
INVALID_PARAMETER_VALUE,
)
from ... | 237 | 9,004 |
mlflow | mlflow/cli/datasets.py | .py | import json
from typing import Any, Literal
import click
from mlflow import MlflowClient
from mlflow.environment_variables import MLFLOW_EXPERIMENT_ID
from mlflow.utils.string_utils import _create_table
from mlflow.utils.time import conv_longdate_to_str
EXPERIMENT_ID = click.option(
"--experiment-id",
"-x",
... | 139 | 3,906 |
mlflow | mlflow/cli/__init__.py | .py | import contextlib
import json
import logging
import os
import re
import sys
import warnings
from datetime import timedelta
from pathlib import Path
import click
from click import UsageError
from click.core import ParameterSource
from dotenv import load_dotenv
import mlflow.db
import mlflow.deployments.cli
import mlfl... | 1,452 | 54,143 |
mlflow | mlflow/cli/scorers.py | .py | import json
from typing import Literal
import click
from mlflow.environment_variables import MLFLOW_EXPERIMENT_ID
from mlflow.genai.judges import make_judge
from mlflow.genai.scorers import get_all_scorers
from mlflow.genai.scorers import list_scorers as list_scorers_api
from mlflow.mcp.decorator import mlflow_mcp
fr... | 251 | 8,041 |
mlflow | mlflow/cli/skills.py | .py | """CLI commands for inspecting MLflow Assistant skills."""
import click
from mlflow.assistant.skill_installer import BundledSkill, list_bundled_skills
def _echo_skill_details(skill: BundledSkill):
skill_name_styled = click.style(skill.name, fg="cyan", bold=True)
skill_path_styled = click.style(f" ({skill.pa... | 47 | 1,475 |
mlflow | mlflow/cli/demo.py | .py | import contextlib
import logging
import os
import threading
import time
import webbrowser
from collections.abc import Generator
from pathlib import Path
from urllib.parse import urljoin
import click
NOISY_LOGGERS = [
"alembic",
"mlflow.store",
"mlflow.tracking",
"mlflow.tracing",
"mlflow.genai",
... | 303 | 9,723 |
mlflow | mlflow/cli/eval.py | .py | """
CLI commands for evaluating traces with scorers.
"""
import json
from typing import Literal
import click
import pandas as pd
import mlflow
from mlflow.cli.genai_eval_utils import (
extract_assessments_from_results,
format_table_output,
resolve_scorers,
)
from mlflow.entities import Trace
from mlflow.... | 129 | 4,217 |
mlflow | mlflow/cli/genai_eval_utils.py | .py | """
Utility functions for trace evaluation output formatting.
"""
from dataclasses import dataclass
from typing import Any
import click
import pandas as pd
from mlflow.exceptions import MlflowException
from mlflow.genai.scorers import Scorer, get_all_scorers, get_scorer
from mlflow.tracing.constant import Assessment... | 278 | 9,160 |
mlflow | mlflow/cli/traces.py | .py | """
Comprehensive MLflow Traces CLI for managing trace data, assessments, and metadata.
This module provides a complete command-line interface for working with MLflow traces,
including search, retrieval, deletion, tagging, and assessment management. It supports
both table and JSON output formats with flexible field se... | 882 | 30,350 |
mlflow | mlflow/cli/crypto.py | .py | import os
import click
from mlflow.exceptions import MlflowException
from mlflow.tracking import _get_store
from mlflow.utils.crypto import (
CRYPTO_KEK_PASSPHRASE_ENV_VAR,
CRYPTO_KEK_VERSION_ENV_VAR,
KEKManager,
rotate_secret_encryption,
)
@click.group("crypto", help="Commands for managing MLflow's... | 212 | 8,346 |
mlflow | mlflow/pydantic_ai/utils.py | .py | import logging
from dataclasses import asdict, is_dataclass
from typing import Any
from mlflow.tracing.constant import TokenUsageKey
_logger = logging.getLogger(__name__)
_SAFE_PRIMITIVE_TYPES = (str, int, float, bool)
def is_safe_for_serialization(value: Any) -> bool:
if value is None:
return False
... | 115 | 4,364 |
mlflow | mlflow/pydantic_ai/__init__.py | .py | import functools
import inspect
import logging
import typing
from packaging.version import Version
from mlflow.pydantic_ai.autolog import (
patched_agent_init,
patched_async_class_call,
patched_async_stream_call,
patched_capability_model_request,
patched_class_call,
patched_sync_stream_call,
)... | 259 | 9,814 |
mlflow | mlflow/pydantic_ai/autolog.py | .py | import contextvars
import inspect
import logging
from contextlib import asynccontextmanager
from dataclasses import is_dataclass
from typing import Any
import mlflow
from mlflow.entities import SpanType
from mlflow.entities.span import LiveSpan
from mlflow.pydantic_ai.utils import parse_usage as _parse_usage
from mlfl... | 498 | 19,723 |
mlflow | mlflow/pydantic_ai/autolog_v2.py | .py | import functools
import inspect
import logging
import sys
from contextlib import asynccontextmanager
from typing import Any
import mlflow
from mlflow.entities import SpanType
from mlflow.entities.span import LiveSpan
from mlflow.pydantic_ai.utils import (
extract_safe_attributes,
model_request_inputs,
pars... | 477 | 16,270 |
mlflow | mlflow/keras/callback.py | .py | """Keras 3 callback to log information to MLflow."""
import keras
from mlflow import log_metrics, log_params, log_text
from mlflow.utils.autologging_utils import ExceptionSafeClass
class MlflowCallback(keras.callbacks.Callback, metaclass=ExceptionSafeClass):
"""Callback for logging Keras metrics/params/model/..... | 103 | 3,968 |
mlflow | mlflow/keras/utils.py | .py | import numpy as np
from mlflow.models import ModelSignature
from mlflow.types import Schema, TensorSpec
def get_model_signature(model):
def replace_none_in_shape(shape):
return [-1 if dim_size is None else dim_size for dim_size in shape]
input_shape = model.input_shape
input_dtype = model.input_... | 34 | 1,127 |
mlflow | mlflow/keras/load.py | .py | """Functions for loading Keras models saved with MLflow."""
import os
import keras
import numpy as np
import pandas as pd
from mlflow.exceptions import INVALID_PARAMETER_VALUE, MlflowException
from mlflow.models import Model
from mlflow.models.model import MLMODEL_FILE_NAME
from mlflow.tracking.artifact_utils import... | 157 | 5,710 |
mlflow | mlflow/keras/__init__.py | .py | # MLflow Keras 3 flavor.
import keras
from packaging.version import Version
if Version(keras.__version__).major < 3:
from mlflow.tensorflow import (
# Redirect `mlflow.keras._load_pyfunc` to `mlflow.tensorflow._load_pyfunc`,
# For backwards compatibility on loading keras model saved by old mlflow v... | 49 | 1,232 |
mlflow | mlflow/keras/autologging.py | .py | """MLflow autologging support for Keras 3."""
import logging
import keras
import numpy as np
import mlflow
from mlflow.data.code_dataset_source import CodeDatasetSource
from mlflow.data.numpy_dataset import from_numpy
from mlflow.data.tensorflow_dataset import from_tensorflow
from mlflow.entities.logged_model_input ... | 279 | 11,143 |
mlflow | mlflow/keras/save.py | .py | """Functions for saving Keras models to MLflow."""
import importlib
import logging
import os
import shutil
import tempfile
from typing import Any
import keras
import yaml
import mlflow
from mlflow import pyfunc
from mlflow.exceptions import INVALID_PARAMETER_VALUE, MlflowException
from mlflow.models import (
Mod... | 366 | 13,032 |
mlflow | mlflow/h2o/__init__.py | .py | """
The ``mlflow.h2o`` module provides an API for logging and loading H2O models. This module exports
H2O models with the following flavors:
H20 (native) format
This is the main flavor that can be loaded back into H2O.
:py:mod:`mlflow.pyfunc`
Produced for use by generic pyfunc-based deployment tools and batch ... | 378 | 12,679 |
mlflow | mlflow/data/spark_delta_utils.py | .py | import logging
import os
from mlflow.utils.string_utils import _backtick_quote
_logger = logging.getLogger(__name__)
def _is_delta_table(table_name: str) -> bool:
"""Checks if a Delta table exists with the specified table name.
Returns:
True if a Delta table exists with the specified table name. Fa... | 118 | 3,987 |
mlflow | mlflow/data/artifact_dataset_sources.py | .py | import re
import warnings
from pathlib import Path
from typing import Any, TypeVar
from urllib.parse import urlparse
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
from mlflow.store.artifact.artifact_repository_registry import get_registered_artifact_repo... | 172 | 6,833 |
mlflow | mlflow/data/code_dataset_source.py | .py | from typing import Any
from typing_extensions import Self
from mlflow.data.dataset_source import DatasetSource
class CodeDatasetSource(DatasetSource):
def __init__(
self,
tags: dict[Any, Any],
):
self._tags = tags
@staticmethod
def _get_source_type() -> str:
return "... | 41 | 880 |
mlflow | mlflow/data/huggingface_dataset.py | .py | import json
import logging
from functools import cached_property
from typing import TYPE_CHECKING, Any, Mapping, Sequence
from mlflow.data.dataset import Dataset
from mlflow.data.dataset_source import DatasetSource
from mlflow.data.digest_utils import compute_pandas_digest
from mlflow.data.evaluation_dataset import Ev... | 259 | 10,499 |
mlflow | mlflow/data/dataset_registry.py | .py | import inspect
import warnings
from contextlib import suppress
from typing import Callable
import mlflow.data
from mlflow.data.dataset import Dataset
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
from mlflow.utils.plugins import get_entry_points
class ... | 169 | 6,451 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.