Spaces:
Running
Running
Tobias Brugger
commited on
Commit
·
9976904
1
Parent(s):
040ec69
add config files loading and display
Browse files- package-lock.json +27 -0
- package.json +2 -0
- src/lib/DatasetViewer.svelte +61 -1
- src/lib/huggingfaceApi.ts +43 -1
package-lock.json
CHANGED
|
@@ -9,11 +9,13 @@
|
|
| 9 |
"version": "0.0.0",
|
| 10 |
"dependencies": {
|
| 11 |
"@huggingface/hub": "^2.7.1",
|
|
|
|
| 12 |
"marked": "^17.0.1"
|
| 13 |
},
|
| 14 |
"devDependencies": {
|
| 15 |
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
| 16 |
"@tsconfig/svelte": "^5.0.4",
|
|
|
|
| 17 |
"svelte": "^5.28.1",
|
| 18 |
"svelte-check": "^4.1.6",
|
| 19 |
"typescript": "~5.8.3",
|
|
@@ -908,6 +910,13 @@
|
|
| 908 |
"dev": true,
|
| 909 |
"license": "MIT"
|
| 910 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 911 |
"node_modules/acorn": {
|
| 912 |
"version": "8.15.0",
|
| 913 |
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
|
|
@@ -931,6 +940,12 @@
|
|
| 931 |
"node": ">=8"
|
| 932 |
}
|
| 933 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 934 |
"node_modules/aria-query": {
|
| 935 |
"version": "5.3.2",
|
| 936 |
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz",
|
|
@@ -1144,6 +1159,18 @@
|
|
| 1144 |
"@types/estree": "^1.0.6"
|
| 1145 |
}
|
| 1146 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1147 |
"node_modules/kleur": {
|
| 1148 |
"version": "4.1.5",
|
| 1149 |
"resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
|
|
|
|
| 9 |
"version": "0.0.0",
|
| 10 |
"dependencies": {
|
| 11 |
"@huggingface/hub": "^2.7.1",
|
| 12 |
+
"js-yaml": "^4.1.1",
|
| 13 |
"marked": "^17.0.1"
|
| 14 |
},
|
| 15 |
"devDependencies": {
|
| 16 |
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
| 17 |
"@tsconfig/svelte": "^5.0.4",
|
| 18 |
+
"@types/js-yaml": "^4.0.9",
|
| 19 |
"svelte": "^5.28.1",
|
| 20 |
"svelte-check": "^4.1.6",
|
| 21 |
"typescript": "~5.8.3",
|
|
|
|
| 910 |
"dev": true,
|
| 911 |
"license": "MIT"
|
| 912 |
},
|
| 913 |
+
"node_modules/@types/js-yaml": {
|
| 914 |
+
"version": "4.0.9",
|
| 915 |
+
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz",
|
| 916 |
+
"integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==",
|
| 917 |
+
"dev": true,
|
| 918 |
+
"license": "MIT"
|
| 919 |
+
},
|
| 920 |
"node_modules/acorn": {
|
| 921 |
"version": "8.15.0",
|
| 922 |
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
|
|
|
|
| 940 |
"node": ">=8"
|
| 941 |
}
|
| 942 |
},
|
| 943 |
+
"node_modules/argparse": {
|
| 944 |
+
"version": "2.0.1",
|
| 945 |
+
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
| 946 |
+
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
|
| 947 |
+
"license": "Python-2.0"
|
| 948 |
+
},
|
| 949 |
"node_modules/aria-query": {
|
| 950 |
"version": "5.3.2",
|
| 951 |
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz",
|
|
|
|
| 1159 |
"@types/estree": "^1.0.6"
|
| 1160 |
}
|
| 1161 |
},
|
| 1162 |
+
"node_modules/js-yaml": {
|
| 1163 |
+
"version": "4.1.1",
|
| 1164 |
+
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
|
| 1165 |
+
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
|
| 1166 |
+
"license": "MIT",
|
| 1167 |
+
"dependencies": {
|
| 1168 |
+
"argparse": "^2.0.1"
|
| 1169 |
+
},
|
| 1170 |
+
"bin": {
|
| 1171 |
+
"js-yaml": "bin/js-yaml.js"
|
| 1172 |
+
}
|
| 1173 |
+
},
|
| 1174 |
"node_modules/kleur": {
|
| 1175 |
"version": "4.1.5",
|
| 1176 |
"resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
|
package.json
CHANGED
|
@@ -12,6 +12,7 @@
|
|
| 12 |
"devDependencies": {
|
| 13 |
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
| 14 |
"@tsconfig/svelte": "^5.0.4",
|
|
|
|
| 15 |
"svelte": "^5.28.1",
|
| 16 |
"svelte-check": "^4.1.6",
|
| 17 |
"typescript": "~5.8.3",
|
|
@@ -19,6 +20,7 @@
|
|
| 19 |
},
|
| 20 |
"dependencies": {
|
| 21 |
"@huggingface/hub": "^2.7.1",
|
|
|
|
| 22 |
"marked": "^17.0.1"
|
| 23 |
}
|
| 24 |
}
|
|
|
|
| 12 |
"devDependencies": {
|
| 13 |
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
| 14 |
"@tsconfig/svelte": "^5.0.4",
|
| 15 |
+
"@types/js-yaml": "^4.0.9",
|
| 16 |
"svelte": "^5.28.1",
|
| 17 |
"svelte-check": "^4.1.6",
|
| 18 |
"typescript": "~5.8.3",
|
|
|
|
| 20 |
},
|
| 21 |
"dependencies": {
|
| 22 |
"@huggingface/hub": "^2.7.1",
|
| 23 |
+
"js-yaml": "^4.1.1",
|
| 24 |
"marked": "^17.0.1"
|
| 25 |
}
|
| 26 |
}
|
src/lib/DatasetViewer.svelte
CHANGED
|
@@ -1,5 +1,9 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import type { TermDefinition, EquivalencyScore } from "./types";
|
| 4 |
import { marked } from "marked";
|
| 5 |
import { config, getDatasetName } from "./config";
|
|
@@ -28,6 +32,7 @@
|
|
| 28 |
let equivalencyScores = $state<EquivalencyScore[]>([]);
|
| 29 |
let selectedTerm1 = $state<string | null>(null);
|
| 30 |
let selectedTerm2 = $state<string | null>(null);
|
|
|
|
| 31 |
|
| 32 |
// Track previous selected terms for detecting user-initiated changes (loop prevention)
|
| 33 |
let prevSelectedTerm1 = $state<string | null>(null);
|
|
@@ -98,6 +103,20 @@
|
|
| 98 |
|
| 99 |
hasLoaded = true;
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
// Auto-select first term from jurisdiction 1 and its equivalent in jurisdiction 2
|
| 102 |
if (data1.length > 0) {
|
| 103 |
const firstTerm = data1[0].term;
|
|
@@ -270,6 +289,22 @@
|
|
| 270 |
<div class="jurisdiction-comparison">
|
| 271 |
<h2>Jurisdiction Term Comparison</h2>
|
| 272 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
<div class="form">
|
| 274 |
<div class="form-row">
|
| 275 |
<div class="form-group">
|
|
@@ -981,4 +1016,29 @@
|
|
| 981 |
background: #535bf2;
|
| 982 |
border-color: #535bf2;
|
| 983 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 984 |
</style>
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
+
import {
|
| 3 |
+
fetchAllRows,
|
| 4 |
+
fetchDatasetConfigYaml,
|
| 5 |
+
type DatasetConfigYaml,
|
| 6 |
+
} from "./huggingfaceApi";
|
| 7 |
import type { TermDefinition, EquivalencyScore } from "./types";
|
| 8 |
import { marked } from "marked";
|
| 9 |
import { config, getDatasetName } from "./config";
|
|
|
|
| 32 |
let equivalencyScores = $state<EquivalencyScore[]>([]);
|
| 33 |
let selectedTerm1 = $state<string | null>(null);
|
| 34 |
let selectedTerm2 = $state<string | null>(null);
|
| 35 |
+
let datasetConfig = $state<DatasetConfigYaml | null>(null);
|
| 36 |
|
| 37 |
// Track previous selected terms for detecting user-initiated changes (loop prevention)
|
| 38 |
let prevSelectedTerm1 = $state<string | null>(null);
|
|
|
|
| 103 |
|
| 104 |
hasLoaded = true;
|
| 105 |
|
| 106 |
+
// Fetch config.yaml for this jurisdiction pair
|
| 107 |
+
try {
|
| 108 |
+
const configPath = `${jurisdiction1}_${jurisdiction2}/config.yaml`;
|
| 109 |
+
datasetConfig = await fetchDatasetConfigYaml(
|
| 110 |
+
scoresDataset,
|
| 111 |
+
configPath,
|
| 112 |
+
"main",
|
| 113 |
+
undefined
|
| 114 |
+
);
|
| 115 |
+
} catch (e) {
|
| 116 |
+
datasetConfig = null;
|
| 117 |
+
console.warn("Could not load dataset config.yaml", e);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
// Auto-select first term from jurisdiction 1 and its equivalent in jurisdiction 2
|
| 121 |
if (data1.length > 0) {
|
| 122 |
const firstTerm = data1[0].term;
|
|
|
|
| 289 |
<div class="jurisdiction-comparison">
|
| 290 |
<h2>Jurisdiction Term Comparison</h2>
|
| 291 |
|
| 292 |
+
<!-- Model Info Display -->
|
| 293 |
+
{#if datasetConfig}
|
| 294 |
+
<div class="dataset-model-info subtle">
|
| 295 |
+
<span><strong>Scoring Model:</strong> {datasetConfig.scoring_model}</span>
|
| 296 |
+
<span class="sep">|</span>
|
| 297 |
+
<span
|
| 298 |
+
><strong>Synthesis Model:</strong> {datasetConfig.synthesis_model}</span
|
| 299 |
+
>
|
| 300 |
+
<span class="sep">|</span>
|
| 301 |
+
<span
|
| 302 |
+
><strong>Last Updated:</strong>
|
| 303 |
+
{datasetConfig.generation_date || "N/A"}</span
|
| 304 |
+
>
|
| 305 |
+
</div>
|
| 306 |
+
{/if}
|
| 307 |
+
|
| 308 |
<div class="form">
|
| 309 |
<div class="form-row">
|
| 310 |
<div class="form-group">
|
|
|
|
| 1016 |
background: #535bf2;
|
| 1017 |
border-color: #535bf2;
|
| 1018 |
}
|
| 1019 |
+
|
| 1020 |
+
.dataset-model-info.subtle {
|
| 1021 |
+
background: none;
|
| 1022 |
+
border: none;
|
| 1023 |
+
padding: 0.25rem 0;
|
| 1024 |
+
margin: 0 0 0.5rem 0;
|
| 1025 |
+
max-width: 100%;
|
| 1026 |
+
color: #888;
|
| 1027 |
+
font-size: 0.92rem;
|
| 1028 |
+
text-align: left;
|
| 1029 |
+
display: flex;
|
| 1030 |
+
flex-wrap: wrap;
|
| 1031 |
+
gap: 0.5rem;
|
| 1032 |
+
align-items: center;
|
| 1033 |
+
}
|
| 1034 |
+
.dataset-model-info.subtle strong {
|
| 1035 |
+
color: #888;
|
| 1036 |
+
font-weight: 500;
|
| 1037 |
+
margin-right: 0.15em;
|
| 1038 |
+
}
|
| 1039 |
+
.dataset-model-info.subtle .sep {
|
| 1040 |
+
color: #ccc;
|
| 1041 |
+
font-size: 1.1em;
|
| 1042 |
+
margin: 0 0.5em;
|
| 1043 |
+
}
|
| 1044 |
</style>
|
src/lib/huggingfaceApi.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
| 5 |
DatasetSplitsResponse,
|
| 6 |
DatasetError,
|
| 7 |
} from "./types";
|
| 8 |
-
|
| 9 |
const BASE_URL = "https://datasets-server.huggingface.co";
|
| 10 |
|
| 11 |
/**
|
|
@@ -156,3 +156,45 @@ export async function fetchAllRows(
|
|
| 156 |
|
| 157 |
return allRows;
|
| 158 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
DatasetSplitsResponse,
|
| 6 |
DatasetError,
|
| 7 |
} from "./types";
|
| 8 |
+
import yaml from "js-yaml";
|
| 9 |
const BASE_URL = "https://datasets-server.huggingface.co";
|
| 10 |
|
| 11 |
/**
|
|
|
|
| 156 |
|
| 157 |
return allRows;
|
| 158 |
}
|
| 159 |
+
|
| 160 |
+
export async function fetchDatasetFileRaw(
|
| 161 |
+
dataset: string, // "owner/dataset-name"
|
| 162 |
+
filePath: string, // "config.yaml"
|
| 163 |
+
branch = "main",
|
| 164 |
+
token?: string
|
| 165 |
+
): Promise<string> {
|
| 166 |
+
const url = `https://huggingface.co/datasets/${dataset}/raw/${encodeURIComponent(
|
| 167 |
+
branch
|
| 168 |
+
)}/${filePath}`;
|
| 169 |
+
const headers: HeadersInit = {};
|
| 170 |
+
if (token) {
|
| 171 |
+
headers["Authorization"] = `Bearer ${token}`;
|
| 172 |
+
}
|
| 173 |
+
const res = await fetch(url, { headers });
|
| 174 |
+
if (!res.ok)
|
| 175 |
+
throw new Error(`Failed to fetch file: ${res.status} ${res.statusText}`);
|
| 176 |
+
return res.text();
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
export interface DatasetConfigYaml {
|
| 180 |
+
scoring_model: string;
|
| 181 |
+
scoring_provider: string;
|
| 182 |
+
synthesis_model: string;
|
| 183 |
+
synthesis_provider: string;
|
| 184 |
+
jurisdiction1: string;
|
| 185 |
+
jurisdiction2: string;
|
| 186 |
+
description: string;
|
| 187 |
+
grading_templates_1_uid: string;
|
| 188 |
+
grading_templates_2_uid: string;
|
| 189 |
+
generation_date?: string;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
export async function fetchDatasetConfigYaml(
|
| 193 |
+
dataset: string,
|
| 194 |
+
filePath = "config.yaml",
|
| 195 |
+
branch = "main",
|
| 196 |
+
token?: string
|
| 197 |
+
): Promise<DatasetConfigYaml | null> {
|
| 198 |
+
const text = await fetchDatasetFileRaw(dataset, filePath, branch, token);
|
| 199 |
+
return yaml.load(text) as DatasetConfigYaml;
|
| 200 |
+
}
|