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

@ -38,7 +38,7 @@ import {
type TestResult,
} from '../types.ts';
import { lookupModelDefaults } from './catalog.ts';
import { isChatModelId, makeUsage, num, parseArgsStrict, parseToolArguments, runTest, str, TEST_TIMEOUT_MS, withCatalogDefaults } from './common.ts';
import { isChatModelId, makeUsage, nearestEffort, num, parseArgsStrict, parseToolArguments, runTest, str, TEST_TIMEOUT_MS, withCatalogDefaults } from './common.ts';
import { ensureOk, errorFromProvider, httpRequest, isRecord, requestJson, sseJson, trimBaseUrl, type ErrorContext } from './http.ts';
type Json = Record<string, unknown>;
@ -120,7 +120,10 @@ export function claudeProfile(model: string): ClaudeProfile {
}
/** Thinking budgets for the legacy `budget_tokens` models. */
const LEGACY_BUDGET = { low: 2_048, medium: 8_192, high: 16_384 } as const;
const LEGACY_BUDGET = { minimal: 1_024, low: 2_048, medium: 8_192, high: 16_384, xhigh: 24_576, max: 32_000 } as const;
/** `output_config.effort` levels. "xhigh" exists on the newest models only; a rejection steps it down. */
const CLAUDE_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'] as const;
/* ------------------------------------------------------------------ */
/* Request building */
@ -133,6 +136,8 @@ interface BuildOptions {
useFallbacks: boolean;
eagerToolInput: boolean;
promptCache: boolean;
/** Highest effort level the model accepted, after a rejection. */
effortCap?: (typeof CLAUDE_EFFORTS)[number];
}
/** Tool-call ids must match ^[a-zA-Z0-9_-]+$; ids minted by other providers may not. */
@ -268,7 +273,7 @@ function buildBody(req: ChatRequest, profile: ClaudeProfile, opts: BuildOptions)
// `display: "summarized"` because these models hide the reasoning text by
// default, which would look like a long pause in the UI.
body.thinking = adaptive;
if (effort) outputConfig.effort = effort;
if (effort) outputConfig.effort = opts.effortCap ? nearestEffort(effort, CLAUDE_EFFORTS.filter((e) => CLAUDE_EFFORTS.indexOf(e) <= CLAUDE_EFFORTS.indexOf(opts.effortCap!))) : nearestEffort(effort, CLAUDE_EFFORTS);
} else if (effort) {
// Forced tool use cannot be combined with thinking on the older generations.
if (profile.thinking === 'opt_in' && !forcing) body.thinking = adaptive;
@ -276,7 +281,7 @@ function buildBody(req: ChatRequest, profile: ClaudeProfile, opts: BuildOptions)
const budget = Math.min(LEGACY_BUDGET[effort], maxTokens - 1_024); // must be < max_tokens, min 1024
if (budget >= 1_024) body.thinking = { type: 'enabled', budget_tokens: budget };
}
if (profile.effort) outputConfig.effort = effort;
if (profile.effort) outputConfig.effort = opts.effortCap ? nearestEffort(effort, CLAUDE_EFFORTS.filter((e) => CLAUDE_EFFORTS.indexOf(e) <= CLAUDE_EFFORTS.indexOf(opts.effortCap!))) : nearestEffort(effort, CLAUDE_EFFORTS);
}
if (Object.keys(outputConfig).length > 0) body.output_config = outputConfig;
}
@ -375,6 +380,7 @@ async function* stream(cfg: ProviderConfig, req: ChatRequest): AsyncGenerator<St
else if (opts.useFallbacks && /fallback|anthropic-beta/i.test(detail)) opts.useFallbacks = false;
else if (opts.eagerToolInput && /eager_input_streaming/i.test(detail)) opts.eagerToolInput = false;
else if (opts.promptCache && /cache_control/i.test(detail)) opts.promptCache = false;
else if (/effort/i.test(detail) && opts.effortCap !== 'medium' && req.reasoningEffort && req.reasoningEffort !== 'none') opts.effortCap = opts.effortCap === 'high' ? 'medium' : opts.effortCap === 'xhigh' ? 'high' : 'xhigh';
else throw err;
}
}