🪢 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(events-table): show scores in table (#12264)
Nimar031421f9603f
diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsxindex 8b42e0bc98..cd432fbdd0 100644--- a/web/src/features/events/components/EventsTable.tsx+++ b/web/src/features/events/components/EventsTable.tsx@@ -1154,7 +1154,7 @@ export default function ObservationsEventsTable({startTime: observation.startTime,endTime: observation.endTime ?? undefined,timeToFirstToken: observation.timeToFirstToken ?? undefined,- scores: {}, // TODO: scores not included in FullObservation type+ scores: observation.scores ?? {},latency: observation.latency ?? undefined,totalCost: observation.totalCost ?? undefined,cost: {diff --git a/web/src/features/events/hooks/useEventsTableData.ts b/web/src/features/events/hooks/useEventsTableData.tsindex 8775f0de5a..b62f9dcf93 100644--- a/web/src/features/events/hooks/useEventsTableData.ts+++ b/web/src/features/events/hooks/useEventsTableData.ts@@ -1,12 +1,18 @@import { api } from "@/src/utils/api";import { useMemo } from "react";-import { type FilterState, AnnotationQueueObjectType } from "@langfuse/shared";+import {+ type FilterState,+ AnnotationQueueObjectType,+ type ScoreAggregate,+} from "@langfuse/shared";import { type FullEventsObservations } from "@langfuse/shared/src/server";import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { joinTableCoreAndMetrics } from "@/src/components/table/utils/joinTableCoreAndMetrics";import { type EventBatchIOOutput } from "@/src/features/events/server/eventsRouter";-type FullEventsObservation = FullEventsObservations[number];+type FullEventsObservation = FullEventsObservations[number] & {+ scores?: ScoreAggregate;+};type UseEventsTableDataParams = {projectId: string;diff --git a/web/src/features/events/server/eventsService.ts b/web/src/features/events/server/eventsService.tsindex 6f7d69b5f1..4e3b930362 100644--- a/web/src/features/events/server/eventsService.ts+++ b/web/src/features/events/server/eventsService.ts@@ -1,4 +1,8 @@import { type z } from "zod/v4";+import {+ AGGREGATABLE_SCORE_TYPES,+ filterAndValidateDbScoreList,+} from "@langfuse/shared";import {getObservationsCountFromEventsTable,getObservationsWithModelDataFromEventsTable,@@ -23,9 +27,12 @@ import {getNumericScoresGroupedByName,getTracesGroupedByTags,getObservationsBatchIOFromEventsTable,+ getScoresForObservations,+ traceException,} from "@langfuse/shared/src/server";import { type timeFilter, type FilterState } from "@langfuse/shared";import { type EventBatchIOOutput } from "@/src/features/events/server/eventsRouter";+import { aggregateScores } from "@/src/features/scores/lib/aggregateScores";type TimeFilter = z.infer<typeof timeFilter>;@@ -72,7 +79,44 @@ export async function getEventList(params: GetObservationsListParams) {const observations =await getObservationsWithModelDataFromEventsTable(queryOpts);- return { observations };+ if (observations.length === 0) {+ return { observations };+ }++ const scores = await getScoresForObservations({+ projectId: params.projectId,+ observationIds: observations.map((observation) => observation.id),+ excludeMetadata: true,+ includeHasMetadata: true,+ });++ const validatedScores = filterAndValidateDbScoreList({+ scores,+ dataTypes: AGGREGATABLE_SCORE_TYPES,+ includeHasMetadata: true,+ onParseError: traceException,+ });++ const scoresByObservationId = new Map<+ string,+ Array<(typeof validatedScores)[number]>+ >();+ for (const score of validatedScores) {+ if (!score.observationId) continue;+ const existingScores = scoresByObservationId.get(score.observationId);+ if (existingScores) {+ existingScores.push(score);+ } else {+ scoresByObservationId.set(score.observationId, [score]);+ }+ }++ const observationsWithScores = observations.map((observation) => ({+ ...observation,+ scores: aggregateScores(scoresByObservationId.get(observation.id) ?? []),+ }));++ return { observations: observationsWithScores };}/**