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
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:
parent
ccdad9728b
commit
f0aabe4d5d
63 changed files with 3892 additions and 488 deletions
|
|
@ -5,7 +5,7 @@ import { toast } from 'sonner';
|
|||
import { api, errorMessage } from '@/lib/api';
|
||||
import { qk } from '@/lib/queries';
|
||||
import { SemanticSettings } from './SemanticSettings';
|
||||
import type { AdapterMeta, AiModel, AiStatus, Provider, ProviderKind, TaskConfig, TaskName, TaskSettings } from '@/lib/types';
|
||||
import { REASONING_EFFORTS, type AdapterMeta, type AiModel, type AiStatus, type Provider, type ProviderKind, type TaskConfig, type TaskName, type TaskSettings } from '@/lib/types';
|
||||
import { cx, formatCost, formatTokens, plural, timeAgo } from '@/lib/util';
|
||||
import { Badge, Button, Callout, Dialog, EmptyState, Field, IconButton, Input, Menu, MenuItem, MenuSeparator, Section, Select, Skeleton, Switch, Textarea, Tooltip, useConfirm } from '@/ui';
|
||||
|
||||
|
|
@ -19,6 +19,7 @@ const KIND_BLURB: Record<ProviderKind, string> = {
|
|||
openai: 'GPT models with an OpenAI API key.',
|
||||
anthropic: 'Claude models with an Anthropic API key.',
|
||||
gemini: 'Gemini models with a Google AI Studio key.',
|
||||
deepseek: 'DeepSeek Flash and Pro with a DeepSeek platform key.',
|
||||
openai_compatible: 'OpenRouter, Groq, Together, LM Studio, vLLM and other compatible servers.',
|
||||
ollama: 'Models running on your own machine or server.',
|
||||
};
|
||||
|
|
@ -182,6 +183,34 @@ function ProviderDialog({ open, onClose, adapters, existing, onSaved }: { open:
|
|||
|
||||
/* ------------------------------ model dialog ------------------------------ */
|
||||
|
||||
/** The discount a provider gives on cached input when a model has no cached price of its own (mirrors the server). */
|
||||
const CACHE_HINT: Record<ProviderKind, string> = {
|
||||
openai: "OpenAI's discount (90% off for GPT-5 and later)",
|
||||
anthropic: "Claude's cache-read rate (10% of input)",
|
||||
gemini: "Gemini's cache rate (10% of input)",
|
||||
deepseek: "DeepSeek's cache-hit rate",
|
||||
openai_compatible: 'the normal input price',
|
||||
ollama: 'the normal input price',
|
||||
};
|
||||
|
||||
function cachedGuess(model: AiModel): string {
|
||||
const id = model.model.slice(model.model.lastIndexOf('/') + 1);
|
||||
const ratio =
|
||||
model.providerKind === 'openai'
|
||||
? /^gpt-4\.1/.test(id)
|
||||
? 0.25
|
||||
: /^(gpt-4o|o\d)/.test(id)
|
||||
? 0.5
|
||||
: 0.1
|
||||
: model.providerKind === 'anthropic' || model.providerKind === 'gemini'
|
||||
? 0.1
|
||||
: model.providerKind === 'deepseek'
|
||||
? 0.02
|
||||
: 1;
|
||||
const v = (model.priceIn ?? 0) * ratio;
|
||||
return `$${v < 0.01 ? v.toFixed(4) : v.toFixed(3)}`;
|
||||
}
|
||||
|
||||
function ModelDialog({ model, onClose, onSaved }: { model: AiModel | null; onClose: () => void; onSaved: () => void }) {
|
||||
const [label, setLabel] = useState('');
|
||||
const [caps, setCaps] = useState(model?.capabilities ?? { tools: true, vision: false, pdf: false, reasoning: false, temperature: true });
|
||||
|
|
@ -189,6 +218,7 @@ function ModelDialog({ model, onClose, onSaved }: { model: AiModel | null; onClo
|
|||
const [maxOut, setMaxOut] = useState('');
|
||||
const [priceIn, setPriceIn] = useState('');
|
||||
const [priceOut, setPriceOut] = useState('');
|
||||
const [priceCached, setPriceCached] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
useEffect(() => {
|
||||
if (!model) return;
|
||||
|
|
@ -198,13 +228,14 @@ function ModelDialog({ model, onClose, onSaved }: { model: AiModel | null; onClo
|
|||
setMaxOut(model.maxOutput?.toString() ?? '');
|
||||
setPriceIn(model.priceIn?.toString() ?? '');
|
||||
setPriceOut(model.priceOut?.toString() ?? '');
|
||||
setPriceCached(model.priceCachedIn?.toString() ?? '');
|
||||
}, [model]);
|
||||
const num = (s: string) => (s.trim() === '' ? null : Number(s));
|
||||
const save = async () => {
|
||||
if (!model) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
await api.patch(`/api/ai/models/${model.id}`, { label, capabilities: caps, contextWindow: num(ctx), maxOutput: num(maxOut), priceIn: num(priceIn), priceOut: num(priceOut) });
|
||||
await api.patch(`/api/ai/models/${model.id}`, { label, capabilities: caps, contextWindow: num(ctx), maxOutput: num(maxOut), priceIn: num(priceIn), priceOut: num(priceOut), priceCachedIn: num(priceCached) });
|
||||
onSaved();
|
||||
onClose();
|
||||
} catch (e) {
|
||||
|
|
@ -254,6 +285,9 @@ function ModelDialog({ model, onClose, onSaved }: { model: AiModel | null; onClo
|
|||
<Field label="Output price" hint="USD per million tokens">
|
||||
<Input type="number" min={0} step="0.01" value={priceOut} onChange={(e) => setPriceOut(e.target.value)} placeholder="Unknown" />
|
||||
</Field>
|
||||
<Field label="Cached input price" hint={`USD per million cached (cache-hit) input tokens. Blank uses ${model ? CACHE_HINT[model.providerKind] : 'the provider discount'}.`} className="col-span-2">
|
||||
<Input type="number" min={0} step="0.001" value={priceCached} onChange={(e) => setPriceCached(e.target.value)} placeholder={model?.priceIn != null ? `About ${cachedGuess(model)}` : 'Unknown'} />
|
||||
</Field>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
|
|
@ -495,10 +529,11 @@ function TaskRow({ name, label, description, config, models, resolved, onChange
|
|||
<Field label="Reasoning effort" hint={model && !model.capabilities.reasoning ? 'Not supported by this model' : undefined}>
|
||||
<Select value={config.reasoningEffort ?? ''} onChange={(e) => onChange({ ...config, reasoningEffort: (e.target.value || null) as TaskConfig['reasoningEffort'] })}>
|
||||
<option value="">Model default</option>
|
||||
<option value="none">Off / minimal</option>
|
||||
<option value="low">Low</option>
|
||||
<option value="medium">Medium</option>
|
||||
<option value="high">High</option>
|
||||
{REASONING_EFFORTS.map((e) => (
|
||||
<option key={e.value} value={e.value}>
|
||||
{e.label}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</Field>
|
||||
<Field label="Temperature" hint={model && !model.capabilities.temperature ? 'Ignored by this model' : '0 to 2'}>
|
||||
|
|
@ -536,13 +571,14 @@ function Usage() {
|
|||
<div className="card px-4 py-5 text-sm text-ink-2">No AI requests in this period.</div>
|
||||
) : (
|
||||
<div className="card overflow-hidden">
|
||||
<div className="grid grid-cols-3 divide-x divide-line border-b border-line">
|
||||
<div className="grid grid-cols-2 gap-px border-b border-line bg-line sm:grid-cols-4">
|
||||
{[
|
||||
['Estimated cost', formatCost(u.total.cost)],
|
||||
['Requests', u.total.calls.toLocaleString()],
|
||||
['Tokens in / out', `${formatTokens(u.total.input)} / ${formatTokens(u.total.output)}`],
|
||||
['Cached input', u.total.input ? `${formatTokens(u.total.cached)} (${Math.round((u.total.cached / u.total.input) * 100)}%)` : '0'],
|
||||
].map(([k, v]) => (
|
||||
<div key={k} className="px-4 py-3">
|
||||
<div key={k} className="bg-surface px-4 py-3">
|
||||
<div className="eyebrow">{k}</div>
|
||||
<div className="num mt-1 text-lg font-semibold">{v}</div>
|
||||
</div>
|
||||
|
|
@ -555,6 +591,7 @@ function Usage() {
|
|||
<th className="px-4 py-2 font-medium">Model</th>
|
||||
<th className="px-3 py-2 text-right font-medium">Requests</th>
|
||||
<th className="px-3 py-2 text-right font-medium">In</th>
|
||||
<th className="px-3 py-2 text-right font-medium">Cached</th>
|
||||
<th className="px-3 py-2 text-right font-medium">Out</th>
|
||||
<th className="px-4 py-2 text-right font-medium">Cost</th>
|
||||
</tr>
|
||||
|
|
@ -571,6 +608,7 @@ function Usage() {
|
|||
</td>
|
||||
<td className="num px-3 py-2 text-right">{m.calls}</td>
|
||||
<td className="num px-3 py-2 text-right">{formatTokens(m.input)}</td>
|
||||
<td className="num px-3 py-2 text-right">{formatTokens(m.cached)}</td>
|
||||
<td className="num px-3 py-2 text-right">{formatTokens(m.output)}</td>
|
||||
<td className="num px-4 py-2 text-right">{m.unpriced > 0 && !m.cost ? 'no price set' : formatCost(m.cost)}</td>
|
||||
</tr>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue