Clean
Browse files- app.py +17 -0
- static/app.js +13 -0
- static/index.html +6 -3
app.py
CHANGED
|
@@ -303,6 +303,23 @@ def clear_corpus():
|
|
| 303 |
return _public_state()
|
| 304 |
|
| 305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
# --- token edit ------------------------------------------------------------
|
| 307 |
|
| 308 |
@app.post("/api/sentence/{idx}/token/{tidx}")
|
|
|
|
| 303 |
return _public_state()
|
| 304 |
|
| 305 |
|
| 306 |
+
@app.post("/api/reset")
|
| 307 |
+
def reset_all():
|
| 308 |
+
"""Wipe everything except the API key (which lives client-side)."""
|
| 309 |
+
SESSION["schema"] = _default_schema().to_dict()
|
| 310 |
+
SESSION["language"] = ""
|
| 311 |
+
SESSION["models"] = ["openai/gpt-oss-20b:free"]
|
| 312 |
+
SESSION["priority"] = []
|
| 313 |
+
SESSION["temperature"] = 0.0
|
| 314 |
+
SESSION["n_icl"] = 5
|
| 315 |
+
SESSION["icl_pool"] = ICLPool()
|
| 316 |
+
SESSION["sentences"] = []
|
| 317 |
+
SESSION["system_prompt"] = DEFAULT_SYSTEM_PROMPT
|
| 318 |
+
SESSION["user_template"] = DEFAULT_FEW_SHOT
|
| 319 |
+
SESSION["rendered_user_cache"] = ""
|
| 320 |
+
return _public_state()
|
| 321 |
+
|
| 322 |
+
|
| 323 |
# --- token edit ------------------------------------------------------------
|
| 324 |
|
| 325 |
@app.post("/api/sentence/{idx}/token/{tidx}")
|
static/app.js
CHANGED
|
@@ -507,6 +507,19 @@ function annotator() {
|
|
| 507 |
this.applyState(await r.json());
|
| 508 |
},
|
| 509 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
async clearIcl() {
|
| 511 |
const r = await fetch('/api/icl/clear', { method: 'POST' });
|
| 512 |
this.applyState(await r.json());
|
|
|
|
| 507 |
this.applyState(await r.json());
|
| 508 |
},
|
| 509 |
|
| 510 |
+
async resetAll() {
|
| 511 |
+
if (!confirm('Reset everything? This wipes:\n• loaded corpus\n• annotations\n• ICL pool\n• custom task/schema\n• prompt overrides\n\nYour API key (browser-only) is kept.')) return;
|
| 512 |
+
this.loading = true;
|
| 513 |
+
try {
|
| 514 |
+
const r = await fetch('/api/reset', { method: 'POST' });
|
| 515 |
+
this.applyState(await r.json());
|
| 516 |
+
this.selection = new Set();
|
| 517 |
+
this.focus = { sent: null, tok: null };
|
| 518 |
+
this.modal = null;
|
| 519 |
+
this.toast('Workspace reset.', 'ok');
|
| 520 |
+
} finally { this.loading = false; }
|
| 521 |
+
},
|
| 522 |
+
|
| 523 |
async clearIcl() {
|
| 524 |
const r = await fetch('/api/icl/clear', { method: 'POST' });
|
| 525 |
this.applyState(await r.json());
|
static/index.html
CHANGED
|
@@ -24,7 +24,7 @@
|
|
| 24 |
}
|
| 25 |
}
|
| 26 |
</script>
|
| 27 |
-
<link rel="stylesheet" href="/static/styles.css?v=
|
| 28 |
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.13.10/dist/cdn.min.js"></script>
|
| 29 |
</head>
|
| 30 |
<body class="font-sans bg-ink-50 text-ink-900 min-h-screen" x-data="annotator()" x-init="init()" x-cloak>
|
|
@@ -133,7 +133,10 @@
|
|
| 133 |
<section class="card">
|
| 134 |
<h3 class="card-title">📝 Your text</h3>
|
| 135 |
<button @click="modal='paste'" class="btn btn-secondary w-full">+ Paste text</button>
|
| 136 |
-
<button @click="clearCorpus()" x-show="state.sentences.length > 0" class="btn btn-ghost w-full mt-2 text-xs">Clear corpus</button>
|
|
|
|
|
|
|
|
|
|
| 137 |
</section>
|
| 138 |
|
| 139 |
<section class="card" x-show="state.sentences.length > 0">
|
|
@@ -827,6 +830,6 @@
|
|
| 827 |
</template>
|
| 828 |
</div>
|
| 829 |
|
| 830 |
-
<script src="/static/app.js?v=
|
| 831 |
</body>
|
| 832 |
</html>
|
|
|
|
| 24 |
}
|
| 25 |
}
|
| 26 |
</script>
|
| 27 |
+
<link rel="stylesheet" href="/static/styles.css?v=20260516b">
|
| 28 |
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.13.10/dist/cdn.min.js"></script>
|
| 29 |
</head>
|
| 30 |
<body class="font-sans bg-ink-50 text-ink-900 min-h-screen" x-data="annotator()" x-init="init()" x-cloak>
|
|
|
|
| 133 |
<section class="card">
|
| 134 |
<h3 class="card-title">📝 Your text</h3>
|
| 135 |
<button @click="modal='paste'" class="btn btn-secondary w-full">+ Paste text</button>
|
| 136 |
+
<button @click="clearCorpus()" x-show="state.sentences.length > 0" class="btn btn-ghost w-full mt-2 text-xs">Clear corpus only</button>
|
| 137 |
+
<button @click="resetAll()" class="btn btn-ghost w-full mt-1 text-xs text-red-600 hover:!bg-red-50">
|
| 138 |
+
🗑 Reset everything
|
| 139 |
+
</button>
|
| 140 |
</section>
|
| 141 |
|
| 142 |
<section class="card" x-show="state.sentences.length > 0">
|
|
|
|
| 830 |
</template>
|
| 831 |
</div>
|
| 832 |
|
| 833 |
+
<script src="/static/app.js?v=20260516b"></script>
|
| 834 |
</body>
|
| 835 |
</html>
|