Add sandboxed Python for the assistant and a Python check of generated quizzes
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 51s
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 51s
- Pyodide (Python 3.14, WebAssembly) in a separate Node process under the permission model: read-only access to Pyodide's files, no writes, processes or network, empty environment, JS bridges removed, time limit with kill and restart. - Assistant tool run_python, which can load a draft or quiz as Python data. - After quiz generation the model checks question count, type mix, correct answers per type, duplicates and recomputed calculations with Python, then submits fixes that are applied only if the question still validates. Switch in the Generate dialog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f0aabe4d5d
commit
5ea61c882c
13 changed files with 800 additions and 6 deletions
|
|
@ -6,8 +6,8 @@ import { toast } from 'sonner';
|
|||
import { api, errorMessage } from '@/lib/api';
|
||||
import { qk, useAiModels, useAiStatus, useClass } from '@/lib/queries';
|
||||
import type { DocumentItem, Template } from '@/lib/types';
|
||||
import { cx, formatTokens } from '@/lib/util';
|
||||
import { Button, Callout, Dialog, Field, Input, Segmented, Select, Textarea } from '@/ui';
|
||||
import { cx, formatTokens, useLocalStorage } from '@/lib/util';
|
||||
import { Button, Callout, Dialog, Field, Input, Segmented, Select, Switch, Textarea } from '@/ui';
|
||||
|
||||
export interface GeneratePreset {
|
||||
kind?: 'quiz' | 'deck' | 'note';
|
||||
|
|
@ -44,6 +44,7 @@ export function GenerateDialog({ open, onClose, classId, folderId, preset }: { o
|
|||
const [instructions, setInstructions] = useState('');
|
||||
const [modelId, setModelId] = useState('');
|
||||
const [templateId, setTemplateId] = useState('');
|
||||
const [verify, setVerify] = useLocalStorage('sd.generate.verify', true);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
const docs = useMemo(() => (cls.data?.items.filter((i): i is DocumentItem => i.kind === 'document') ?? []).filter((d) => d.status === 'ready' && d.tokenCount > 0), [cls.data]);
|
||||
|
|
@ -103,7 +104,7 @@ export function GenerateDialog({ open, onClose, classId, folderId, preset }: { o
|
|||
else if (mode === 'text') source.text = text;
|
||||
else if (mode === 'weak') source.weakAreas = true;
|
||||
const body: Record<string, unknown> = { kind, classId, folderId: folderId ?? null, source, focus: focus.trim() || undefined, instructions: instructions.trim() || undefined, modelId: modelId || undefined };
|
||||
if (kind === 'quiz') Object.assign(body, { count, style, difficulty, sataShare: sata / 100 });
|
||||
if (kind === 'quiz') Object.assign(body, { count, style, difficulty, sataShare: sata / 100, verify });
|
||||
else if (kind === 'deck') Object.assign(body, { count, cardStyle });
|
||||
else Object.assign(body, { noteStyle });
|
||||
if (fixedSource && kind !== 'note') delete body.count;
|
||||
|
|
@ -264,6 +265,9 @@ export function GenerateDialog({ open, onClose, classId, folderId, preset }: { o
|
|||
<Field label={`Select-all-that-apply: ${sata}%`}>
|
||||
<input type="range" min={0} max={100} step={10} value={sata} onChange={(e) => setSata(Number(e.target.value))} className="mt-2.5 w-full accent-[var(--accent)]" />
|
||||
</Field>
|
||||
<div className="sm:col-span-full">
|
||||
<Switch checked={verify} onChange={setVerify} label="Double-check with Python" description="After writing, the model counts questions, select-all items and correct answers and recomputes calculations in a sandbox, then fixes what is wrong." />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{kind === 'deck' && (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue