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
|
|
@ -13,7 +13,7 @@
|
|||
* - reasoning text may arrive as `reasoning_content`, `reasoning` or `thinking`;
|
||||
* - the last chunk may lack a `finish_reason`.
|
||||
*/
|
||||
import {
|
||||
import { type EmbedRequest, type EmbedResult,
|
||||
AIError,
|
||||
type ChatMessage,
|
||||
type ChatRequest,
|
||||
|
|
@ -27,7 +27,7 @@ import {
|
|||
type StreamEvent,
|
||||
type TestResult,
|
||||
} from '../types.ts';
|
||||
import { dataUrl, isChatModelId, makeUsage, newToolCallId, num, parseArgsStrict, parseToolArguments, runTest, str, TEST_TIMEOUT_MS, withCatalogDefaults } from './common.ts';
|
||||
import { parseEmbeddings, dataUrl, isChatModelId, makeUsage, newToolCallId, num, parseArgsStrict, parseToolArguments, runTest, str, TEST_TIMEOUT_MS, withCatalogDefaults } from './common.ts';
|
||||
import { ensureOk, errorFromProvider, hostOf, httpRequest, isLocalUrl, isRecord, requestJson, sseJson, trimBaseUrl, type ErrorContext, type HttpResponse } from './http.ts';
|
||||
|
||||
type Json = Record<string, unknown>;
|
||||
|
|
@ -62,6 +62,8 @@ function userContent(parts: ContentPart[], caps: Partial<ModelCapabilities>): st
|
|||
else blocks.push({ type: 'image_url', image_url: { url: dataUrl(p.mime, p.data) } });
|
||||
} else if (p.type === 'file') {
|
||||
if (p.mime.startsWith('text/')) blocks.push({ type: 'text', text: Buffer.from(p.data, 'base64').toString('utf8') });
|
||||
// Chat Completions "file" parts (OpenAI, OpenRouter and others) for models marked as reading PDFs.
|
||||
else if (p.mime === 'application/pdf' && caps.pdf) blocks.push({ type: 'file', file: { filename: p.filename ?? 'document.pdf', file_data: dataUrl(p.mime, p.data) } });
|
||||
else blocks.push({ type: 'text', text: `[The file "${p.filename ?? 'attachment'}" was attached, but this model cannot read it directly.]` });
|
||||
}
|
||||
}
|
||||
|
|
@ -319,6 +321,14 @@ export async function listCompatModels(o: CompatOptions, signal?: AbortSignal, t
|
|||
return withCatalogDefaults(o.kind, found);
|
||||
}
|
||||
|
||||
/** OpenAI-style `/embeddings`, shared with Ollama's compatible endpoint. */
|
||||
export async function compatEmbed(o: CompatOptions, req: EmbedRequest): Promise<EmbedResult> {
|
||||
const body: Record<string, unknown> = { model: req.model, input: req.inputs, encoding_format: 'float' };
|
||||
if (req.dimensions && /text-embedding-3/.test(req.model)) body.dimensions = req.dimensions;
|
||||
const res = await requestJson(`${normalizeCompatBase(o.baseUrl)}/embeddings`, { ...errorContext(o), headers: authHeaders(o), body, signal: req.signal, firstByteTimeoutMs: 120_000, totalTimeoutMs: 300_000 });
|
||||
return parseEmbeddings(res, req.inputs.length, o.label);
|
||||
}
|
||||
|
||||
function options(cfg: ProviderConfig): CompatOptions {
|
||||
if (!cfg.baseUrl?.trim()) throw new AIError('not_configured', `Add the server URL for "${cfg.name}" in Settings.`);
|
||||
return { kind: 'openai_compatible', label: cfg.name || hostOf(cfg.baseUrl), baseUrl: cfg.baseUrl, apiKey: cfg.apiKey, headers: cfg.headers };
|
||||
|
|
@ -360,4 +370,5 @@ export const openaiCompatibleAdapter: ProviderAdapter = {
|
|||
stream: (cfg, req) => streamChatCompletions(options(cfg), req),
|
||||
listModels: (cfg, signal) => listCompatModels(options(cfg), signal),
|
||||
test,
|
||||
embed: (cfg, req) => compatEmbed(options(cfg), req),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue