feat(webui): improve model and provider settings UX (#6145)
* feat(webui): improve model and provider settings UX * refactor(webui): organize provider forms and model picker interactions * fix(webui): separate OAuth credentials from provider configuration * fix(webui): stabilize shared combobox navigation * refactor(config): store provider connections as sparse entries * fix(webui): preserve provider validation and isolate catalog tests * refactor(config): manage explicit provider connections * refactor(webui): decouple settings UX from provider removal * fix(webui): select current combobox options during rapid input * feat(webui): refine model preset and provider management * style(webui): refine preset footer actions * fix(webui): align model settings with responsive layout rules * refactor(webui): finalize preset dialogs and simplify provider state * fix(webui): keep fallback heading stable while sorting presets Animate card dimensions without changing layout height and keep the section heading outside sortable cards. Remove proxy normalization from this PR. * docs: update WebUI model and provider setup instructions * docs: start model setup from new preset * docs: remove duplicate WebUI model setup instructions
This commit is contained in:
1 parent
8080ea843a
commit
9261e731ce
88 files changed
+2854
-1734
No files matched your search
@@ -1071,9 +1071,11 @@ export async function fetchProviderModels(
|
||||
token: string,
|
||||
provider: string,
|
||||
base: string = "",
|
||||
options?: { refresh?: boolean },
|
||||
): Promise<ProviderModelsPayload> {
|
||||
const query = new URLSearchParams();
|
||||
query.set("provider", provider);
|
||||
if (options?.refresh) query.set("refresh", "1");
|
||||
return request<ProviderModelsPayload>(
|
||||
`${base}/api/settings/provider-models?${query}`,
|
||||
token,
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
export function formatContextWindow(tokens: number): string {
|
||||
if (tokens >= 1_000_000) {
|
||||
const value = tokens / 1_000_000;
|
||||
return `${Number.isInteger(value) ? value.toFixed(0) : value.toFixed(1)}M`;
|
||||
}
|
||||
if (tokens >= 1_000) {
|
||||
const value = tokens / 1_000;
|
||||
return `${Number.isInteger(value) ? value.toFixed(0) : value.toFixed(1)}K`;
|
||||
}
|
||||
return String(tokens);
|
||||
}
|
||||
|
||||
export function formatModelContextWindow(tokens: number): string {
|
||||
if (tokens === 65_536) return "64K";
|
||||
if (tokens === 262_144) return "256K";
|
||||
if (tokens === 1_048_576) return "1M";
|
||||
return formatContextWindow(tokens);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { Bot, Brain, Cloud, Cpu, Database, Gem, Grid3X3, Hexagon, Layers, Moon, Orbit, Search, Sparkles, Triangle, Waves, Zap, type LucideIcon } from "lucide-react";
|
||||
|
||||
export const PROVIDER_ICONS: Record<string, LucideIcon> = {
|
||||
custom: Hexagon,
|
||||
openrouter: Sparkles,
|
||||
orcarouter: Sparkles,
|
||||
skywork: Sparkles,
|
||||
aihubmix: Triangle,
|
||||
anthropic: Brain,
|
||||
openai: Bot,
|
||||
deepseek: Waves,
|
||||
zhipu: Grid3X3,
|
||||
dashscope: Cloud,
|
||||
modelscope: Layers,
|
||||
moonshot: Moon,
|
||||
minimax: Zap,
|
||||
minimax_anthropic: Brain,
|
||||
groq: Cpu,
|
||||
huggingface: Layers,
|
||||
gemini: Gem,
|
||||
mistral: Orbit,
|
||||
siliconflow: Layers,
|
||||
volcengine: Cloud,
|
||||
volcengine_coding_plan: Cloud,
|
||||
byteplus: Cloud,
|
||||
byteplus_coding_plan: Cloud,
|
||||
qianfan: Database,
|
||||
ant_ling: Sparkles,
|
||||
azure_openai: Cloud,
|
||||
bedrock: Database,
|
||||
bocha: Search,
|
||||
brave: Search,
|
||||
duckduckgo: Search,
|
||||
exa: Search,
|
||||
jina: Search,
|
||||
kagi: Search,
|
||||
olostep: Search,
|
||||
searxng: Search,
|
||||
tavily: Search,
|
||||
vllm: Cpu,
|
||||
ollama: Cpu,
|
||||
lm_studio: Cpu,
|
||||
atomic_chat: Cpu,
|
||||
ovms: Cpu,
|
||||
nvidia: Zap,
|
||||
};
|
||||
@@ -0,0 +1,79 @@
|
||||
import { fetchProviderModels } from "@/lib/api";
|
||||
import type { ProviderModelsPayload } from "@/lib/types";
|
||||
|
||||
interface CatalogSnapshot {
|
||||
payload: ProviderModelsPayload | null;
|
||||
pending: boolean;
|
||||
failed: boolean;
|
||||
}
|
||||
|
||||
export function isCatalogAvailable(payload: ProviderModelsPayload | null): boolean {
|
||||
return payload?.status === "available" && payload.error_kind !== "auth_required";
|
||||
}
|
||||
|
||||
function catalogFailed(payload: ProviderModelsPayload): boolean {
|
||||
return payload.status === "error" || Boolean(payload.error_kind)
|
||||
|| payload.source === "stale" || payload.source === "fallback";
|
||||
}
|
||||
|
||||
function createCatalog(token: string, provider: string) {
|
||||
let snapshot: CatalogSnapshot = { payload: null, pending: false, failed: false };
|
||||
let request: Promise<void> | null = null;
|
||||
const listeners = new Set<() => void>();
|
||||
const publish = () => listeners.forEach((listener) => listener());
|
||||
|
||||
const load = (refresh = false): Promise<void> => {
|
||||
if (request) return request;
|
||||
snapshot = { ...snapshot, pending: true };
|
||||
publish();
|
||||
request = fetchProviderModels(token, provider, "", { refresh })
|
||||
.then((payload) => {
|
||||
const retainCatalog = payload.status === "error"
|
||||
&& payload.error_kind !== "auth_required" && isCatalogAvailable(snapshot.payload);
|
||||
snapshot = {
|
||||
payload: retainCatalog ? snapshot.payload : payload,
|
||||
pending: true,
|
||||
failed: catalogFailed(payload),
|
||||
};
|
||||
}, () => {
|
||||
snapshot = { ...snapshot, failed: true };
|
||||
})
|
||||
.finally(() => {
|
||||
request = null;
|
||||
snapshot = { ...snapshot, pending: false };
|
||||
publish();
|
||||
});
|
||||
return request;
|
||||
};
|
||||
|
||||
return {
|
||||
getSnapshot: () => snapshot,
|
||||
subscribe: (listener: () => void) => {
|
||||
listeners.add(listener);
|
||||
return () => { listeners.delete(listener); };
|
||||
},
|
||||
load,
|
||||
};
|
||||
}
|
||||
|
||||
type Catalog = ReturnType<typeof createCatalog>;
|
||||
|
||||
// A full settings response replaces provider rows, including after logging back
|
||||
// into the same account. Usage updates retain them. Weak keys release catalogs
|
||||
// belonging to superseded configurations without persisting browser-side data.
|
||||
const catalogs = new WeakMap<object, Map<string, Catalog>>();
|
||||
|
||||
export function getProviderModelCatalog(revision: object, token: string, provider: string): Catalog {
|
||||
let entries = catalogs.get(revision);
|
||||
if (!entries) {
|
||||
entries = new Map();
|
||||
catalogs.set(revision, entries);
|
||||
}
|
||||
const key = JSON.stringify([token, provider]);
|
||||
let catalog = entries.get(key);
|
||||
if (!catalog) {
|
||||
catalog = createCatalog(token, provider);
|
||||
entries.set(key, catalog);
|
||||
}
|
||||
return catalog;
|
||||
}
|
||||
Reference in new issue
Block a user