feat: add model run comparison

This commit is contained in:
2026-06-24 15:12:20 +08:00
parent f1ad5a7d15
commit b002c44218
7 changed files with 643 additions and 13 deletions

View File

@@ -273,6 +273,23 @@ export type AreaScoreModelRunResponse = {
scores: AreaScore[];
};
export type AreaScoreRunDiffItem = {
area_id: string;
name: string;
district: string;
base_score: number | null;
candidate_score: number | null;
score_delta: number | null;
base_recommendation: string | null;
candidate_recommendation: string | null;
};
export type AreaScoreRunDiff = {
base_run: ModelRun;
candidate_run: ModelRun;
items: AreaScoreRunDiffItem[];
};
export type AreaScoreLineage = {
area_id: string;
area_name: string;
@@ -527,6 +544,29 @@ export async function createAreaScoreModelRun(
});
}
export async function fetchModelRuns(filters: {
model_name?: string;
target_month?: string;
} = {}): Promise<ModelRun[]> {
const params = new URLSearchParams();
for (const [key, value] of Object.entries(filters)) {
if (value) {
params.set(key, value);
}
}
const query = params.toString();
return fetchJson(`/api/v1/model-runs${query ? `?${query}` : ""}`);
}
export async function fetchAreaScoreRunDiff(
baseRunId: number,
candidateRunId: number,
): Promise<AreaScoreRunDiff> {
return fetchJson(
`/api/v1/model-runs/area-scores/diff?base_run_id=${baseRunId}&candidate_run_id=${candidateRunId}`,
);
}
export async function fetchAreaScoreLineage(
areaId: string,
month: string,