Add drag reordering, exam deadlines, frozen shared quizzes, batched OCR and semantic search
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 33s
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 33s
- Drag-to-reorder for class materials, folders, quiz questions and deck cards. Pointer-based so touch works, plus keyboard (arrows/Home/End) with screen-reader announcements. - Timed exams get a wall-clock deadline. The server refuses late answers, submits overdue exams with what was saved, and the countdown keeps running while the page is closed. - Shared quiz sessions keep a frozen copy of their questions and flag later owner edits. - Scanned PDFs are read in cached 8-page batches with real page numbers (pdf-lib), removing the 30 MB whole-file limit. Compatible providers now receive PDFs as file parts. - Semantic search: embeddings for OpenAI, Gemini, Ollama and compatible servers, background indexing into chunk_vectors (migration 2), hybrid keyword + vector ranking for search, the assistant and focused generation, and a Settings -> AI section. 181 tests pass locally and in the Docker test stage on Node 24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3046e46d1c
commit
ccdad9728b
39 changed files with 1772 additions and 121 deletions
|
|
@ -49,6 +49,21 @@ export function newToolCallId(prefix: string): string {
|
|||
return `${prefix}_${globalThis.crypto.randomUUID().replace(/-/g, '').slice(0, 24)}`;
|
||||
}
|
||||
|
||||
/** Parses an OpenAI-style `/embeddings` response ({ data: [{ index, embedding }], usage }). */
|
||||
export function parseEmbeddings(res: unknown, expected: number, label: string): { vectors: number[][]; inputTokens: number } {
|
||||
const body = res as { data?: { index?: number; embedding?: unknown }[]; usage?: { prompt_tokens?: number; total_tokens?: number } };
|
||||
const rows = Array.isArray(body?.data) ? body.data : [];
|
||||
const vectors: number[][] = new Array(expected);
|
||||
rows.forEach((row, i) => {
|
||||
const at = typeof row.index === 'number' ? row.index : i;
|
||||
if (Array.isArray(row.embedding)) vectors[at] = row.embedding.map(Number);
|
||||
});
|
||||
if (rows.length !== expected || vectors.some((v) => !v || v.length === 0)) {
|
||||
throw new AIError('invalid_response', `${label} returned ${rows.length} embeddings for ${expected} inputs.`);
|
||||
}
|
||||
return { vectors, inputTokens: num(body?.usage?.prompt_tokens ?? body?.usage?.total_tokens) };
|
||||
}
|
||||
|
||||
export function dataUrl(mime: string, base64: string): string {
|
||||
return `data:${mime};base64,${base64}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue