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/genai/judges/prompts/summarization.py
.py
# NB: User-facing name for the summarization assessment. SUMMARIZATION_ASSESSMENT_NAME = "summarization" SUMMARIZATION_PROMPT = """\ Consider the following source document and candidate summary. You must decide whether the summary is an acceptable summary of the document. Output only "yes" or "no" based on whether the...
27
1,969
mlflow
mlflow/genai/judges/prompts/equivalence.py
.py
from mlflow.genai.prompts.utils import format_prompt # NB: User-facing name for the equivalence assessment. EQUIVALENCE_FEEDBACK_NAME = "equivalence" EQUIVALENCE_PROMPT_INSTRUCTIONS = """\ Compare the following actual output against the expected output. You must determine whether they \ are semantically equivalent o...
46
1,512
mlflow
mlflow/genai/judges/prompts/retrieval_relevance.py
.py
from mlflow.genai.prompts.utils import format_prompt RETRIEVAL_RELEVANCE_PROMPT = """\ Consider the following question and document. You must determine whether the document provides information that is (fully or partially) relevant to the question. Do not focus on the correctness or completeness of the document. Do no...
23
1,107
mlflow
mlflow/genai/judges/prompts/conversation_completeness.py
.py
# NB: User-facing name for the conversation completeness assessment. CONVERSATION_COMPLETENESS_ASSESSMENT_NAME = "conversation_completeness" CONVERSATION_COMPLETENESS_PROMPT = """\ Consider the following conversation history between a user and an assistant. Your task is to output exactly one label: "yes" or "no" based...
20
1,527
mlflow
mlflow/genai/judges/prompts/correctness.py
.py
from mlflow.genai.prompts.utils import format_prompt # NB: User-facing name for the is_correct assessment. CORRECTNESS_FEEDBACK_NAME = "correctness" CORRECTNESS_PROMPT_INSTRUCTIONS = """\ Consider the following question, claim and document. You must determine whether the claim is \ supported by the document in the c...
70
2,729
mlflow
mlflow/genai/judges/prompts/tool_call_efficiency.py
.py
from typing import TYPE_CHECKING from mlflow.genai.judges.utils.formatting_utils import ( format_available_tools, format_tools_called, ) from mlflow.genai.prompts.utils import format_prompt if TYPE_CHECKING: from mlflow.genai.utils.type import FunctionCall from mlflow.types.chat import ChatTool # NB:...
84
2,804
mlflow
mlflow/genai/judges/instructions_judge/__init__.py
.py
import json import logging from dataclasses import asdict from typing import Any, Literal from urllib.parse import urlparse, urlunparse import pydantic from pydantic import PrivateAttr import mlflow from mlflow.entities.assessment import Feedback from mlflow.entities.model_registry.prompt_version import PromptVersion...
910
39,049
mlflow
mlflow/genai/judges/instructions_judge/constants.py
.py
""" Constants for the InstructionsJudge module. This module contains constant values used by the InstructionsJudge class, including the augmented prompt template for trace-based evaluation. """ # Common base prompt for all judge evaluations JUDGE_BASE_PROMPT = """You are an expert judge tasked with evaluating the per...
68
3,384
mlflow
mlflow/genai/judges/utils/parsing_utils.py
.py
"""Response parsing utilities for judge models.""" import re def _strip_markdown_code_blocks(response: str) -> str: """ Strip markdown code blocks from LLM responses. Some legacy models wrap responses in markdown code blocks (```json...``` or unlabeled fences). This function removes those wrappers t...
45
1,428
mlflow
mlflow/genai/judges/utils/prompt_utils.py
.py
"""Prompt formatting and manipulation utilities for judge models.""" from __future__ import annotations import re from typing import TYPE_CHECKING, Any, Literal, NamedTuple, get_origin from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import BAD_REQUEST if TYPE_CHECKING: from mlflo...
115
4,073
mlflow
mlflow/genai/judges/utils/tool_calling_utils.py
.py
"""Tool calling support for judge models.""" from __future__ import annotations import json import logging from dataclasses import asdict, is_dataclass from typing import TYPE_CHECKING, Any, NoReturn if TYPE_CHECKING: from mlflow.entities.trace import Trace from mlflow.types.llm import ChatMessage, ToolCall ...
249
9,302
mlflow
mlflow/genai/judges/utils/invocation_utils.py
.py
"""Main invocation utilities for judge models.""" from __future__ import annotations import json import logging from typing import TYPE_CHECKING, Any import pydantic if TYPE_CHECKING: from mlflow.entities.trace import Trace from mlflow.types.llm import ChatMessage from mlflow.entities.assessment import Fee...
273
10,994
mlflow
mlflow/genai/judges/utils/__init__.py
.py
"""Main utilities module for judges. Maintains backwards compatibility.""" from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from mlflow.genai.judges.base import AlignmentOptimizer import mlflow from mlflow.environment_variables import MLFLOW_GENAI_JUDGE_DEFAULT_MODEL from ml...
134
3,918
mlflow
mlflow/genai/judges/utils/formatting_utils.py
.py
import logging from typing import TYPE_CHECKING if TYPE_CHECKING: from mlflow.genai.utils.type import FunctionCall from mlflow.types.chat import ChatTool _logger = logging.getLogger(__name__) def format_available_tools(available_tools: list["ChatTool"]) -> str: """Format available tools with description...
97
3,548
mlflow
mlflow/genai/judges/utils/telemetry_utils.py
.py
from __future__ import annotations import logging _logger = logging.getLogger(__name__) def _record_judge_model_usage_success_databricks_telemetry( *, request_id: str | None, model_provider: str, endpoint_name: str, num_prompt_tokens: int | None, num_completion_tokens: int | None, ) -> None:...
70
2,158
mlflow
mlflow/genai/judges/adapters/utils.py
.py
"""Shared utilities for judge adapters.""" from __future__ import annotations import time from typing import TYPE_CHECKING, Any import requests if TYPE_CHECKING: from mlflow.genai.judges.adapters.base_adapter import BaseJudgeAdapter from mlflow.types.llm import ChatMessage from mlflow.environment_variables...
180
5,908
mlflow
mlflow/genai/judges/adapters/databricks_managed_judge_adapter.py
.py
from __future__ import annotations import inspect import json import logging from typing import TYPE_CHECKING, Any, Callable, TypeVar if TYPE_CHECKING: from mlflow.entities.trace import Trace from mlflow.types.llm import ChatMessage, ToolDefinition T = TypeVar("T") # Generic type for agentic loop return val...
393
13,539
mlflow
mlflow/genai/judges/adapters/litellm_adapter.py
.py
from __future__ import annotations import contextlib import json import logging import re import threading from contextlib import ContextDecorator from contextvars import ContextVar from dataclasses import dataclass from typing import TYPE_CHECKING, Any, Iterator import pydantic if TYPE_CHECKING: import litellm ...
657
25,723
mlflow
mlflow/genai/judges/adapters/base_adapter.py
.py
from __future__ import annotations import logging from abc import ABC, abstractmethod from dataclasses import dataclass from typing import TYPE_CHECKING, Any import pydantic if TYPE_CHECKING: from mlflow.entities.trace import Trace from mlflow.types.llm import ChatMessage from mlflow.entities.assessment imp...
178
6,300
mlflow
mlflow/genai/judges/adapters/gateway_adapter.py
.py
"""Gateway-based judge adapter with tool-calling loop support. Uses the MLflow Gateway provider infrastructure for request/response transformation and provider configuration, with retry logic, context window management, and proactive pruning. """ from __future__ import annotations import json import logging from dat...
672
26,629
mlflow
mlflow/genai/scorers/aggregation.py
.py
"""Generate the metrics logged into MLflow.""" import collections import logging import numpy as np from mlflow.entities.assessment import Feedback from mlflow.genai.evaluation.entities import EvalResult from mlflow.genai.judges.builtin import CategoricalRating from mlflow.genai.scorers.base import AggregationFunc, ...
116
4,049
mlflow
mlflow/genai/scorers/__init__.py
.py
from typing import TYPE_CHECKING from mlflow.genai.scorers.base import Scorer, ScorerSamplingConfig, make_scorer_ensemble, scorer from mlflow.genai.scorers.ensemble import agg_all, agg_any, majority_vote, maximum, mean, minimum from mlflow.genai.scorers.registry import delete_scorer, get_scorer, list_scorers # Metada...
154
4,717
mlflow
mlflow/genai/scorers/registry.py
.py
""" Registered scorer functionality for MLflow GenAI. This module provides functions to manage registered scorers that automatically evaluate traces in MLflow experiments. """ import json import warnings from abc import ABCMeta, abstractmethod from base64 import urlsafe_b64encode from collections.abc import Callable ...
1,127
43,824
mlflow
mlflow/genai/scorers/llm_backend.py
.py
"""Shared LLM client for scorer packages and simulator. Provides a single routing layer so that DeepEval, RAGAS, Phoenix, TruLens scorers and the conversation simulator all resolve model URIs and make chat completion calls through the same code path. Note: This is NOT intended for judge adapters, which need lower-lev...
293
10,785
mlflow
mlflow/genai/scorers/builtin_scorers.py
.py
import copy import inspect import json import logging import math import re from abc import abstractmethod from dataclasses import asdict, dataclass from typing import TYPE_CHECKING, Any, Literal import pydantic if TYPE_CHECKING: from mlflow.genai.utils.type import FunctionCall from mlflow.types.llm import Ch...
3,673
130,749
mlflow
mlflow/genai/scorers/ensemble.py
.py
"""Built-in ensemble functions for ``make_scorer_ensemble``. Each function receives the list of per-sub-scorer values and returns a single ``Feedback``. The parameter is named ``values`` on purpose: ``make_scorer_ensemble`` introspects the parameter name to decide whether to pass raw values or full ``Feedback`` object...
168
6,925
mlflow
mlflow/genai/scorers/job.py
.py
"""Huey job functions for async scorer invocation.""" import logging import os import random from collections import defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed from contextlib import nullcontext from dataclasses import asdict, dataclass, field from typing import Any from mlflow.entiti...
517
18,719
mlflow
mlflow/genai/scorers/scorer_utils.py
.py
# This file contains utility functions for scorer functionality. import ast import inspect import json import logging import re from textwrap import dedent from typing import TYPE_CHECKING, Any, Callable from mlflow.exceptions import INVALID_PARAMETER_VALUE, MlflowException if TYPE_CHECKING: from mlflow.genai.ut...
333
11,981
mlflow
mlflow/genai/scorers/base.py
.py
import functools import importlib import inspect import json import logging from contextvars import ContextVar from dataclasses import asdict, dataclass, fields from enum import Enum from typing import Any, Callable, ClassVar, Literal, TypeAlias, TypeVar, overload from pydantic import BaseModel, PrivateAttr import ml...
1,747
74,547
mlflow
mlflow/genai/scorers/validation.py
.py
import importlib import logging from collections import defaultdict from typing import Any, Callable from mlflow.exceptions import MlflowException from mlflow.genai.scorers.base import AggregationFunc, Scorer from mlflow.genai.scorers.builtin_scorers import ( BuiltInScorer, MissingColumnsException, get_all...
204
7,694
mlflow
mlflow/genai/scorers/phoenix/utils.py
.py
from __future__ import annotations from typing import Any from mlflow.entities.trace import Trace from mlflow.exceptions import MlflowException from mlflow.genai.utils.trace_utils import ( extract_retrieval_context_from_trace, parse_inputs_to_str, parse_outputs_to_str, resolve_expectations_from_trace,...
92
2,823
mlflow
mlflow/genai/scorers/phoenix/models.py
.py
from __future__ import annotations from mlflow.genai.scorers.llm_backend import ScorerLLMClient from mlflow.genai.scorers.phoenix.utils import _NoOpRateLimiter, check_phoenix_installed class MlflowPhoenixModel: """Phoenix model adapter backed by the shared scorer LLM client. Routes through native providers ...
48
1,459
mlflow
mlflow/genai/scorers/phoenix/__init__.py
.py
""" Phoenix (Arize) integration for MLflow. This module provides integration with Phoenix evaluators, allowing them to be used with MLflow's scorer interface. Example usage: .. code-block:: python from mlflow.genai.scorers.phoenix import get_scorer scorer = get_scorer("Hallucination", model="openai:/gpt-4"...
280
8,245
mlflow
mlflow/genai/scorers/phoenix/registry.py
.py
from __future__ import annotations from mlflow.exceptions import MlflowException from mlflow.genai.scorers.phoenix.utils import check_phoenix_installed _METRIC_REGISTRY = { "Hallucination": "HallucinationEvaluator", "Relevance": "RelevanceEvaluator", "Toxicity": "ToxicityEvaluator", "QA": "QAEvaluator...
51
1,740
mlflow
mlflow/genai/scorers/online/trace_checkpointer.py
.py
"""Checkpoint management for trace-level online scoring.""" import json import logging import time from dataclasses import asdict, dataclass from mlflow.entities.experiment_tag import ExperimentTag from mlflow.environment_variables import ( MLFLOW_ONLINE_SCORING_DEFAULT_TRACE_COMPLETION_BUFFER_SECONDS, ) from mlf...
111
4,550
mlflow
mlflow/genai/scorers/online/trace_processor.py
.py
"""Online scoring processor for executing scorers on traces.""" import logging import time from concurrent.futures import ThreadPoolExecutor, as_completed from dataclasses import dataclass from mlflow.entities import Trace from mlflow.environment_variables import MLFLOW_ONLINE_SCORING_MAX_WORKER_THREADS from mlflow.g...
297
11,956
mlflow
mlflow/genai/scorers/online/trace_loader.py
.py
"""Trace loading utilities for online scoring.""" import logging from mlflow.entities import Trace, TraceData, TraceInfo from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository from mlflow.store.tracking.abstract_store import AbstractStore from mlflow.tracing.constant import SpansLocati...
159
6,071
mlflow
mlflow/genai/scorers/online/__init__.py
.py
"""Online scoring subpackage for scheduled scorer execution.""" from mlflow.genai.scorers.online.entities import ( CompletedSession, OnlineScorer, OnlineScoringConfig, ) from mlflow.genai.scorers.online.sampler import OnlineScorerSampler from mlflow.genai.scorers.online.session_checkpointer import OnlineSe...
26
958
mlflow
mlflow/genai/scorers/online/constants.py
.py
"""Constants for online scoring.""" from mlflow.tracing.constant import TraceMetadataKey # Maximum lookback period to prevent getting stuck on old failing traces (1 hour) MAX_LOOKBACK_MS = 60 * 60 * 1000 # Maximum traces to include in a single scoring job MAX_TRACES_PER_JOB = 500 # Maximum sessions to include in a ...
16
522
mlflow
mlflow/genai/scorers/online/session_processor.py
.py
"""Session-level online scoring processor for executing scorers on completed sessions.""" import logging from concurrent.futures import ThreadPoolExecutor, as_completed from dataclasses import dataclass, field from mlflow.entities.assessment import Assessment from mlflow.environment_variables import MLFLOW_ONLINE_SCO...
343
14,714
mlflow
mlflow/genai/scorers/online/entities.py
.py
""" Online scorer entities and configuration. This module contains entities for online scorer configuration used by the store layer and online scoring infrastructure. """ from dataclasses import dataclass @dataclass class OnlineScoringConfig: """ Internal entity representing the online configuration for a s...
65
1,864
mlflow
mlflow/genai/scorers/online/session_checkpointer.py
.py
"""Checkpoint management for session-level online scoring.""" import json import logging import time from dataclasses import asdict, dataclass from mlflow.entities.experiment_tag import ExperimentTag from mlflow.environment_variables import ( MLFLOW_ONLINE_SCORING_DEFAULT_SESSION_COMPLETION_BUFFER_SECONDS, ) from...
106
4,079
mlflow
mlflow/genai/scorers/online/sampler.py
.py
"""Dense sampling strategy for online scoring.""" import hashlib import logging from collections import defaultdict from typing import TYPE_CHECKING from mlflow.genai.scorers.base import Scorer if TYPE_CHECKING: from mlflow.genai.scorers.online.entities import OnlineScorer _logger = logging.getLogger(__name__) ...
107
3,896
mlflow
mlflow/genai/scorers/guardrails/utils.py
.py
from __future__ import annotations from typing import Any from mlflow.entities.trace import Trace from mlflow.exceptions import MlflowException from mlflow.genai.utils.trace_utils import ( parse_inputs_to_str, parse_outputs_to_str, resolve_inputs_from_trace, resolve_outputs_from_trace, ) def check_g...
58
1,741
mlflow
mlflow/genai/scorers/guardrails/__init__.py
.py
""" Guardrails AI integration for MLflow. This module provides integration with Guardrails AI validators, allowing them to be used with MLflow's scorer interface for LLM safety, PII detection, and content quality evaluation. Example usage: .. code-block:: python from mlflow.genai.scorers.guardrails import Toxic...
335
9,938
mlflow
mlflow/genai/scorers/guardrails/registry.py
.py
from __future__ import annotations from mlflow.exceptions import MlflowException _SUPPORTED_VALIDATORS = [ "ToxicLanguage", "NSFWText", "DetectJailbreak", "DetectPII", "SecretsPresent", "GibberishText", ] def get_validator_class(validator_name: str): """ Get Guardrails AI validator c...
44
1,343
mlflow
mlflow/genai/scorers/trulens/utils.py
.py
from __future__ import annotations import logging from typing import Any from mlflow.entities.trace import Trace from mlflow.genai.scorers.trulens.registry import build_trulens_args from mlflow.genai.utils.trace_utils import ( extract_retrieval_context_from_trace, parse_inputs_to_str, parse_outputs_to_str...
106
3,380
mlflow
mlflow/genai/scorers/trulens/models.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Any import pydantic from mlflow.exceptions import MlflowException from mlflow.genai.scorers.llm_backend import ScorerLLMClient from mlflow.genai.utils.message_utils import serialize_chat_messages_to_prompts if TYPE_CHECKING: from typing import...
123
4,241
mlflow
mlflow/genai/scorers/trulens/__init__.py
.py
""" TruLens evaluation framework integration for MLflow. This module provides integration with TruLens feedback functions, allowing them to be used with MLflow's scorer interface. Example usage: .. code-block:: python from mlflow.genai.scorers.trulens import get_scorer scorer = get_scorer("Groundedness", m...
301
8,531
mlflow
mlflow/genai/scorers/trulens/registry.py
.py
from __future__ import annotations import re from typing import Any # Mapping: metric name -> (feedback method name, argument mapping) # Argument mapping: generic key -> TruLens-specific argument name _METRIC_REGISTRY: dict[str, tuple[str, dict[str, str]]] = { # RAG metrics "Groundedness": ( "grounded...
65
2,224
mlflow
mlflow/genai/scorers/trulens/scorers/agent_trace.py
.py
""" Agent trace scorers for goal-plan-action alignment evaluation. These scorers analyze agent execution traces to detect internal errors and evaluate the quality of agent reasoning, planning, and tool usage. Based on TruLens' benchmarked goal-plan-action alignment evaluations which achieve 95% error coverage against...
277
7,729
mlflow
mlflow/genai/scorers/trulens/scorers/__init__.py
.py
from mlflow.genai.scorers.trulens.scorers.agent_trace import ( ExecutionEfficiency, LogicalConsistency, PlanAdherence, PlanQuality, ToolCalling, ToolSelection, TruLensAgentScorer, ) __all__ = [ "TruLensAgentScorer", "LogicalConsistency", "ExecutionEfficiency", "PlanAdherence...
20
384
mlflow
mlflow/genai/scorers/google_adk/utils.py
.py
"""Utility functions for Google ADK integration.""" from __future__ import annotations import asyncio import concurrent.futures import json from typing import Any from mlflow.entities.trace import Trace from mlflow.exceptions import MlflowException GOOGLE_ADK_NOT_INSTALLED_ERROR_MESSAGE = ( "Google ADK scorers ...
164
5,479
mlflow
mlflow/genai/scorers/google_adk/__init__.py
.py
""" Google ADK integration for MLflow. This module provides integration with Google Agent Development Kit (ADK) evaluators, allowing them to be used with MLflow's scorer interface for agent evaluation. Example usage: .. code-block:: python from mlflow.genai.scorers.google_adk import ToolTrajectory, ResponseMatc...
722
24,388
mlflow
mlflow/genai/scorers/google_adk/registry.py
.py
"""Registry of Google ADK scorers exposed through ``get_scorer``.""" from __future__ import annotations from mlflow.exceptions import MlflowException def get_scorer_class(metric_name: str): """Return the Google ADK scorer class registered under ``metric_name``.""" from mlflow.genai.scorers.google_adk import...
33
920
mlflow
mlflow/genai/scorers/ragas/utils.py
.py
from __future__ import annotations from typing import Any from mlflow.entities.trace import Trace from mlflow.exceptions import MlflowException from mlflow.genai.scorers.scorer_utils import parse_tool_call_expectations from mlflow.genai.utils.trace_utils import ( extract_retrieval_context_from_trace, extract_...
307
10,230
mlflow
mlflow/genai/scorers/ragas/models.py
.py
from __future__ import annotations import json import typing as t from openai import AsyncOpenAI from pydantic import BaseModel from ragas.embeddings import OpenAIEmbeddings from ragas.llms import InstructorBaseRagasLLM from mlflow.genai.judges.utils.parsing_utils import _strip_markdown_code_blocks from mlflow.genai...
82
2,594
mlflow
mlflow/genai/scorers/ragas/__init__.py
.py
""" RAGAS integration for MLflow. This module provides integration with RAGAS metrics, allowing them to be used with MLflow's judge interface. Example usage: .. code-block:: python from mlflow.genai.scorers.ragas import get_scorer judge = get_scorer("Faithfulness", model="openai:/gpt-4") feedback = jud...
394
12,777
mlflow
mlflow/genai/scorers/ragas/registry.py
.py
from __future__ import annotations from dataclasses import dataclass from mlflow.exceptions import MlflowException @dataclass(frozen=True) class MetricConfig: classpath: str is_agentic_or_multiturn: bool = False requires_embeddings: bool = False requires_llm_in_constructor: bool = True requires_...
160
6,163
mlflow
mlflow/genai/scorers/ragas/scorers/__init__.py
.py
from __future__ import annotations from typing import ClassVar from mlflow.genai.judges.builtin import _MODEL_API_DOC from mlflow.genai.scorers.ragas import RagasScorer from mlflow.genai.scorers.ragas.scorers.agentic_metrics import ( AgentGoalAccuracyWithoutReference, AgentGoalAccuracyWithReference, ToolC...
322
9,441
mlflow
mlflow/genai/scorers/ragas/scorers/agentic_metrics.py
.py
from __future__ import annotations from typing import ClassVar from mlflow.genai.judges.builtin import _MODEL_API_DOC from mlflow.genai.scorers.ragas import RagasScorer from mlflow.utils.docstring_utils import format_docstring @format_docstring(_MODEL_API_DOC) class TopicAdherence(RagasScorer): """ Evaluate...
196
6,168
mlflow
mlflow/genai/scorers/ragas/scorers/rag_metrics.py
.py
from __future__ import annotations from typing import ClassVar from ragas.embeddings.base import Embeddings from mlflow.genai.judges.builtin import _MODEL_API_DOC from mlflow.genai.scorers.ragas import RagasScorer from mlflow.utils.annotations import experimental from mlflow.utils.docstring_utils import format_docst...
250
6,776
mlflow
mlflow/genai/scorers/ragas/scorers/comparison_metrics.py
.py
from __future__ import annotations from typing import ClassVar from mlflow.genai.judges.builtin import _MODEL_API_DOC from mlflow.genai.scorers.ragas import RagasScorer from mlflow.utils.docstring_utils import format_docstring @format_docstring(_MODEL_API_DOC) class FactualCorrectness(RagasScorer): """ Eval...
170
4,406
mlflow
mlflow/genai/scorers/deepeval/utils.py
.py
"""Utility functions and constants for DeepEval integration.""" from __future__ import annotations from typing import Any from mlflow.entities.span import SpanAttributeKey, SpanType from mlflow.entities.trace import Trace from mlflow.exceptions import MlflowException from mlflow.genai.utils.trace_utils import ( ...
227
7,541
mlflow
mlflow/genai/scorers/deepeval/models.py
.py
from __future__ import annotations import json from typing import Any from deepeval.models.base_model import DeepEvalBaseLLM from pydantic import ValidationError from mlflow.genai.scorers.llm_backend import ScorerLLMClient def _build_json_prompt_with_schema(prompt: str, schema) -> str: return ( f"{prom...
91
3,181
mlflow
mlflow/genai/scorers/deepeval/__init__.py
.py
""" DeepEval integration for MLflow. This module provides integration with DeepEval metrics, allowing them to be used with MLflow's scorer interface. Example usage: .. code-block:: python from mlflow.genai.scorers.deepeval import get_scorer scorer = get_scorer("AnswerRelevancy", threshold=0.7, model="opena...
322
9,783
mlflow
mlflow/genai/scorers/deepeval/registry.py
.py
from __future__ import annotations from mlflow.exceptions import MlflowException from mlflow.genai.scorers.deepeval.utils import DEEPEVAL_NOT_INSTALLED_ERROR_MESSAGE # Registry format: metric_name -> (classpath, is_deterministic) _METRIC_REGISTRY = { # RAG Metrics "AnswerRelevancy": ("deepeval.metrics.AnswerR...
91
4,263
mlflow
mlflow/genai/scorers/deepeval/scorers/safety_metrics.py
.py
"""Safety and responsible AI metrics for content evaluation.""" from __future__ import annotations from typing import ClassVar from mlflow.genai.judges.builtin import _MODEL_API_DOC from mlflow.genai.scorers.deepeval import DeepEvalScorer from mlflow.utils.docstring_utils import format_docstring @format_docstring(...
185
5,776
mlflow
mlflow/genai/scorers/deepeval/scorers/__init__.py
.py
"""DeepEval metric scorers organized by category.""" from __future__ import annotations from typing import ClassVar from mlflow.genai.judges.builtin import _MODEL_API_DOC from mlflow.genai.scorers.deepeval import DeepEvalScorer from mlflow.genai.scorers.deepeval.scorers.agentic_metrics import ( ArgumentCorrectne...
236
5,896
mlflow
mlflow/genai/scorers/deepeval/scorers/agentic_metrics.py
.py
"""Agentic metrics for evaluating AI agent performance.""" from __future__ import annotations from typing import ClassVar from mlflow.genai.judges.builtin import _MODEL_API_DOC from mlflow.genai.scorers.deepeval import DeepEvalScorer from mlflow.utils.docstring_utils import format_docstring @format_docstring(_MODE...
174
5,560
mlflow
mlflow/genai/scorers/deepeval/scorers/rag_metrics.py
.py
"""RAG (Retrieval-Augmented Generation) metrics for DeepEval integration.""" from __future__ import annotations from typing import ClassVar from mlflow.genai.judges.builtin import _MODEL_API_DOC from mlflow.genai.scorers.deepeval import DeepEvalScorer from mlflow.utils.docstring_utils import format_docstring @form...
147
5,124
mlflow
mlflow/genai/scorers/deepeval/scorers/conversational_metrics.py
.py
"""Conversational metrics for evaluating multi-turn dialogue performance.""" from __future__ import annotations from typing import ClassVar from mlflow.genai.judges.builtin import _MODEL_API_DOC from mlflow.genai.scorers.deepeval import DeepEvalScorer from mlflow.utils.docstring_utils import format_docstring @form...
218
6,896
mlflow
mlflow/genai/git_versioning/__init__.py
.py
import logging from typing_extensions import Self import mlflow from mlflow.genai.git_versioning.git_info import GitInfo, GitOperationError from mlflow.telemetry.events import GitModelVersioningEvent from mlflow.telemetry.track import record_usage_event from mlflow.tracking.fluent import _set_active_model from mlflow...
162
5,382
mlflow
mlflow/genai/git_versioning/git_info.py
.py
import logging from dataclasses import dataclass from typing_extensions import Self from mlflow.utils.mlflow_tags import ( MLFLOW_GIT_BRANCH, MLFLOW_GIT_COMMIT, MLFLOW_GIT_DIFF, MLFLOW_GIT_DIRTY, MLFLOW_GIT_REPO_URL, ) _logger = logging.getLogger(__name__) class GitOperationError(Exception): ...
101
3,276
mlflow
mlflow/genai/prompts/utils.py
.py
import re from typing import Any def format_prompt(prompt: str, **values: Any) -> str: """Format double-curly variables in the prompt template.""" for key, value in values.items(): # Escape backslashes in the replacement string to prevent re.sub from interpreting # them as escape sequences (e....
13
508
mlflow
mlflow/genai/prompts/__init__.py
.py
import json import warnings from contextlib import contextmanager from typing import Any from pydantic import BaseModel import mlflow.tracking._model_registry.fluent as registry_api from mlflow.entities.model_registry.prompt import Prompt from mlflow.entities.model_registry.prompt_version import ( PromptModelConf...
415
14,905
mlflow
mlflow/genai/datasets/databricks_evaluation_dataset_source.py
.py
from typing import Any from mlflow.data.dataset_source import DatasetSource class DatabricksEvaluationDatasetSource(DatasetSource): """ Represents a Databricks Evaluation Dataset source. This source is used for datasets managed by the Databricks agents SDK. """ def __init__( self, ...
103
3,057
mlflow
mlflow/genai/datasets/evaluation_dataset.py
.py
from datetime import datetime from typing import TYPE_CHECKING, Any from mlflow.data import Dataset from mlflow.data.pyfunc_dataset_mixin import PyFuncConvertibleDatasetMixin from mlflow.entities.evaluation_dataset import ( EvaluationDataset as _EntityEvaluationDataset, ) from mlflow.genai.datasets.databricks_eval...
360
13,412
mlflow
mlflow/genai/datasets/__init__.py
.py
""" Databricks Agent Datasets Python SDK. For more details see Databricks Agent Evaluation: <https://docs.databricks.com/en/generative-ai/agent-evaluation/index.html> The API docs can be found here: <https://api-docs.databricks.com/python/databricks-agents/latest/databricks_agent_eval.html#datasets> """ import loggi...
798
28,145
mlflow
mlflow/genai/datasets/entities.py
.py
from dataclasses import dataclass from datetime import datetime, timedelta def _format_datetime_for_repr(value: datetime) -> str: formatted = value.isoformat(sep=" ", timespec="seconds") if value.utcoffset() == timedelta(0): return formatted.removesuffix("+00:00") + " UTC" return formatted @data...
33
941
mlflow
mlflow/genai/evaluation/rate_limiter.py
.py
"""Thread-safe rate limiters for evaluation harness.""" from __future__ import annotations import abc import contextlib import logging import threading import time from typing import Callable _logger = logging.getLogger(__name__) @contextlib.contextmanager def eval_retry_context(): """Disable downstream 429 re...
194
6,570
mlflow
mlflow/genai/evaluation/telemetry.py
.py
import hashlib import threading import uuid import mlflow from mlflow.genai.scorers.base import Scorer from mlflow.genai.scorers.builtin_scorers import BuiltInScorer from mlflow.utils.databricks_utils import get_databricks_host_creds from mlflow.utils.rest_utils import _REST_API_PATH_PREFIX, http_request from mlflow.u...
142
4,375
mlflow
mlflow/genai/evaluation/utils.py
.py
import json import logging import math from typing import TYPE_CHECKING, Any, Collection from mlflow.entities import Assessment, Trace, TraceData from mlflow.entities.assessment import DEFAULT_FEEDBACK_NAME, Feedback from mlflow.entities.assessment_source import AssessmentSource, AssessmentSourceType from mlflow.entit...
467
16,696
mlflow
mlflow/genai/evaluation/__init__.py
.py
from mlflow.genai.evaluation.base import evaluate, to_predict_fn __all__ = ["evaluate", "to_predict_fn"]
4
106
mlflow
mlflow/genai/evaluation/entities.py
.py
"""Entities for evaluation.""" import hashlib import json from dataclasses import dataclass, field from typing import Any, Callable import pandas as pd from mlflow.entities.assessment import Expectation, Feedback from mlflow.entities.assessment_source import AssessmentSource, AssessmentSourceType from mlflow.entitie...
338
12,121
mlflow
mlflow/genai/evaluation/session_utils.py
.py
"""Utilities for session-level (multi-turn) evaluation.""" from __future__ import annotations import traceback from collections import defaultdict from concurrent.futures import ThreadPoolExecutor from typing import TYPE_CHECKING, Any from mlflow.entities.assessment import Feedback from mlflow.entities.assessment_er...
211
7,657
mlflow
mlflow/genai/evaluation/context.py
.py
""" Introduces main Context class and the framework to specify different specialized contexts. """ import functools from abc import ABC, abstractmethod from typing import Callable, ParamSpec, TypeVar import mlflow from mlflow.tracking.context import registry as context_registry from mlflow.utils.mlflow_tags import ML...
146
4,020
mlflow
mlflow/genai/evaluation/job.py
.py
"""Huey job function for the UI-triggered `mlflow.genai.evaluate` flow. This module backs the `POST /ajax-api/3.0/mlflow/genai/evaluate/invoke` endpoint used by the "Run evaluation" modal's "Run judges" button. """ import logging import os import mlflow from mlflow.client import MlflowClient from mlflow.entities.run...
61
2,118
mlflow
mlflow/genai/evaluation/constant.py
.py
class AgentEvaluationReserverKey: """ Expectation column names that are used by Agent Evaluation. Ref: https://docs.databricks.com/aws/en/generative-ai/agent-evaluation/evaluation-schema """ EXPECTED_RESPONSE = "expected_response" EXPECTED_RETRIEVED_CONTEXT = "expected_retrieved_context" EX...
48
1,260
mlflow
mlflow/genai/evaluation/base.py
.py
import inspect import logging import os import time from contextlib import nullcontext from typing import TYPE_CHECKING, Any, Callable, NamedTuple import mlflow from mlflow.data.dataset import Dataset from mlflow.entities.dataset_input import DatasetInput from mlflow.entities.evaluation_dataset import EvaluationDatase...
715
28,358
mlflow
mlflow/genai/evaluation/harness.py
.py
"""Entry point to the evaluation harness""" from __future__ import annotations import logging import queue import threading import time import traceback import uuid from concurrent.futures import FIRST_COMPLETED, Future, ThreadPoolExecutor, as_completed, wait from typing import Any, Callable import pandas as pd try...
1,120
41,605
mlflow
mlflow/genai/agent_server/server.py
.py
import argparse import functools import inspect import json import logging import os import posixpath from typing import Any, AsyncGenerator, Callable, Literal, ParamSpec, TypeVar import httpx import uvicorn from fastapi import FastAPI, HTTPException, Request from fastapi.responses import Response, StreamingResponse ...
439
17,247
mlflow
mlflow/genai/agent_server/utils.py
.py
import logging import os import subprocess from contextvars import ContextVar from mlflow.tracking.fluent import _set_active_model # Context-isolated storage for request headers # ensuring thread-safe access across async execution contexts _request_headers: ContextVar[dict[str, str]] = ContextVar[dict[str, str]]( ...
48
1,656
mlflow
mlflow/genai/agent_server/__init__.py
.py
from mlflow.genai.agent_server.server import ( AgentServer, get_invoke_function, get_stream_function, invoke, stream, ) from mlflow.genai.agent_server.utils import ( get_request_headers, set_request_headers, setup_mlflow_git_based_version_tracking, ) __all__ = [ "set_request_headers...
24
500
mlflow
mlflow/genai/agent_server/validator.py
.py
from dataclasses import asdict, is_dataclass from typing import Any from pydantic import BaseModel from mlflow.types.responses import ( ResponsesAgentRequest, ResponsesAgentResponse, ResponsesAgentStreamEvent, ) class BaseAgentValidator: """Base validator class with common validation methods""" ...
67
2,527
mlflow
mlflow/genai/label_schemas/label_schemas.py
.py
import warnings from abc import ABC, abstractmethod from dataclasses import dataclass from typing import TYPE_CHECKING, TypeVar from mlflow.exceptions import MlflowException from mlflow.genai.utils.enum_utils import StrEnum from mlflow.protos import label_schemas_pb2 as _ls_pb from mlflow.protos.databricks_pb2 import ...
465
17,937
mlflow
mlflow/genai/label_schemas/__init__.py
.py
""" Label schemas define how reviewers annotate traces in the review UI. By default a schema is managed in the MLflow tracking store and scoped to an experiment (identity ``(experiment_id, name)``, with a server-generated ``schema_id``). On a Databricks tracking URI the same functions route to the workspace's ReviewAp...
318
11,349
mlflow
mlflow/genai/label_schemas/validation.py
.py
""" Server-side validation for label schemas. Type immutability post-create is enforced server-side (the field is documented as immutable but the entity does not enforce it on its own). The validation surface is intentionally split: - :py:func:`validate_schema_for_create` is called from the store layer's create pa...
320
12,453
mlflow
mlflow/genai/utils/type.py
.py
from __future__ import annotations from typing import Any from mlflow.types.chat import Function class FunctionCall(Function): arguments: str | dict[str, Any] | None = None outputs: Any | None = None exception: str | None = None
12
245
mlflow
mlflow/genai/utils/llm_utils.py
.py
from __future__ import annotations import functools import logging import threading import time from dataclasses import dataclass from typing import TYPE_CHECKING, Any import pydantic import requests import mlflow from mlflow.gateway.config import EndpointType from mlflow.genai.judges.adapters.litellm_adapter import...
278
9,894