🪢 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
perf: limit filteroptions api (#1973)
Max Deichmann74da65f9b28d
diff --git a/web/src/server/api/routers/generations/filterOptionsQuery.ts b/web/src/server/api/routers/generations/filterOptionsQuery.tsindex 16171514c1..760997b0ed 100644--- a/web/src/server/api/routers/generations/filterOptionsQuery.ts+++ b/web/src/server/api/routers/generations/filterOptionsQuery.ts@@ -18,6 +18,10 @@ export const filterOptionsQuery = protectedProjectProcedureprojectId: input.projectId,},},+ take: 1000,+ orderBy: {+ name: "desc",+ },by: ["name"],});@@ -25,11 +29,19 @@ export const filterOptionsQuery = protectedProjectProcedureby: ["model"],where: queryFilter,_count: { _all: true },+ take: 1000,+ orderBy: {+ model: "desc",+ },});const name = await ctx.prisma.observation.groupBy({by: ["name"],where: queryFilter,_count: { _all: true },+ take: 1000,+ orderBy: {+ name: "desc",+ },});const promptNames = await ctx.prisma.$queryRaw<Array<{@@ -47,6 +59,7 @@ export const filterOptionsQuery = protectedProjectProcedureAND o.prompt_id IS NOT NULLAND p.project_id = ${input.projectId}GROUP BY 1+ LIMIT 1000`);const traceName = await ctx.prisma.$queryRaw<Array<{@@ -63,6 +76,7 @@ export const filterOptionsQuery = protectedProjectProcedureAND o.project_id = ${input.projectId}AND t.project_id = ${input.projectId}GROUP BY 1+ LIMIT 1000`);// typecheck filter options, needs to include all columns with optionsdiff --git a/web/src/server/api/routers/traces.ts b/web/src/server/api/routers/traces.tsindex d64a43ce9b..a34fad092d 100644--- a/web/src/server/api/routers/traces.ts+++ b/web/src/server/api/routers/traces.ts@@ -182,6 +182,12 @@ export const traceRouter = createTRPCRouter({projectId: input.projectId,},},+ take: 1000,+ orderBy: {+ _count: {+ id: "desc",+ },+ },by: ["name"],});const names = await ctx.prisma.trace.groupBy({@@ -207,7 +213,8 @@ export const traceRouter = createTRPCRouter({SELECT COUNT(*)::integer AS "count", tags.tag as valueFROM traces, UNNEST(traces.tags) AS tags(tag)WHERE traces.project_id = ${input.projectId}- GROUP BY tags.tag;+ GROUP BY tags.tag+ LIMIT 1000`;const res: TraceOptions = {scores_avg: scores.map((score) => score.name),