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
|
|
@ -16,7 +16,7 @@
|
|||
* numeric `thinkingBudget` on 2.5; an unsupported config is dropped and retried.
|
||||
* - A response can be blocked (`promptFeedback.blockReason`, finishReason SAFETY).
|
||||
*/
|
||||
import {
|
||||
import { type EmbedRequest, type EmbedResult,
|
||||
AIError,
|
||||
type ChatMessage,
|
||||
type ChatRequest,
|
||||
|
|
@ -296,6 +296,30 @@ async function* stream(cfg: ProviderConfig, req: ChatRequest): AsyncGenerator<St
|
|||
};
|
||||
}
|
||||
|
||||
async function embed(cfg: ProviderConfig, req: EmbedRequest): Promise<EmbedResult> {
|
||||
const name = req.model.startsWith('models/') ? req.model : `models/${req.model}`;
|
||||
const requests = req.inputs.map((text) => ({
|
||||
model: name,
|
||||
content: { parts: [{ text }] },
|
||||
taskType: req.purpose === 'query' ? 'RETRIEVAL_QUERY' : 'RETRIEVAL_DOCUMENT',
|
||||
...(req.dimensions ? { outputDimensionality: req.dimensions } : {}),
|
||||
}));
|
||||
const res = await requestJson<{ embeddings?: { values?: number[] }[] }>(`${root(cfg)}/v1beta/${name}:batchEmbedContents`, {
|
||||
...errorContext(cfg),
|
||||
headers: headers(cfg),
|
||||
body: { requests },
|
||||
signal: req.signal,
|
||||
firstByteTimeoutMs: 60_000,
|
||||
totalTimeoutMs: 120_000,
|
||||
});
|
||||
const vectors = (res.embeddings ?? []).map((e) => (Array.isArray(e.values) ? e.values.map(Number) : []));
|
||||
if (vectors.length !== req.inputs.length || vectors.some((v) => v.length === 0)) {
|
||||
throw new AIError('invalid_response', `${LABEL} returned ${vectors.length} embeddings for ${req.inputs.length} inputs.`);
|
||||
}
|
||||
// Gemini does not report token use for embeddings; estimate it for the usage log.
|
||||
return { vectors, inputTokens: Math.ceil(req.inputs.reduce((n, t) => n + t.length, 0) / 4) };
|
||||
}
|
||||
|
||||
async function listModels(cfg: ProviderConfig, signal?: AbortSignal, timeoutMs?: number): Promise<DiscoveredModel[]> {
|
||||
const found: DiscoveredModel[] = [];
|
||||
let pageToken = '';
|
||||
|
|
@ -338,5 +362,6 @@ export const geminiAdapter: ProviderAdapter = {
|
|||
},
|
||||
stream,
|
||||
listModels: (cfg, signal) => listModels(cfg, signal),
|
||||
embed,
|
||||
test,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue