Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

Add list of scores to GET /traces

Marc Klingen5ec05326c824
diff --git a/src/pages/api/public/traces.ts b/src/pages/api/public/traces.ts
index 14f51b5114..65cc37e707 100644
--- a/src/pages/api/public/traces.ts
+++ b/src/pages/api/public/traces.ts
@@ -139,7 +139,9 @@ export default async function handler(
const nameCondition = Prisma.sql`AND t."name" = ${obj.name}`;
const [traces, totalItems] = await Promise.all([
- prisma.$queryRaw<Array<Trace & { observations: string[] }>>(Prisma.sql`
+ prisma.$queryRaw<
+ Array<Trace & { observations: string[]; scores: string[] }>
+ >(Prisma.sql`
SELECT
t.id,
t.timestamp,
@@ -150,9 +152,11 @@ export default async function handler(
t.user_id as "userId",
t.release,
t.version,
- ARRAY_AGG(o.id) AS "observations"
+ array_remove(array_agg(o.id), NULL) AS "observations",
+ array_remove(array_agg(s.id), NULL) AS "scores"
FROM "traces" AS t
LEFT JOIN "observations" AS o ON t.id = o.trace_id
+ LEFT JOIN "scores" AS s ON t.id = s.trace_id
WHERE t.project_id = ${authCheck.scope.projectId}
AND o.project_id = ${authCheck.scope.projectId}
${obj.userId ? userCondition : Prisma.empty}