diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/components/ScenarioTree.tsx b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/components/ScenarioTree.tsx index 154bbcd42b2..5f9b93019e9 100644 --- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/components/ScenarioTree.tsx +++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/components/ScenarioTree.tsx @@ -3,7 +3,7 @@ import React, { useState, useCallback } from "react"; import { makeStyles, tokens, Tree, TreeItem, TreeItemLayout, TreeItemValue, TreeOpenChangeData, TreeOpenChangeEvent, mergeClasses } from "@fluentui/react-components"; -import { DefaultRootNodeName, ScoreNode, ScoreNodeType, getPromptDetails, ChatMessageDisplay } from "./Summary"; +import { ScoreNode, ScoreNodeType, getPromptDetails, ChatMessageDisplay } from "./Summary"; import { PassFailBar } from "./PassFailBar"; import { MetricCardList, type MetricType } from "./MetricCard"; import ReactMarkdown from "react-markdown"; @@ -16,7 +16,6 @@ const ScenarioLevel = ({ node, parentPath, isOpen, renderMarkdown }: { isOpen: (path: string) => boolean, renderMarkdown: boolean, }) => { - node.collapseSingleChildNodes(); const path = `${parentPath}.${node.name}`; if (node.isLeafNode) { return @@ -53,7 +52,7 @@ export const ScenarioGroup = ({ node, renderMarkdown }: { node: ScoreNode, rende const isOpen = (name: string) => openItems.has(name); return ( - + ); }; diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/components/Summary.ts b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/components/Summary.ts index f49db7a2a60..4f818bdf133 100644 --- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/components/Summary.ts +++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/components/Summary.ts @@ -129,14 +129,13 @@ export class ScoreNode { } }; -export const DefaultRootNodeName = "All Evaluations"; - export const createScoreTree = (dataset: Dataset): ScoreNode => { - const root = new ScoreNode(DefaultRootNodeName, ScoreNodeType.Group); + const root = new ScoreNode("All Evaluations", ScoreNodeType.Group); for (const scenario of dataset.scenarioRunResults) { const path = [...scenario.scenarioName.split('.'), scenario.iterationName]; root.insertNode(path, scenario); } + root.collapseSingleChildNodes(); root.aggregate(); return root; }; @@ -151,8 +150,8 @@ const shortenPrompt = (prompt: string | undefined) => { return prompt; }; -function* flattener(node: ScoreNode, parentKey: string): Iterable<{key: string, node: ScoreNode}> { - const key= `${parentKey}.${node.name}`; +const flattener = function* (node: ScoreNode, parentKey: string): Iterable<{key: string, node: ScoreNode}> { + const key = `${parentKey}.${node.name}`; if (node.isLeafNode) { yield {key, node}; } else { @@ -161,7 +160,7 @@ function* flattener(node: ScoreNode, parentKey: string): Iterable<{key: string, yield* flattener(child, key); } } -} +}; const isTextContent = (content: AIContent): content is TextContent => { return (content as TextContent).text !== undefined; diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/html-report/init-devdata.js b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/html-report/init-devdata.js index a388f64e546..df7a91b71c1 100644 --- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/html-report/init-devdata.js +++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/html-report/init-devdata.js @@ -5,10 +5,16 @@ import fs from 'fs/promises'; import path from 'path'; import {fileURLToPath} from 'url'; +const storagePath = process.argv[2]; +if (!storagePath) { + console.error('Usage: node init-devdata.js '); + process.exit(1); +} + const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); -const resultsDir = path.join(__dirname, '../../../.storage/results'); +const resultsDir = path.join(storagePath, 'results'); const scenarioDirents = await fs.readdir(resultsDir, { withFileTypes: true }); let maxBirthtime = 0;