First revision: DeepSeek, numeric questions, background assistant, UI fixes
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 1m2s

Providers and pricing
- Add a DeepSeek provider: thinking mode with low/high/max effort, reasoning_content
  replayed between tool steps, cache-hit usage, /models discovery and catalog prices.
- Fix "does not support tool calling": a rejected forced tool_choice (DeepSeek thinking
  mode) now asks for the call in the prompt; only a genuine no-tools 400 is "unsupported".
- Seven reasoning-effort levels (Off to Max) mapped per adapter.
- Cached-input price per model, cache-write and DeepSeek off-peak aware cost estimates.
- Built-in bge-small embedding model (transformers.js) as the semantic search default.

Quizzes
- Numeric (type-the-answer) questions: units ignored, optional ± tolerance; editor,
  runner, importer, templates and generation prompts.
- Quiz start screen instead of showing answers; navigator ring no longer clipped and
  key legend removed; clock only for timed exams; 7-point letter grades.

Assistant and generation
- Assistant turns run on the server independently of the browser, with re-attach and
  an explicit stop; drafts tray shows generations in progress.
- Per-chat model switcher, @-tagging of class materials, full-width assistant page and
  a smaller assistant button.
- Editable generation instructions and built-in presets, separate from the chatbot
  import instructions.

Other
- Dialog footer padding, keyboard hints removed, copy buttons work over plain HTTP,
  class and folder shares include documents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-15 12:48:17 -07:00
parent ccdad9728b
commit f0aabe4d5d
63 changed files with 3892 additions and 488 deletions

View file

@ -129,10 +129,28 @@ const GEMINI: Record<string, Entry> = {
'gemini-2.5-flash-lite': { label: 'Gemini 2.5 Flash-Lite', priceIn: 0.1, priceOut: 0.4, capabilities: GEMINI_CAPS },
};
/* ------------------------------------------------------------------ */
/* DeepSeek */
/* Prices and limits: https://api-docs.deepseek.com/quick_start/pricing (fetched 2026-11-15)
/* Peak-hour list prices are stored. Off-peak hours (everything outside 01:00-04:00 and
/* 06:00-10:00 UTC, Monday to Friday) cost half; `priceMultiplier` applies that per call.
/* deepseek-v4-flash / deepseek-v4-flash-vision-exp are retired aliases served by
/* deepseek-flash at the Flash price.
/* ------------------------------------------------------------------ */
const DS_LIMITS = { contextWindow: 1_048_576, maxOutput: 393_216 };
const DEEPSEEK: Record<string, Entry> = {
'deepseek-flash': { label: 'DeepSeek V4.1 Flash', ...DS_LIMITS, priceIn: 0.3, priceCachedIn: 0.006, priceOut: 1.2, capabilities: { tools: true, vision: true, pdf: false, reasoning: true, temperature: true } },
'deepseek-v4-flash': { label: 'DeepSeek V4 Flash (alias of Flash)', ...DS_LIMITS, priceIn: 0.3, priceCachedIn: 0.006, priceOut: 1.2, capabilities: { tools: true, vision: true, pdf: false, reasoning: true, temperature: true } },
'deepseek-v4-pro': { label: 'DeepSeek V4 Pro', ...DS_LIMITS, priceIn: 1.32, priceCachedIn: 0.044, priceOut: 3.96, capabilities: { tools: true, vision: false, pdf: false, reasoning: true, temperature: true } },
};
const TABLES: Record<ProviderKind, Record<string, Entry>> = {
openai: OPENAI,
anthropic: ANTHROPIC,
gemini: GEMINI,
deepseek: DEEPSEEK,
// Aggregators and local servers host arbitrary models at their own prices.
openai_compatible: {},
ollama: {},
@ -168,6 +186,7 @@ function lookupIn(table: Record<string, Entry>, id: string): Partial<DiscoveredM
// capabilities are a fair guess, the price is not.
delete out.priceIn;
delete out.priceOut;
delete out.priceCachedIn;
}
return out;
}
@ -185,11 +204,12 @@ export function lookupModelDefaults(kind: ProviderKind, modelId: string): Partia
// Routers name models "<vendor>/<model>" (`anthropic/claude-sonnet-5-5`).
// Borrow capabilities and limits from the vendor's table, never its prices.
const bare = id.slice(id.lastIndexOf('/') + 1).replace(/:[a-z]+$/, '');
for (const table of [OPENAI, ANTHROPIC, GEMINI]) {
for (const table of [OPENAI, ANTHROPIC, GEMINI, DEEPSEEK]) {
const hit = lookupIn(table, bare);
if (Object.keys(hit).length > 0) {
delete hit.priceIn;
delete hit.priceOut;
delete hit.priceCachedIn;
// Temperature limits are properties of the first-party APIs, not of the router.
if (hit.capabilities) delete hit.capabilities.temperature;
return hit;
@ -204,3 +224,51 @@ export function lookupModelDefaults(kind: ProviderKind, modelId: string): Partia
export function catalogModelIds(kind: ProviderKind): string[] {
return Object.keys(TABLES[kind]);
}
/**
* What a cache-hit input token costs when a model has no cached price of its own, as a
* fraction of the normal input price. These are the providers' published discounts for
* their current models: OpenAI GPT-5 and later, Claude cache reads and Gemini 2.5 and later
* all bill cached input at 10%. Older OpenAI models (GPT-4.1 25%, GPT-4o / o-series 50%)
* discount less. Servers behind the compatible adapter and Ollama have no known discount.
*/
export function cachedInputRatio(kind: ProviderKind, modelId: string): number {
const id = modelId.slice(modelId.lastIndexOf('/') + 1);
switch (kind) {
case 'openai':
if (/^gpt-4\.1/.test(id)) return 0.25;
if (/^(gpt-4o|o\d)/.test(id)) return 0.5;
return 0.1;
case 'anthropic':
case 'gemini':
return 0.1;
case 'deepseek':
return 0.02;
default:
return 1;
}
}
/** USD per million cached input tokens: the model's own price when set, otherwise the provider discount. */
export function cachedInputPrice(kind: ProviderKind, modelId: string, priceIn: number | null, priceCachedIn: number | null): number {
if (priceCachedIn !== null && priceCachedIn !== undefined) return priceCachedIn;
return (priceIn ?? 0) * cachedInputRatio(kind, modelId);
}
/** Cache writes: Claude bills writing the (5-minute) prompt cache at 1.25x the input price. */
export function cacheWriteRatio(kind: ProviderKind): number {
return kind === 'anthropic' ? 1.25 : 1;
}
/**
* Time-of-day pricing. DeepSeek charges half its list price outside peak hours
* (01:00-04:00 and 06:00-10:00 UTC, Monday to Friday).
*/
export function priceMultiplier(kind: ProviderKind, at: number = Date.now()): number {
if (kind !== 'deepseek') return 1;
const d = new Date(at);
const day = d.getUTCDay();
const hour = d.getUTCHours();
const peak = day >= 1 && day <= 5 && ((hour >= 1 && hour < 4) || (hour >= 6 && hour < 10));
return peak ? 1 : 0.5;
}