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
|
|
@ -37,6 +37,7 @@ import {
|
|||
testProvider,
|
||||
usageSummary,
|
||||
} from '../ai/service.ts';
|
||||
import { embedTexts, embeddingSettingsSchema, getEmbeddingSettings, embeddingStatus, rebuildIndex, saveEmbeddingSettings, scheduleIndexing } from '../services/semantic.ts';
|
||||
import { AIError } from '../ai/types.ts';
|
||||
import { badRequest, idParam, notFound, readBody, type AppContext } from '../http.ts';
|
||||
|
||||
|
|
@ -108,7 +109,10 @@ export function aiRoutes(app: AppContext): Hono {
|
|||
r.post('/ai/providers', async (c) => c.json({ provider: saveProvider(app, null, await readBody(c, providerInputSchema)) }, 201));
|
||||
r.patch('/ai/providers/:id', async (c) => c.json({ provider: saveProvider(app, idParam(c), await readBody(c, providerInputSchema)) }));
|
||||
r.delete('/ai/providers/:id', (c) => {
|
||||
deleteProvider(app, idParam(c));
|
||||
const id = idParam(c);
|
||||
deleteProvider(app, id);
|
||||
// Semantic search cannot keep using a provider that no longer exists.
|
||||
if (getEmbeddingSettings(db).providerId === id) saveEmbeddingSettings(app, { providerId: null, model: '', dimensions: null });
|
||||
return c.json({ ok: true });
|
||||
});
|
||||
r.post('/ai/providers/:id/test', async (c) => c.json({ result: await testProvider(app, idParam(c)) }));
|
||||
|
|
@ -267,5 +271,27 @@ export function aiRoutes(app: AppContext): Hono {
|
|||
});
|
||||
});
|
||||
|
||||
/* ------------------------------ semantic search ------------------------------ */
|
||||
|
||||
r.get('/ai/embeddings', (c) => c.json(embeddingStatus(app)));
|
||||
r.put('/ai/embeddings', async (c) => {
|
||||
saveEmbeddingSettings(app, await readBody(c, embeddingSettingsSchema));
|
||||
return c.json(embeddingStatus(app));
|
||||
});
|
||||
/** Embeds one sentence to prove the model works before indexing everything. */
|
||||
r.post('/ai/embeddings/test', async (c) => {
|
||||
const started = Date.now();
|
||||
const [v] = await embedTexts(app, ['Furosemide is a loop diuretic.'], 'query');
|
||||
return c.json({ ok: true, dimensions: v.length, latencyMs: Date.now() - started });
|
||||
});
|
||||
r.post('/ai/embeddings/rebuild', (c) => {
|
||||
rebuildIndex(app);
|
||||
return c.json(embeddingStatus(app));
|
||||
});
|
||||
r.post('/ai/embeddings/resume', (c) => {
|
||||
scheduleIndexing(app);
|
||||
return c.json(embeddingStatus(app));
|
||||
});
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue