🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore(score-configs): rename ScoreDataType -> ScoreConfigDataType (#11266)
marliessophie223f4571c9da
diff --git a/packages/shared/prisma/generated/types.ts b/packages/shared/prisma/generated/types.tsindex 3f2259cfca..737039da7e 100644--- a/packages/shared/prisma/generated/types.ts+++ b/packages/shared/prisma/generated/types.ts@@ -47,12 +47,13 @@ export const LegacyPrismaScoreSource = {} as const;export type LegacyPrismaScoreSource =(typeof LegacyPrismaScoreSource)[keyof typeof LegacyPrismaScoreSource];-export const ScoreDataType = {+export const ScoreConfigDataType = {CATEGORICAL: "CATEGORICAL",NUMERIC: "NUMERIC",BOOLEAN: "BOOLEAN",} as const;-export type ScoreDataType = (typeof ScoreDataType)[keyof typeof ScoreDataType];+export type ScoreConfigDataType =+ (typeof ScoreConfigDataType)[keyof typeof ScoreConfigDataType];export const AnnotationQueueStatus = {PENDING: "PENDING",COMPLETED: "COMPLETED",@@ -596,7 +597,7 @@ export type LegacyPrismaScore = {queue_id: string | null;created_at: Generated<Timestamp>;updated_at: Generated<Timestamp>;- data_type: Generated<ScoreDataType>;+ data_type: Generated<ScoreConfigDataType>;};export type LegacyPrismaTrace = {id: string;@@ -834,7 +835,7 @@ export type ScoreConfig = {updated_at: Generated<Timestamp>;project_id: string;name: string;- data_type: ScoreDataType;+ data_type: ScoreConfigDataType;is_archived: Generated<boolean>;min_value: number | null;max_value: number | null;diff --git a/packages/shared/prisma/migrations/20251218102933_score_configs_rename_score_data_type_enum/migration.sql b/packages/shared/prisma/migrations/20251218102933_score_configs_rename_score_data_type_enum/migration.sqlnew file mode 100644index 0000000000..59ad87e6c4--- /dev/null+++ b/packages/shared/prisma/migrations/20251218102933_score_configs_rename_score_data_type_enum/migration.sql@@ -0,0 +1,8 @@+/*+ Warnings:++ - Changed the type of `data_type` on the `score_configs` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.++*/+-- Rename enum+ALTER TYPE "ScoreDataType" RENAME TO "ScoreConfigDataType";\ No newline at end of filediff --git a/packages/shared/prisma/schema.prisma b/packages/shared/prisma/schema.prismaindex 4535803664..8a613def92 100644--- a/packages/shared/prisma/schema.prisma+++ b/packages/shared/prisma/schema.prisma@@ -457,7 +457,7 @@ model LegacyPrismaScore {queueId String? @map("queue_id")createdAt DateTime @default(now()) @map("created_at")updatedAt DateTime @default(now()) @updatedAt @map("updated_at")- dataType ScoreDataType @default(NUMERIC) @map("data_type")+ dataType ScoreConfigDataType @default(NUMERIC) @map("data_type")scoreConfig ScoreConfig? @relation(fields: [configId], references: [id], onDelete: SetNull)@@unique([id, projectId]) // used for upserts via prisma@@ -488,7 +488,7 @@ model ScoreConfig {projectId String @map("project_id")project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)name String- dataType ScoreDataType @map("data_type")+ dataType ScoreConfigDataType @map("data_type")isArchived Boolean @default(false) @map("is_archived")minValue Float? @map("min_value")maxValue Float? @map("max_value")@@ -506,7 +506,7 @@ model ScoreConfig {@@map("score_configs")}-enum ScoreDataType {+enum ScoreConfigDataType {CATEGORICALNUMERICBOOLEANdiff --git a/packages/shared/scripts/seeder/seed-postgres.ts b/packages/shared/scripts/seeder/seed-postgres.tsindex 43d57ed1ab..60c4b6e488 100644--- a/packages/shared/scripts/seeder/seed-postgres.ts+++ b/packages/shared/scripts/seeder/seed-postgres.ts@@ -9,7 +9,8 @@ import {PrismaClient,type Project,ScoreConfigCategoryDomain,- ScoreDataType,+ ScoreDataTypeEnum,+ type ScoreDataTypeType,} from "../../src/index";import { getDisplaySecretKey, hashSecretKey, logger } from "../../src/server";import { redis } from "../../src/server/redis/redis";@@ -753,7 +754,7 @@ async function generateConfigsForProject(projects: Project[]) {{name: string;id: string;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;categories: ScoreConfigCategoryDomain[] | null;}[]> = new Map();@@ -803,7 +804,7 @@ async function generateConfigs(project: Project) {const configNameAndId: {name: string;id: string;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;categories: ScoreConfigCategoryDomain[] | null;}[] = [];@@ -811,7 +812,7 @@ async function generateConfigs(project: Project) {{id: `config-${v4()}`,name: "manual-score",- dataType: ScoreDataType.NUMERIC,+ dataType: ScoreDataTypeEnum.NUMERIC,projectId: project.id,isArchived: false,},@@ -819,7 +820,7 @@ async function generateConfigs(project: Project) {id: `config-${v4()}`,projectId: project.id,name: "Accuracy",- dataType: ScoreDataType.CATEGORICAL,+ dataType: ScoreDataTypeEnum.CATEGORICAL,categories: [{ label: "Incorrect", value: 0 },{ label: "Partially Correct", value: 1 },@@ -831,7 +832,7 @@ async function generateConfigs(project: Project) {id: `config-${v4()}`,projectId: project.id,name: "Toxicity",- dataType: ScoreDataType.BOOLEAN,+ dataType: ScoreDataTypeEnum.BOOLEAN,categories: [{ label: "True", value: 1 },{ label: "False", value: 0 },@@ -880,7 +881,7 @@ async function generateQueuesForProject({name: string;id: string;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;categories: ScoreConfigCategoryDomain[] | null;}[]>,@@ -904,7 +905,7 @@ async function generateQueues(configIdsAndNames: {name: string;id: string;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;categories: ScoreConfigCategoryDomain[] | null;}[],) {diff --git a/packages/shared/src/features/scores/interfaces/ui/types.ts b/packages/shared/src/features/scores/interfaces/ui/types.tsindex 4905076405..6737636108 100644--- a/packages/shared/src/features/scores/interfaces/ui/types.ts+++ b/packages/shared/src/features/scores/interfaces/ui/types.ts@@ -1,5 +1,8 @@-import { ScoreDataType } from "@prisma/client";-import { MetadataDomain, ScoreSourceType } from "../../../../domain";+import {+ MetadataDomain,+ ScoreDataTypeType,+ ScoreSourceType,+} from "../../../../domain";export type BaseAggregate = {comment?: string | null;@@ -27,7 +30,7 @@ export type ScoreAggregate = Record<string, AggregatedScoreData>;export type ScoreSimplified = {id: string;name: string;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;source: ScoreSourceType;value?: number | null;comment?: string | null;diff --git a/packages/shared/src/server/ingestion/validateAndInflateScore.ts b/packages/shared/src/server/ingestion/validateAndInflateScore.tsindex bdd4244da3..1d0e2111ec 100644--- a/packages/shared/src/server/ingestion/validateAndInflateScore.ts+++ b/packages/shared/src/server/ingestion/validateAndInflateScore.ts@@ -1,10 +1,12 @@import {ScoreBodyWithoutConfig,ScoreConfigDomain,- ScoreDomain,+ ScoreDataTypeEnum,+ type ScoreDataTypeType,+ type ScoreDomain,ScorePropsAgainstConfig,} from "../../../src";-import { prisma, ScoreDataType } from "../../db";+import { prisma } from "../../db";import { InvalidRequestError, LangfuseNotFoundError } from "../../errors";import { validateDbScoreConfigSafe } from "../../features/scoreConfigs/validation";import { ScoreEventType } from "./types";@@ -68,10 +70,10 @@ export async function validateAndInflateScore(return inflateScoreBody(params);}-function inferDataType(value: string | number): ScoreDataType {+function inferDataType(value: string | number): ScoreDataTypeType {return typeof value === "number"- ? ScoreDataType.NUMERIC- : ScoreDataType.CATEGORICAL;+ ? ScoreDataTypeEnum.NUMERIC+ : ScoreDataTypeEnum.CATEGORICAL;}function mapStringValueToNumericValue(@@ -97,12 +99,12 @@ function inflateScoreBody(};if (typeof body.value === "number") {- if (relevantDataType && relevantDataType === ScoreDataType.BOOLEAN) {+ if (relevantDataType && relevantDataType === ScoreDataTypeEnum.BOOLEAN) {return {...scoreProps,value: body.value,stringValue: body.value === 1 ? "True" : "False",- dataType: ScoreDataType.BOOLEAN,+ dataType: ScoreDataTypeEnum.BOOLEAN,};}@@ -110,7 +112,7 @@ function inflateScoreBody(...scoreProps,value: body.value,stringValue: null,- dataType: ScoreDataType.NUMERIC,+ dataType: ScoreDataTypeEnum.NUMERIC,};}@@ -118,7 +120,7 @@ function inflateScoreBody(...scoreProps,value: config ? mapStringValueToNumericValue(config, body.value) : 0,stringValue: body.value,- dataType: ScoreDataType.CATEGORICAL,+ dataType: ScoreDataTypeEnum.CATEGORICAL,};}@@ -142,10 +144,10 @@ function resolveScoreValueAnnotation(body: ScoreDomain,): string | number | null {switch (body.dataType) {- case ScoreDataType.NUMERIC:- case ScoreDataType.BOOLEAN:+ case ScoreDataTypeEnum.NUMERIC:+ case ScoreDataTypeEnum.BOOLEAN:return body.value;- case ScoreDataType.CATEGORICAL:+ case ScoreDataTypeEnum.CATEGORICAL:return body.stringValue;}}diff --git a/packages/shared/src/server/repositories/scores.ts b/packages/shared/src/server/repositories/scores.tsindex a86a440f8e..3c415709c6 100644--- a/packages/shared/src/server/repositories/scores.ts+++ b/packages/shared/src/server/repositories/scores.ts@@ -1,5 +1,8 @@-import { ScoreDataType } from "@prisma/client";-import { ScoreDomain, ScoreSourceType } from "../../domain/scores";+import {+ ScoreDataTypeType,+ ScoreDomain,+ ScoreSourceType,+} from "../../domain/scores";import {commandClickhouse,queryClickhouse,@@ -45,7 +48,7 @@ export const searchExistingAnnotationScore = async (sessionId: string | null,name: string | undefined,configId: string | undefined,- dataType: ScoreDataType,+ dataType: ScoreDataTypeType,) => {if (!name && !configId) {throw new Error("Either name or configId (or both) must be provided.");@@ -622,7 +625,7 @@ export const getScoresGroupedByNameSourceType = async ({return rows.map((row) => ({name: row.name,source: row.source as ScoreSourceType,- dataType: row.data_type as ScoreDataType,+ dataType: row.data_type as ScoreDataTypeType,}));};diff --git a/packages/shared/src/server/repositories/scores_converters.ts b/packages/shared/src/server/repositories/scores_converters.tsindex f4b1cff251..9b04a51758 100644--- a/packages/shared/src/server/repositories/scores_converters.ts+++ b/packages/shared/src/server/repositories/scores_converters.ts@@ -1,6 +1,9 @@-import { ScoreDataType } from "@prisma/client";import { ScoreRecordReadType } from "./definitions";-import { ScoreDomain, ScoreSourceType } from "../../domain/scores";+import type {+ ScoreDataTypeType,+ ScoreDomain,+ ScoreSourceType,+} from "../../domain/scores";import { parseMetadataCHRecordToDomain } from "../utils/metadata_conversion";import { parseClickhouseUTCDateTimeFormat } from "./clickhouse";@@ -34,7 +37,7 @@ export const convertClickhouseScoreToDomain = <ExcludeMetadata extends boolean>(comment: record.comment ?? null,authorUserId: record.author_user_id ?? null,configId: record.config_id ?? null,- dataType: record.data_type as ScoreDataType,+ dataType: record.data_type as ScoreDataTypeType,queueId: record.queue_id ?? null,executionTraceId: record.execution_trace_id ?? null,createdAt: record.created_at@@ -68,7 +71,7 @@ export const convertScoreAggregation = (row: ScoreAggregation) => {stringValue: row.string_value,value: Number(row.value),source: row.source as ScoreSourceType,- dataType: row.data_type as ScoreDataType,+ dataType: row.data_type as ScoreDataTypeType,comment: row.comment,timestamp: row.timestamp,};diff --git a/web/src/__tests__/score-configs.servertest.ts b/web/src/__tests__/score-configs.servertest.tsindex 6d040faed8..841d8b954a 100644--- a/web/src/__tests__/score-configs.servertest.ts+++ b/web/src/__tests__/score-configs.servertest.ts@@ -11,11 +11,8 @@ import {PostScoreConfigResponse,PutScoreConfigResponse,} from "@/src/features/public-api/types/score-configs";-import {- type ScoreConfig,- prisma,- type ScoreDataType,-} from "@langfuse/shared/src/db";+import { ScoreConfigDataType } from "@langfuse/shared";+import { type ScoreConfig, prisma } from "@langfuse/shared/src/db";import { createOrgProjectAndApiKey } from "@langfuse/shared/src/server";const configOne = [@@ -23,7 +20,7 @@ const configOne = [projectId: "<to be replaced>",name: "Test Boolean Config",description: "Test Description",- dataType: "BOOLEAN" as ScoreDataType,+ dataType: ScoreConfigDataType.BOOLEAN,categories: [{ label: "True", value: 1 },{ label: "False", value: 0 },@@ -37,7 +34,7 @@ const configTwo = [projectId: "<to be replaced>",name: "Test Numeric Config",description: "Test Description",- dataType: "NUMERIC" as ScoreDataType,+ dataType: ScoreConfigDataType.NUMERIC,minValue: 0,createdAt: new Date("2024-05-11T00:00:00.000Z"),updatedAt: new Date("2024-05-11T00:00:00.000Z"),@@ -49,7 +46,7 @@ const configThree = [projectId: "<to be replaced>",name: "Test Categorical Config",description: "Test Description",- dataType: "CATEGORICAL" as ScoreDataType,+ dataType: ScoreConfigDataType.CATEGORICAL,categories: [{ label: "A", value: 0 },{ label: "B", value: 1 },diff --git a/web/src/components/table/use-cases/score-configs.tsx b/web/src/components/table/use-cases/score-configs.tsxindex 648c1870f2..7e6ad8517e 100644--- a/web/src/components/table/use-cases/score-configs.tsx+++ b/web/src/components/table/use-cases/score-configs.tsx@@ -6,7 +6,7 @@ import { type LangfuseColumnDef } from "@/src/components/table/types";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";import { DataTable } from "@/src/components/table/data-table";import {- type ScoreDataType,+ type ScoreConfigDataType,type Prisma,type ScoreConfigCategoryDomain,} from "@langfuse/shared";@@ -34,7 +34,7 @@ import { UpsertScoreConfigDialog } from "@/src/features/score-configs/componentstype ScoreConfigTableRow = {id: string;name: string;- dataType: ScoreDataType;+ dataType: ScoreConfigDataType;createdAt: string;updatedAt: string;range: {diff --git a/web/src/components/table/use-cases/scores.tsx b/web/src/components/table/use-cases/scores.tsxindex 09ffc015e5..8f937a57c9 100644--- a/web/src/components/table/use-cases/scores.tsx+++ b/web/src/components/table/use-cases/scores.tsx@@ -27,7 +27,7 @@ import type { RouterOutput } from "@/src/utils/types";import {isPresent,type FilterState,- type ScoreDataType,+ type ScoreDataTypeType,BatchExportTableName,BatchActionType,TableViewPresetTableName,@@ -58,7 +58,7 @@ export type ScoresTableRow = {timestamp: Date;source: string;name: string;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;value: string;author: {userId?: string;diff --git a/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx b/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsxindex ae31435ea9..9fb74e560a 100644--- a/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx@@ -9,7 +9,6 @@ import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";import useColumnOrder from "@/src/features/column-visibility/hooks/useColumnOrder";import { CreateOrEditAnnotationQueueButton } from "@/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton";-import { type ScoreDataType } from "@langfuse/shared";import {DropdownMenu,DropdownMenuContent,@@ -24,6 +23,7 @@ import Link from "next/link";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { DeleteAnnotationQueueButton } from "@/src/features/annotation-queues/components/DeleteAnnotationQueueButton";import { getScoreDataTypeIcon } from "@/src/features/scores/lib/scoreColumns";+import { type ScoreConfigDataType } from "@langfuse/shared";type RowData = {key: {@@ -33,7 +33,7 @@ type RowData = {description?: string;countCompletedItems: number;countPendingItems: number;- scoreConfigs: { id: string; name: string; dataType: ScoreDataType }[];+ scoreConfigs: { id: string; name: string; dataType: ScoreConfigDataType }[];createdAt: string;isAssigned: boolean;};diff --git a/web/src/features/dashboard/components/ChartScores.tsx b/web/src/features/dashboard/components/ChartScores.tsxindex 6e071402ce..1427f7081c 100644--- a/web/src/features/dashboard/components/ChartScores.tsx+++ b/web/src/features/dashboard/components/ChartScores.tsx@@ -2,7 +2,7 @@ import { api } from "@/src/utils/api";import { BaseTimeSeriesChart } from "@/src/features/dashboard/components/BaseTimeSeriesChart";import { DashboardCard } from "@/src/features/dashboard/components/cards/DashboardCard";-import { type ScoreDataType, type FilterState } from "@langfuse/shared";+import { type ScoreDataTypeType, type FilterState } from "@langfuse/shared";import {extractTimeSeriesData,fillMissingValuesAndTransform,@@ -69,7 +69,7 @@ export function ChartScores(props: {{accessor: "data_type",formatFct: (value) =>- getScoreDataTypeIcon(value as ScoreDataType),+ getScoreDataTypeIcon(value as ScoreDataTypeType),},{ accessor: "name" },{diff --git a/web/src/features/dashboard/components/ScoresTable.tsx b/web/src/features/dashboard/components/ScoresTable.tsxindex c2f053b767..0bce3051a2 100644--- a/web/src/features/dashboard/components/ScoresTable.tsx+++ b/web/src/features/dashboard/components/ScoresTable.tsx@@ -1,7 +1,7 @@import { DashboardCard } from "@/src/features/dashboard/components/cards/DashboardCard";import { DashboardTable } from "@/src/features/dashboard/components/cards/DashboardTable";import {- type ScoreDataType,+ type ScoreDataTypeType,type ScoreSourceType,type FilterState,} from "@langfuse/shared";@@ -18,7 +18,7 @@ import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";const dropValuesForCategoricalScores = (value: number,- scoreDataType: ScoreDataType,+ scoreDataType: ScoreDataTypeType,): string => {return isCategoricalDataType(scoreDataType)? "-"@@ -29,7 +29,7 @@ const scoreNameSourceDataTypeMatch =(scoreName: string,scoreSource: ScoreSourceType,- scoreDataType: ScoreDataType,+ scoreDataType: ScoreDataTypeType,) =>(item: DatabaseRow) =>item.scoreName === scoreName &&@@ -148,7 +148,7 @@ export const ScoresTable = ({return metrics.data.map((metric) => {const scoreName = metric.scoreName as string;const scoreSource = metric.scoreSource as ScoreSourceType;- const scoreDataType = metric.scoreDataType as ScoreDataType;+ const scoreDataType = metric.scoreDataType as ScoreDataTypeType;const zeroValueScore = zeroValueScores.data.find(scoreNameSourceDataTypeMatch(scoreName, scoreSource, scoreDataType),diff --git a/web/src/features/dashboard/components/score-analytics/NumericScoreHistogram.tsx b/web/src/features/dashboard/components/score-analytics/NumericScoreHistogram.tsxindex f74cfceeb3..0642288d4d 100644--- a/web/src/features/dashboard/components/score-analytics/NumericScoreHistogram.tsx+++ b/web/src/features/dashboard/components/score-analytics/NumericScoreHistogram.tsx@@ -1,9 +1,8 @@import { api } from "@/src/utils/api";-import {type ScoreSourceType,type FilterState,- type ScoreDataType,+ type ScoreDataTypeType,} from "@langfuse/shared";import { createTracesTimeFilter } from "@/src/features/dashboard/lib/dashboard-utils";import React from "react";@@ -18,7 +17,7 @@ export function NumericScoreHistogram(props: {projectId: string;name: string;source: ScoreSourceType;- dataType: ScoreDataType;+ dataType: Extract<ScoreDataTypeType, "NUMERIC" | "BOOLEAN">;globalFilterState: FilterState;}) {const histogram = api.dashboard.scoreHistogram.useQuery(diff --git a/web/src/features/dashboard/components/score-analytics/NumericScoreTimeSeriesChart.tsx b/web/src/features/dashboard/components/score-analytics/NumericScoreTimeSeriesChart.tsxindex a98496222d..81240decbf 100644--- a/web/src/features/dashboard/components/score-analytics/NumericScoreTimeSeriesChart.tsx+++ b/web/src/features/dashboard/components/score-analytics/NumericScoreTimeSeriesChart.tsx@@ -5,7 +5,7 @@ import { Card } from "@/src/components/ui/card";import {type ScoreSourceType,type FilterState,- type ScoreDataType,+ type ScoreDataTypeType,} from "@langfuse/shared";import {extractTimeSeriesData,@@ -28,7 +28,7 @@ import { type DatabaseRow } from "@/src/server/api/services/sqlInterface";export function NumericScoreTimeSeriesChart(props: {projectId: string;source: ScoreSourceType;- dataType: ScoreDataType;+ dataType: Extract<ScoreDataTypeType, "NUMERIC" | "BOOLEAN">;name: string;agg: DashboardDateRangeAggregationOption;globalFilterState: FilterState;diff --git a/web/src/features/score-analytics/components/cards/HeatmapCard.tsx b/web/src/features/score-analytics/components/cards/HeatmapCard.tsxindex 2006ea71a9..5d5f0270b9 100644--- a/web/src/features/score-analytics/components/cards/HeatmapCard.tsx+++ b/web/src/features/score-analytics/components/cards/HeatmapCard.tsx@@ -13,12 +13,12 @@ import { HeatmapSkeleton } from "../charts/HeatmapSkeleton";import { getHeatmapCellColor } from "@/src/features/score-analytics/lib/color-scales";import { type HeatmapCell } from "@/src/features/score-analytics/lib/heatmap-utils";import { useCallback } from "react";-import type { ScoreDataType } from "@langfuse/shared";import { SamplingDetailsHoverCard } from "../SamplingDetailsHoverCard";+import { type ScoreDataTypeType } from "@langfuse/shared";interface HeatmapTooltipContentProps {cell: HeatmapCell;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;score1: { name: string; source: string };score2: { name: string; source: string } | undefined;score1Color: string;diff --git a/web/src/features/score-configs/components/UpsertScoreConfigDialog.tsx b/web/src/features/score-configs/components/UpsertScoreConfigDialog.tsxindex c03f3916bb..2fb52eaadf 100644--- a/web/src/features/score-configs/components/UpsertScoreConfigDialog.tsx+++ b/web/src/features/score-configs/components/UpsertScoreConfigDialog.tsx@@ -22,7 +22,6 @@ import {FormMessage,} from "@/src/components/ui/form";import { Input } from "@/src/components/ui/input";-import { ScoreDataType, ScoreDataTypeArray } from "@langfuse/shared";import {Select,SelectContent,@@ -46,6 +45,7 @@ import {type UpdateConfig,} from "@/src/features/score-configs/lib/upsertFormTypes";import { validateScoreConfigUpsertFormInput } from "@/src/features/score-configs/lib/validateScoreConfigUpsertFormInput";+import { ScoreConfigDataType } from "@langfuse/shared";export function UpsertScoreConfigDialog({projectId,@@ -84,7 +84,7 @@ export function UpsertScoreConfigDialog({const form = useForm({resolver: zodResolver(id ? updateConfigSchema : createConfigSchema),defaultValues: defaultValues ?? {- dataType: ScoreDataType.NUMERIC,+ dataType: ScoreConfigDataType.NUMERIC,minValue: undefined,maxValue: undefined,name: "",@@ -196,16 +196,16 @@ export function UpsertScoreConfigDialog({disabled={!!id}defaultValue={field.value}onValueChange={(value) => {- field.onChange(- value as (typeof ScoreDataTypeArray)[number],- );+ field.onChange(value as ScoreConfigDataType);form.clearErrors();- if (isNumericDataType(value as ScoreDataType)) {+ if (isNumericDataType(value as ScoreConfigDataType)) {form.setValue("categories", undefined);} else {form.setValue("minValue", undefined);form.setValue("maxValue", undefined);- if (isBooleanDataType(value as ScoreDataType)) {+ if (+ isBooleanDataType(value as ScoreConfigDataType)+ ) {replace([{ label: "True", value: 1 },{ label: "False", value: 0 },@@ -222,11 +222,13 @@ export function UpsertScoreConfigDialog({</SelectTrigger></FormControl><SelectContent>- {ScoreDataTypeArray.map((role) => (- <SelectItem value={role} key={role}>- {role}- </SelectItem>- ))}+ {Object.values(ScoreConfigDataType).map(+ (dataType) => (+ <SelectItem value={dataType} key={dataType}>+ {dataType}+ </SelectItem>+ ),+ )}</SelectContent></Select><FormMessage />diff --git a/web/src/features/score-configs/lib/upsertFormTypes.ts b/web/src/features/score-configs/lib/upsertFormTypes.tsindex 9ccddf85d9..4273b3fe28 100644--- a/web/src/features/score-configs/lib/upsertFormTypes.ts+++ b/web/src/features/score-configs/lib/upsertFormTypes.ts@@ -1,10 +1,10 @@-import { ScoreDataTypeDomain, ScoreConfigCategory } from "@langfuse/shared";+import { ScoreConfigCategory } from "@langfuse/shared";import { z } from "zod/v4";export const createConfigSchema = z.object({name: z.string().min(1).max(35),description: z.string().optional(),- dataType: ScoreDataTypeDomain,+ dataType: z.enum(["CATEGORICAL", "NUMERIC", "BOOLEAN"]),minValue: z.coerce.number().optional(),maxValue: z.coerce.number().optional(),categories: z.array(ScoreConfigCategory).optional(),diff --git a/web/src/features/scores/hooks/useScoreColumns.ts b/web/src/features/scores/hooks/useScoreColumns.tsindex 261d5b8df7..e03f933872 100644--- a/web/src/features/scores/hooks/useScoreColumns.ts+++ b/web/src/features/scores/hooks/useScoreColumns.ts@@ -1,7 +1,7 @@import { useMemo } from "react";import { api } from "@/src/utils/api";import {- type ScoreDataType,+ type ScoreDataTypeType,type FilterCondition,type ScoreAggregate,} from "@langfuse/shared";@@ -16,7 +16,7 @@ function createScoreColumns<T extends Record<string, any>>(key: string;name: string;source: string;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;}>,scoreColumnKey: keyof T & string,displayFormat: "smart" | "aggregate",diff --git a/web/src/features/scores/lib/aggregateScores.ts b/web/src/features/scores/lib/aggregateScores.tsindex 0cf10433a2..6efd95fedd 100644--- a/web/src/features/scores/lib/aggregateScores.ts+++ b/web/src/features/scores/lib/aggregateScores.ts@@ -3,8 +3,8 @@ import {type ScoreAggregate,type ScoreSimplified,type ScoreSourceType,- type ScoreDataType,type ScoreDomain,+ type ScoreDataTypeType,} from "@langfuse/shared";/**@@ -22,7 +22,7 @@ export const composeAggregateScoreKey = ({}: {name: string;source: ScoreSourceType;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;keyPrefix?: string;}): string => {const formattedName = normalizeScoreName(name);@@ -34,13 +34,13 @@ export const decomposeAggregateScoreKey = (): {name: string;source: ScoreSourceType;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;} => {const [name, source, dataType] = key.split("-");return {name,source: source as ScoreSourceType,- dataType: dataType as ScoreDataType,+ dataType: dataType as ScoreDataTypeType,};};@@ -59,7 +59,7 @@ type ScoreToAggregate = (ScoreDomain | ScoreSimplified) & {* aggregation logic (value counting vs numeric averaging).*/export const resolveAggregateType = (- dataType: ScoreDataType,+ dataType: ScoreDataTypeType,): "NUMERIC" | "CATEGORICAL" => {return dataType === "BOOLEAN" ? "CATEGORICAL" : dataType;};diff --git a/web/src/features/scores/lib/annotationFormHelpers.ts b/web/src/features/scores/lib/annotationFormHelpers.tsindex 10a66b392e..93713a34bc 100644--- a/web/src/features/scores/lib/annotationFormHelpers.ts+++ b/web/src/features/scores/lib/annotationFormHelpers.ts@@ -1,8 +1,8 @@import { getScoreDataTypeIcon } from "@/src/features/scores/lib/scoreColumns";import {isPresent,+ type ScoreConfigDataType,type ScoreConfigCategoryDomain,- type ScoreDataType,} from "@langfuse/shared";export const resolveConfigValue = ({@@ -10,7 +10,7 @@ export const resolveConfigValue = ({dataType,}: {name: string;- dataType: ScoreDataType;+ dataType: ScoreConfigDataType;}) => {return `${getScoreDataTypeIcon(dataType)} ${name}`;};diff --git a/web/src/features/scores/lib/helpers.ts b/web/src/features/scores/lib/helpers.tsindex ca76d59f77..fdb68fb0f8 100644--- a/web/src/features/scores/lib/helpers.ts+++ b/web/src/features/scores/lib/helpers.ts@@ -1,19 +1,20 @@import { type ScoreData } from "./types";import {- ScoreDataType,+ type ScoreDataTypeType,type ScoreTargetTrace,type ScoreTarget,type ScoreTargetSession,+ ScoreDataTypeEnum,} from "@langfuse/shared";-export const isNumericDataType = (dataType: ScoreDataType) =>- dataType === ScoreDataType.NUMERIC;+export const isNumericDataType = (dataType: ScoreDataTypeType) =>+ dataType === ScoreDataTypeEnum.NUMERIC;-export const isCategoricalDataType = (dataType: ScoreDataType) =>- dataType === ScoreDataType.CATEGORICAL;+export const isCategoricalDataType = (dataType: ScoreDataTypeType) =>+ dataType === ScoreDataTypeEnum.CATEGORICAL;-export const isBooleanDataType = (dataType: ScoreDataType) =>- dataType === ScoreDataType.BOOLEAN;+export const isBooleanDataType = (dataType: ScoreDataTypeType) =>+ dataType === ScoreDataTypeEnum.BOOLEAN;export const isScoreUnsaved = (scoreId?: string | null): boolean => !scoreId;diff --git a/web/src/features/scores/lib/scoreColumns.ts b/web/src/features/scores/lib/scoreColumns.tsindex b498cec1ef..5e4f33916b 100644--- a/web/src/features/scores/lib/scoreColumns.ts+++ b/web/src/features/scores/lib/scoreColumns.ts@@ -1,7 +1,7 @@import {type ScoreAggregate,type FilterCondition,- type ScoreDataType,+ type ScoreDataTypeType,type ScoreSourceType,} from "@langfuse/shared";@@ -118,7 +118,7 @@ export const addPrefixToScoreKeys = (return prefixed;};-export const getScoreDataTypeIcon = (dataType: ScoreDataType): string => {+export const getScoreDataTypeIcon = (dataType: ScoreDataTypeType): string => {switch (dataType) {case "NUMERIC":default:@@ -136,7 +136,7 @@ export const convertScoreColumnsToAnalyticsData = (| {key: string;name: string;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;source: ScoreSourceType;}[]| undefined,diff --git a/web/src/features/scores/lib/types.ts b/web/src/features/scores/lib/types.tsindex b81d570ba2..f7e0c1703f 100644--- a/web/src/features/scores/lib/types.ts+++ b/web/src/features/scores/lib/types.ts@@ -7,7 +7,7 @@ import {type DatasetRunItemByRunRowData,} from "@/src/features/datasets/lib/types";import { type PromptVersionTableRow } from "@/src/pages/project/[projectId]/prompts/metrics";-import { type ScoreDataType, type ScoreSourceType } from "@langfuse/shared";+import { type ScoreDataTypeType, type ScoreSourceType } from "@langfuse/shared";export type TableRowTypesWithIndividualScoreColumns =| ObservationsTableRow@@ -21,6 +21,6 @@ export type TableRowTypesWithIndividualScoreColumns =export type ScoreData = {key: string;name: string;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;source: ScoreSourceType;};diff --git a/web/src/features/scores/schema.ts b/web/src/features/scores/schema.tsindex 4733dfd6a4..ff785a23cd 100644--- a/web/src/features/scores/schema.ts+++ b/web/src/features/scores/schema.ts@@ -1,4 +1,4 @@-import { ScoreDataType } from "@langfuse/shared";+import { ScoreDataTypeArray } from "@langfuse/shared";import { z } from "zod/v4";export const AnnotationScoreDataSchema = z.object({@@ -9,7 +9,7 @@ export const AnnotationScoreDataSchema = z.object({name: z.string(),value: z.number().nullish(),stringValue: z.string().nullish(),- dataType: z.enum(ScoreDataType),+ dataType: z.enum(ScoreDataTypeArray),configId: z.string(),comment: z.string().nullish(),});diff --git a/web/src/features/scores/types.ts b/web/src/features/scores/types.tsindex 84946c7bdc..25423c9c74 100644--- a/web/src/features/scores/types.ts+++ b/web/src/features/scores/types.ts@@ -3,7 +3,7 @@ import { type AnnotateFormSchema } from "@/src/features/scores/schema";import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";import {type ScoreSourceType,- type ScoreDataType,+ type ScoreDataTypeType,type ScoreAggregate,type ScoreConfigDomain,type ScoreDomain,@@ -31,7 +31,7 @@ export type ChartData = {export type ScoreData = {key: string;name: string;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;source: string;};@@ -56,7 +56,7 @@ export type ScoreTarget = SessionScoreTarget | TraceScoreTarget;export type AnnotationScore = {id: string | null;name: string;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;source: ScoreSourceType;value?: number | null;stringValue?: string | null;@@ -99,7 +99,7 @@ export type ScoreColumn = {key: string;name: string;source: ScoreSourceType;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;};export type ScoreConfigSelection =@@ -123,7 +123,7 @@ export type AnnotationScoreFormData = {id: string | null;configId: string;name: string;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;value?: number | null;stringValue?: string | null;comment?: string | null;diff --git a/web/src/server/api/routers/scoreConfigs.ts b/web/src/server/api/routers/scoreConfigs.tsindex ccb68176bb..7c42ae6364 100644--- a/web/src/server/api/routers/scoreConfigs.ts+++ b/web/src/server/api/routers/scoreConfigs.ts@@ -11,7 +11,7 @@ import {LangfuseNotFoundError,optionalPaginationZod,ScoreConfigCategory,- ScoreDataType,+ ScoreConfigDataType,validateDbScoreConfig,validateDbScoreConfigSafe,} from "@langfuse/shared";@@ -29,7 +29,7 @@ const ScoreConfigAllInputPaginated = ScoreConfigAllInput.extend({const ScoreConfigCreateInput = z.object({projectId: z.string(),name: z.string().min(1).max(35),- dataType: z.enum(ScoreDataType),+ dataType: z.enum(ScoreConfigDataType),minValue: z.number().optional(),maxValue: z.number().optional(),categories: z.array(ScoreConfigCategory).optional(),diff --git a/worker/src/features/database-read-stream/getDatabaseReadStream.ts b/worker/src/features/database-read-stream/getDatabaseReadStream.tsindex 114a4d111d..ef06dcd662 100644--- a/worker/src/features/database-read-stream/getDatabaseReadStream.ts+++ b/worker/src/features/database-read-stream/getDatabaseReadStream.ts@@ -5,8 +5,8 @@ import {BatchExportQueryType,OrderByState,TracingSearchType,- ScoreDataType,isPresent,+ type ScoreDataTypeType,} from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";import {@@ -588,7 +588,7 @@ export function prepareScoresForOutput(scores: {name: string;stringValue?: string | null;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;value: number;}[],): Record<string, string[] | number[]> {diff --git a/worker/src/features/database-read-stream/observation-stream.ts b/worker/src/features/database-read-stream/observation-stream.tsindex 8a3ba7b830..c08d902515 100644--- a/worker/src/features/database-read-stream/observation-stream.ts+++ b/worker/src/features/database-read-stream/observation-stream.ts@@ -1,6 +1,7 @@import {FilterCondition,- ScoreDataType,+ ScoreDataTypeEnum,+ type ScoreDataTypeType,TimeFilter,TracingSearchType,} from "@langfuse/shared";@@ -260,7 +261,7 @@ export const getObservationStream = async (props: {| {name: string;value: number;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;stringValue: string;}[]| undefined;@@ -301,7 +302,7 @@ export const getObservationStream = async (props: {| {name: string;value: number;- dataType: ScoreDataType;+ dataType: ScoreDataTypeType;stringValue: string;}[]| undefined;@@ -336,7 +337,7 @@ export const getObservationStream = async (props: {return {name,value: null,- dataType: "CATEGORICAL" as ScoreDataType,+ dataType: ScoreDataTypeEnum.CATEGORICAL,stringValue: valueParts.join(":"),};},diff --git a/worker/src/features/database-read-stream/trace-stream.ts b/worker/src/features/database-read-stream/trace-stream.tsindex 860e7f9e0b..dbc6a2f7c2 100644--- a/worker/src/features/database-read-stream/trace-stream.ts+++ b/worker/src/features/database-read-stream/trace-stream.ts@@ -1,7 +1,8 @@import {FilterCondition,+ ScoreDataTypeEnum,+ type ScoreDataTypeType,TracingSearchType,- ScoreDataType,} from "@langfuse/shared";import {getDistinctScoreNames,@@ -192,7 +193,7 @@ export const getTraceStream = async (props: {| {name: string;avg_value: number;- data_type: ScoreDataType;+ data_type: ScoreDataTypeType;string_value: string;}[]| undefined;@@ -235,7 +236,7 @@ export const getTraceStream = async (props: {return {name,value: null,- dataType: "CATEGORICAL" as ScoreDataType,+ dataType: ScoreDataTypeEnum.CATEGORICAL,stringValue: valueParts.join(":"),};},