Skip to main content

BuiltInMetrics

Provides convenient access to built-in Galileo metrics (formerly “scorers”). Examples

Metric

Base class for all Galileo metrics. This is an abstract base class that defines common attributes and methods for all metric types. Use one of the concrete metric classes instead:
  • GalileoMetric: Built-in Galileo scorers (access via Metric.scorers)
  • LlmMetric: Custom LLM-based metrics with prompt templates
  • LocalMetric: Local function-based metrics
  • CodeMetric: Code-based metrics (future support)

Common Attributes

id (str | None): The unique metric identifier (UUID). name (str): The metric name. scorer_type (ScorerTypes | None): The type of scorer. description (str): Description of the metric. tags (list[str]): Tags associated with the metric. created_at (datetime | None): When the metric was created. updated_at (datetime | None): When the metric was last updated. version (int | None): Metric version number.

Class Attributes

metrics (BuiltInMetrics): Access built-in Galileo metrics. Examples

delete

Delete this metric. Only works for server-side metrics. Local metrics don’t need deletion. Examples

delete_by_name

Delete a metric by name without retrieving it first. This is more efficient than calling Metric.get(name=...).delete() when you only need to delete and don’t need the metric object. Arguments
  • name: The name of the metric to delete.

get

Get an existing metric by ID or name. Returns the appropriate subclass instance based on scorer_type. Arguments
  • id: The metric ID (UUID).
  • name: The metric name.

list

List metrics with optional filtering. Returns appropriate subclass instances based on scorer_type. Arguments
  • name_filter: Filter metrics by exact name match.
  • scorer_types: Filter by scorer types.

refresh

Refresh this metric’s state from the API. Updates all attributes with the latest values from the remote API. Examples

to_legacy_metric

Convert to legacy galileo.schema.metrics.Metric format. This enables backward compatibility with existing code that uses the legacy Metric class. Examples

update

Update this metric’s properties on the API. Only name, description, and tags can be updated via this method. On success the instance is updated with the API response and returned in SYNCED state. Arguments
  • **kwargs (Any): Fields to update. Supported keys: name, description, tags.
Examples

LlmMetric

LLM-based metric with custom prompt templates. This metric type allows you to create custom metrics evaluated by an LLM judge using a prompt template. Arguments
  • Configuration:
  • -------------: Default values for model and judges can be configured via:
    • Configuration.default_scorer_model (env: GALILEO_DEFAULT_SCORER_MODEL)
    • Configuration.default_scorer_judges (env: GALILEO_DEFAULT_SCORER_JUDGES)
Examples

create

Persist this LLM metric to the API. Examples

CodeMetric

Code-based metric. This metric type is for code-based scorers that execute custom code to evaluate traces/spans. Examples

create

Persist this Code metric to the API. This method validates the code first by submitting it to the validation endpoint, polling for the result, and then creating the scorer with the validated result. Examples

load_code

Load code from a file into this metric instance. Arguments
  • code_file_path: Path to the Python file containing the scorer code.

GalileoMetric

Built-in Galileo scorer metric. This metric type represents Galileo’s built-in scorers like correctness, completeness, toxicity, etc. Access these via Metric.metrics. Examples

LocalMetric

Local function-based metric. This metric type uses a Python function to score traces/spans locally without making API calls. Useful for simple, deterministic metrics. Examples

to_local_metric_config

Convert to LocalMetricConfig format. Examples