Skip to main content

Function: createMetricConfigs()

function createMetricConfigs(
  projectId: string,
  runId: string,
  metrics: (string | Metric | LocalMetricConfig)[],
): Promise<[ScorerConfig[], LocalMetricConfig[]]>;
Defined in: src/utils/metrics.ts Process metrics and create scorer configurations for log streams or experiments. This function categorizes metrics into server-side and client-side types, validates they exist, and registers server-side metrics with Galileo.

Parameters

projectId

string The ID of the project

runId

string The ID of the run (can be experiment ID or log stream ID)

metrics

( | string | Metric | LocalMetricConfig)[] List of metrics to configure. Can include: - GalileoMetrics const object values (e.g., GalileoMetrics.correctness) - Metric objects with name and optional version - LocalMetricConfig objects for client-side scoring - String names of metrics

Returns

Promise<[ScorerConfig[], LocalMetricConfig[]]> A promise that resolves to a tuple containing: - Array of ScorerConfig objects for server-side metrics - Array of LocalMetricConfig objects for client-side metrics

Throws

Error if any specified metrics are unknown or don’t exist in Galileo

Example

const [scorerConfigs, localMetrics] = await createMetricConfigs(
  "project-123",
  "log-stream-456",
  [
    GalileoMetrics.correctness,
    GalileoMetrics.completeness,
    "toxicity",
    { name: "custom_metric", version: 2 },
  ],
);