Skip to main content

Function: createMetricConfigs()

function createMetricConfigs(
  projectId: string,
  runId: string,
  metrics: (string | Metric | LocalMetricConfig)[],
): Promise<[object[], LocalMetricConfig[]]>;
Defined in: src/utils/metrics.ts:122 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

Returns

Promise<[object[], 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

import { GalileoScorers } from "../types/metrics.types";

const [scorerConfigs, localMetrics] = await createMetricConfigs(
  "project-123",
  "log-stream-456",
  [
    GalileoScorers.Correctness,
    GalileoScorers.Completeness,
    "toxicity",
    { name: "custom_metric", version: 2 },
    {
      name: "local_scorer",
      scorerFn: (span) => 0.85,
      scorableTypes: ["llm"],
    },
  ],
);
I