Skip to content

Commit 05f8b26

Browse files
authored
Update dev-server data import to reflect runtime import quirks. (#6257)
1 parent 84d09b7 commit 05f8b26

File tree

2 files changed

+4
-11
lines changed
  • src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript

2 files changed

+4
-11
lines changed

src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/components/App.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,9 @@ function App() {
5555
const toggleSettings = () => setIsSettingsOpen(!isSettingsOpen);
5656
const closeSettings = () => setIsSettingsOpen(false);
5757

58-
const downloadDataset = () => {
59-
// check if dataset has a default property that duplicates the content
60-
const containsDefault = 'default' in dataset &&
61-
typeof dataset.default === 'object' &&
62-
dataset.default !== null &&
63-
'scenarioRunResults' in (dataset.default as any);
64-
65-
const dataToSerialize = containsDefault ? dataset.default : dataset;
66-
58+
const downloadDataset = () => {
6759
// create a stringified JSON of the dataset
68-
const dataStr = JSON.stringify(dataToSerialize, null, 2);
60+
const dataStr = JSON.stringify(dataset, null, 2);
6961

7062
// create a link to download the JSON file in the page and click it
7163
const blob = new Blob([dataStr], { type: 'application/json' });

src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/html-report/src/main.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ let dataset: Dataset = { scenarioRunResults: [] };
1313
if (!import.meta.env.PROD) {
1414
// This only runs in development. In production the data is embedded into the dataset variable declaration above.
1515
// run `node init-devdata.js` to populate the data file from the most recent execution.
16-
dataset = await import("../devdata.json") as unknown as Dataset;
16+
const imported = await import("../devdata.json");
17+
dataset = imported.default as unknown as Dataset;
1718
}
1819

1920
const scoreSummary = createScoreSummary(dataset);

0 commit comments

Comments
 (0)