🪢 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
fix(prompts): show correct observation count for folder prompts (#10500)
Nimar9d78cef68a8f
diff --git a/web/src/__tests__/server/api/tables/prompts-ui.servertest.ts b/web/src/__tests__/server/api/tables/prompts-ui.servertest.tsindex 0d09b8537d..51080ae51d 100644--- a/web/src/__tests__/server/api/tables/prompts-ui.servertest.ts+++ b/web/src/__tests__/server/api/tables/prompts-ui.servertest.ts@@ -91,6 +91,77 @@ describe("UI Prompts Table", () => {);});+ it("should count observations for foldered prompts with full path", async () => {+ const folderedObservation = createObservation({+ id: v4(),+ project_id: projectId,+ trace_id: v4(),+ prompt_id: v4(),+ type: "GENERATION",+ created_at: Date.now(),+ updated_at: Date.now(),+ event_ts: Date.now(),+ is_deleted: 0,+ metadata: {},+ start_time: Date.now(),+ provided_usage_details: {},+ provided_cost_details: {},+ usage_details: { input: 100, output: 200 },+ cost_details: { input: 100, output: 200 },+ name: "Test Observation",+ level: "WARNING",+ input: "some llm input",+ output: "some llm output",+ version: "1.2.0",+ parent_observation_id: null,+ status_message: null,+ provided_model_name: "anthropic",+ internal_model_id: "some-model-id",+ model_parameters: null,+ total_cost: 100,+ prompt_name: "folder1/my-prompt", // Full path with folder+ prompt_version: 1,+ end_time: Date.now(),+ completion_start_time: Date.now(),+ });++ const secondFolderedObservation = {+ ...folderedObservation,+ id: v4(),+ prompt_name: "folder1/my-prompt", // Same foldered prompt+ };++ const thirdFolderedObservation = {+ ...folderedObservation,+ id: v4(),+ prompt_name: "folder2/another-prompt", // Different folder+ };++ await createObservationsCh([+ folderedObservation,+ secondFolderedObservation,+ thirdFolderedObservation,+ ]);++ const result = await getObservationsWithPromptName(projectId, [+ "folder1/my-prompt",+ "folder2/another-prompt",+ ]);++ expect(result).toEqual(+ expect.arrayContaining([+ {+ promptName: "folder1/my-prompt",+ count: 2, // Should count both observations+ },+ {+ promptName: "folder2/another-prompt",+ count: 1,+ },+ ]),+ );+ });+it("should correctly calculate prompt metrics", async () => {const observation = createObservation({id: v4(),diff --git a/web/src/features/prompts/components/prompts-table.tsx b/web/src/features/prompts/components/prompts-table.tsxindex d479d8c939..d89458c9b4 100644--- a/web/src/features/prompts/components/prompts-table.tsx+++ b/web/src/features/prompts/components/prompts-table.tsx@@ -134,7 +134,7 @@ export function PromptTable() {const promptsRowData = joinTableCoreAndMetrics<CoreType, MetricType>(prompts.data?.prompts.map((p) => ({...p,- id: p.name,+ id: buildFullPath(currentFolderPath, p.name),})),promptMetrics.data?.map((pm) => ({...pm,@@ -150,8 +150,9 @@ export function PromptTable() {for (const prompt of promptsRowData.rows) {const isFolder = (prompt as { row_type?: string }).row_type === "folder";- const itemName = prompt.id; // id actually contains the name due to type mapping- const fullPath = buildFullPath(currentFolderPath, itemName);+ const fullPath = prompt.id; // id now contains the full path (used for metrics join)+ // Extract just the name portion (last segment) for display+ const itemName = fullPath.split("/").pop() ?? fullPath;const type = isFolder ? "folder" : (prompt.type as "text" | "chat");combinedRows.push(@@ -177,7 +178,7 @@ export function PromptTable() {...promptsRowData,rows: combinedRows,};- }, [promptsRowData, currentFolderPath]);+ }, [promptsRowData]);const promptFilterOptions = api.prompts.filterOptions.useQuery({