Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions dashboard/api/src/functions/getMsbenchEvalMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ function getEvalTableClient(): TableClient {
);
}

/** Escape a value for use inside an OData string literal (single quotes are doubled). */
function odataLiteral(value: string): string {
return value.replace(/'/g, "''");
}

/**
* Returns eval metrics from the table.
* GET /api/msbench-eval-metrics
Expand All @@ -39,8 +44,8 @@ async function getMsbenchEvalMetrics(request: HttpRequest, context: InvocationCo
const tableClient = getEvalTableClient();

const filters: string[] = [];
if (filterBenchmark) filters.push(`benchmark eq '${filterBenchmark}'`);
if (filterModel) filters.push(`model eq '${filterModel}'`);
if (filterBenchmark) filters.push(`benchmark eq '${odataLiteral(filterBenchmark)}'`);
if (filterModel) filters.push(`model eq '${odataLiteral(filterModel)}'`);
if (filterResolved === "1" || filterResolved === "0") filters.push(`resolved eq ${Number(filterResolved)}`);
const filter = filters.length > 0 ? filters.join(" and ") : undefined;

Expand All @@ -64,11 +69,11 @@ async function getMsbenchEvalMetrics(request: HttpRequest, context: InvocationCo
body: JSON.stringify(entities),
};
} catch (err: any) {
context.log("Error querying eval metrics:", err.message);
context.error("Error querying eval metrics:", err);
return {
status: 500,
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ error: err.message }),
body: JSON.stringify({ error: "Failed to query eval metrics" }),
};
}
}
Expand Down Expand Up @@ -101,11 +106,11 @@ async function getMsbenchEvalFilters(request: HttpRequest, context: InvocationCo
}),
};
} catch (err: any) {
context.log("Error querying eval filters:", err.message);
context.error("Error querying eval filters:", err);
return {
status: 500,
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ error: err.message }),
body: JSON.stringify({ error: "Failed to query eval filters" }),
};
}
}
Expand Down