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/tools/get_traces_in_session.py
.py
""" Get traces in session tool for MLflow GenAI judges. This module provides a tool for retrieving traces from the same session to enable multi-turn evaluation capabilities. """ from mlflow.entities.trace import Trace from mlflow.exceptions import MlflowException from mlflow.genai.judges.tools.base import JudgeTool f...
111
4,378
mlflow
mlflow/genai/judges/tools/utils.py
.py
""" Utilities for MLflow GenAI judge tools. This module contains utility functions and classes used across different judge tool implementations. """ from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE def create_page_token(offset: int) -> str: """ C...
48
1,147
mlflow
mlflow/genai/judges/tools/get_span.py
.py
""" Get span tool for MLflow GenAI judges. This module provides a tool for retrieving a specific span by ID. """ import json from mlflow.entities.trace import Trace from mlflow.genai.judges.tools.base import JudgeTool from mlflow.genai.judges.tools.constants import ToolNames from mlflow.genai.judges.tools.types impo...
133
5,306
mlflow
mlflow/genai/judges/tools/get_root_span.py
.py
""" Get root span tool for MLflow GenAI judges. This module provides a tool for retrieving the root span of a trace, which contains the top-level inputs and outputs. """ from mlflow.entities.trace import Trace from mlflow.genai.judges.tools.base import JudgeTool from mlflow.genai.judges.tools.constants import ToolNam...
109
4,316
mlflow
mlflow/genai/judges/tools/search_traces.py
.py
""" Search traces tool for MLflow GenAI judges. This module provides a tool for searching and retrieving traces from an MLflow experiment based on filter criteria, ordering, and result limits. It enables judges to analyze traces within the same experiment context. """ import logging import mlflow from mlflow.entitie...
269
11,277
mlflow
mlflow/genai/judges/tools/__init__.py
.py
from mlflow.genai.judges.tools.base import JudgeTool from mlflow.genai.judges.tools.get_root_span import GetRootSpanTool from mlflow.genai.judges.tools.get_span import GetSpanTool from mlflow.genai.judges.tools.get_span_image import GetSpanImageTool, SpanImageResult from mlflow.genai.judges.tools.get_span_performance_a...
47
1,524
mlflow
mlflow/genai/judges/tools/constants.py
.py
""" Constants for MLflow GenAI judge tools. This module contains constant values used across the judge tools system, providing a single reference point for tool names and other constants. """ # Tool names class ToolNames: """Registry of judge tool names.""" GET_TRACE_INFO = "get_trace_info" GET_ROOT_SPA...
22
658
mlflow
mlflow/genai/judges/tools/get_trace_info.py
.py
""" Get trace info tool for MLflow GenAI judges. This module provides a tool for retrieving trace metadata including timing, location, state, and other high-level information. """ from mlflow.entities.trace import Trace from mlflow.entities.trace_info import TraceInfo from mlflow.genai.judges.tools.base import JudgeT...
61
1,871
mlflow
mlflow/genai/judges/tools/registry.py
.py
""" Tool registry for MLflow GenAI judges. This module provides a registry system for managing and invoking JudgeTool instances. """ import json import logging from typing import Any import mlflow from mlflow.entities import SpanType, Trace from mlflow.environment_variables import MLFLOW_GENAI_EVAL_ENABLE_SCORER_TRA...
148
4,753
mlflow
mlflow/genai/judges/tools/list_spans.py
.py
""" Tool definitions for MLflow GenAI judges. This module provides concrete JudgeTool implementations that judges can use to analyze traces and extract information during evaluation. """ from dataclasses import dataclass from mlflow.entities.trace import Trace from mlflow.genai.judges.tools.base import JudgeTool fro...
127
4,350
mlflow
mlflow/genai/judges/tools/get_span_performance_and_timing_report.py
.py
""" Get span timing report tool for MLflow traces. This tool generates a timing report showing span latencies, execution order, and concurrency patterns for performance analysis. """ from collections import defaultdict from dataclasses import dataclass from mlflow.entities.span import Span from mlflow.entities.trace...
500
17,080
mlflow
mlflow/genai/judges/tools/search_trace_regex.py
.py
""" Tool for searching traces using regex patterns. This module provides functionality to search through entire traces (including spans, metadata, tags, requests, and responses) using regular expressions with case-insensitive matching. """ import re from dataclasses import dataclass from mlflow.entities.trace import...
165
5,826
mlflow
mlflow/genai/judges/tools/get_span_image.py
.py
""" Get span image tool for MLflow GenAI judges. This module provides a tool that resolves an ``mlflow-attachment://`` image reference inside a span, downloads the real bytes, and returns them as a base64 data URL so a multimodal judge model can actually view the image. When autolog extracts an image from a span it r...
198
8,690
mlflow
mlflow/genai/judges/tools/base.py
.py
""" Base classes for MLflow GenAI tools that can be used by judges. This module provides the foundational interfaces for tools that judges can use to enhance their evaluation capabilities. """ from abc import ABC, abstractmethod from typing import Any from mlflow.entities.trace import Trace from mlflow.types.llm imp...
54
1,418
mlflow
mlflow/genai/judges/prompts/knowledge_retention.py
.py
# NB: User-facing name for the knowledge retention assessment. KNOWLEDGE_RETENTION_ASSESSMENT_NAME = "knowledge_retention" KNOWLEDGE_RETENTION_PROMPT = """\ Your task is to evaluate the LAST AI response in the {{ conversation }} and determine if it: - Correctly uses or references information the user provided in earli...
29
1,594
mlflow
mlflow/genai/judges/prompts/conversational_safety.py
.py
# NB: User-facing name for the conversational safety assessment. CONVERSATIONAL_SAFETY_ASSESSMENT_NAME = "conversational_safety" CONVERSATIONAL_SAFETY_PROMPT = """\ Consider the following conversation history between a user and an assistant. Your task is to \ evaluate the safety of the assistant's responses only and o...
27
1,403
mlflow
mlflow/genai/judges/prompts/guidelines.py
.py
from mlflow.genai.prompts.utils import format_prompt GUIDELINES_FEEDBACK_NAME = "guidelines" GUIDELINES_PROMPT_INSTRUCTIONS = """\ Given the following set of guidelines and some inputs, please assess whether the inputs fully \ comply with all the provided guidelines. Only focus on the provided guidelines and not the...
51
1,814
mlflow
mlflow/genai/judges/prompts/conversational_tool_call_efficiency.py
.py
# NB: User-facing name for the conversational tool call efficiency assessment. CONVERSATIONAL_TOOL_CALL_EFFICIENCY_ASSESSMENT_NAME = "conversational_tool_call_efficiency" CONVERSATIONAL_TOOL_CALL_EFFICIENCY_PROMPT = """\ Consider the following conversation history between a user and an assistant, including tool calls ...
27
1,541
mlflow
mlflow/genai/judges/prompts/relevance_to_query.py
.py
from mlflow.genai.prompts.utils import format_prompt # NB: User-facing name for the is_context_relevant assessment. RELEVANCE_TO_QUERY_ASSESSMENT_NAME = "relevance_to_context" RELEVANCE_TO_QUERY_PROMPT_INSTRUCTIONS = """\ Consider the following question and answer. You must determine whether the answer provides \ in...
37
1,397
mlflow
mlflow/genai/judges/prompts/context_sufficiency.py
.py
from typing import Any from mlflow.genai.prompts.utils import format_prompt # NB: User-facing name for the is_context_sufficient assessment. CONTEXT_SUFFICIENCY_FEEDBACK_NAME = "context_sufficiency" CONTEXT_SUFFICIENCY_PROMPT_INSTRUCTIONS = """\ Consider the following claim and document. You must determine whether ...
72
2,451
mlflow
mlflow/genai/judges/prompts/tool_call_correctness.py
.py
import json 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 Cha...
208
8,547
mlflow
mlflow/genai/judges/prompts/safety.py
.py
from mlflow.genai.prompts.utils import format_prompt # NB: User-facing name for the safety assessment. SAFETY_ASSESSMENT_NAME = "safety" SAFETY_PROMPT = """\ You are a content safety classifier. Analyze the given text against policies prohibiting hate speech, harassment, incitement of violence, and the promotion of ...
22
928
mlflow
mlflow/genai/judges/prompts/conversational_guidelines.py
.py
CONVERSATIONAL_GUIDELINES_ASSESSMENT_NAME = "conversational_guidelines" CONVERSATIONAL_GUIDELINES_PROMPT = """\ Consider the following conversation history between a user and an assistant. Your task is to evaluate whether the assistant's responses throughout the conversation comply with the provided guidelines and out...
24
1,158
mlflow
mlflow/genai/judges/prompts/fluency.py
.py
# NB: User-facing name for the fluency assessment. FLUENCY_ASSESSMENT_NAME = "fluency" FLUENCY_PROMPT = """\ You are a linguistic expert evaluating the Fluency of AI-generated text in {{ outputs }}. Definition: Fluency measures the grammatical correctness, natural flow, and linguistic quality of the text, regardless ...
16
661
mlflow
mlflow/genai/judges/prompts/completeness.py
.py
# NB: User-facing name for the completeness assessment. COMPLETENESS_ASSESSMENT_NAME = "completeness" COMPLETENESS_PROMPT = """\ Consider the following user prompt and assistant response. You must decide whether the assistant successfully addressed all explicit requests in the user's prompt. Output only "yes" or "no" ...
21
1,295
mlflow
mlflow/genai/judges/prompts/conversational_role_adherence.py
.py
# NB: User-facing name for the conversational role adherence assessment. CONVERSATIONAL_ROLE_ADHERENCE_ASSESSMENT_NAME = "conversational_role_adherence" CONVERSATIONAL_ROLE_ADHERENCE_PROMPT = """\ Consider the following conversation history between a user and an assistant. \ Your task is to evaluate whether the assist...
31
2,069
mlflow
mlflow/genai/judges/prompts/groundedness.py
.py
from typing import Any from mlflow.genai.prompts.utils import format_prompt # NB: User-facing name for the is_grounded assessment. GROUNDEDNESS_FEEDBACK_NAME = "groundedness" GROUNDEDNESS_PROMPT_INSTRUCTIONS = """\ Consider the following claim and document. You must determine whether claim is supported by the \ doc...
50
1,630
mlflow
mlflow/genai/judges/prompts/user_frustration.py
.py
# NB: User-facing name for the user frustration assessment. USER_FRUSTRATION_ASSESSMENT_NAME = "user_frustration" USER_FRUSTRATION_PROMPT = """\ Consider the following conversation history between a user and an assistant. Your task is to determine the user's emotional trajectory and output exactly one of the following...
20
1,183
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