mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 04:09:53 +08:00
1247 lines
49 KiB
TypeScript
1247 lines
49 KiB
TypeScript
"use client";
|
|
|
|
import { scrollToSettingsElement } from "@/features/settings/navigation/settings-scroll";
|
|
import Tooltip from "@/shared/ui/Tooltip";
|
|
import { stageRegistryAction, type RegistryEdit } from "@/lib/provider-registry";
|
|
import { useEffect, useId, useRef, useState } from "react";
|
|
import Link from "next/link";
|
|
import { Check, Plus, SlidersHorizontal, Trash2 } from "lucide-react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { formatConfiguredProviderName } from "@/lib/provider-branding";
|
|
import ProviderIcon from "@/components/common/ProviderIcon";
|
|
import {
|
|
useSettings,
|
|
type CatalogModel,
|
|
type CatalogProfile,
|
|
type ServiceName,
|
|
} from "@/features/settings/store/SettingsStore";
|
|
import {
|
|
defaultModelFor,
|
|
flattenModels,
|
|
modelProvider,
|
|
providerAdapter,
|
|
providerIdentity,
|
|
providerProbeInput,
|
|
providerRegistry,
|
|
providerServiceSupport,
|
|
SERVICE_TITLES,
|
|
type ProviderSource,
|
|
} from "@/lib/provider-registry";
|
|
import { voiceModelOptions } from "@/lib/voice-settings";
|
|
import { BulkModelImport } from "./BulkModelImport";
|
|
import { VoiceDiscoveryField } from "./VoiceDiscoveryField";
|
|
import { VoiceModelFields } from "./VoiceModelFields";
|
|
import { VoicePreviewPanel } from "./VoicePreviewPanel";
|
|
import { ServicePreviewPanel } from "./ServicePreviewPanel";
|
|
import { ModelTestPanel } from "./ModelTestPanel";
|
|
import EmbeddingModelUsage from "./EmbeddingModelUsage";
|
|
import {
|
|
EditableRegistryName,
|
|
RegistryField,
|
|
RegistryModelIdField,
|
|
RegistryProbe,
|
|
registryButton,
|
|
registryDanger,
|
|
registryPrimary,
|
|
} from "./RegistryControls";
|
|
import { inputClass, selectClass, subPanelClass } from "./shared";
|
|
import {
|
|
WorkspaceDetailEmpty,
|
|
WorkspaceRail,
|
|
WorkspaceSplit,
|
|
workspaceCardClass,
|
|
} from "./WorkspaceShell";
|
|
|
|
import { randomUuid } from "@/lib/random-uuid";
|
|
type ModelPage = "llm" | "embedding" | "search" | "voice" | "multimodal";
|
|
const PAGE_SERVICES: Record<ModelPage, ServiceName[]> = {
|
|
llm: ["llm", "task"],
|
|
embedding: ["embedding"],
|
|
search: ["search"],
|
|
voice: ["tts", "stt"],
|
|
multimodal: ["imagegen", "videogen"],
|
|
};
|
|
export function ModelsWorkspace({
|
|
page,
|
|
initialService,
|
|
}: {
|
|
page: ModelPage;
|
|
initialService?: ServiceName;
|
|
}) {
|
|
const { t, i18n } = useTranslation();
|
|
const uiLanguage = i18n?.resolvedLanguage ?? i18n?.language ?? "en";
|
|
const {
|
|
draft,
|
|
providers,
|
|
connectionTargets,
|
|
catalogEditable,
|
|
mutateCatalog,
|
|
focusModel,
|
|
clearFocusModel,
|
|
} = useSettings();
|
|
const services = PAGE_SERVICES[page];
|
|
const rows = flattenModels(draft, services);
|
|
const editorRef = useRef<HTMLDivElement>(null);
|
|
const restoredPage = useRef<string | null>(null);
|
|
const [selected, setSelected] = useState<string | null>(null);
|
|
const [adding, setAdding] = useState(false);
|
|
const [newService, setNewService] = useState<ServiceName>(
|
|
initialService && services.includes(initialService) ? initialService : services[0],
|
|
);
|
|
const [newProvider, setNewProvider] = useState("");
|
|
const [newModelId, setNewModelId] = useState("");
|
|
const [query, setQuery] = useState("");
|
|
const [filter, setFilter] = useState("all");
|
|
// The add panel and the selected row are what the URL says they are, so a
|
|
// refresh cannot silently swap one surface for the other.
|
|
const syncQuery = (updates: Record<string, string | null>) => {
|
|
restoredPage.current = page;
|
|
const params = new URLSearchParams(window.location.search);
|
|
for (const [key, value] of Object.entries(updates)) {
|
|
if (value !== null) params.set(key, value);
|
|
else params.delete(key);
|
|
}
|
|
const query = params.toString();
|
|
window.history.replaceState(
|
|
null,
|
|
"",
|
|
`${window.location.pathname}${query ? `?${query}` : ""}`,
|
|
);
|
|
};
|
|
useEffect(() => {
|
|
if (restoredPage.current === page) return;
|
|
const params = new URLSearchParams(window.location.search);
|
|
if (params.get("add") === "1") {
|
|
setAdding(true);
|
|
const requested = params.get("service") as ServiceName | null;
|
|
const effective =
|
|
requested && services.includes(requested) ? requested : newService;
|
|
if (requested && services.includes(requested)) setNewService(requested);
|
|
const provider = params.get("provider");
|
|
const source = provider
|
|
? selectable.find((p) => p.id === provider)
|
|
: undefined;
|
|
// A provider may arrive after the initial empty catalog. Retry hydration
|
|
// until it exists, but never overwrite user edits after that point.
|
|
if (provider && !source) return;
|
|
setNewProvider(source?.id ?? "");
|
|
setNewModelId(
|
|
params.get("model") ??
|
|
(source ? defaultModelFor(source, effective, connectionTargets, providers) : ""),
|
|
);
|
|
restoredPage.current = page;
|
|
} else {
|
|
const profileId = params.get("profile");
|
|
if (!profileId) {
|
|
restoredPage.current = page;
|
|
return;
|
|
}
|
|
const modelId = params.get("model");
|
|
const match =
|
|
rows.find(
|
|
(r) =>
|
|
r.profile.id === profileId &&
|
|
(!modelId || r.model?.id === modelId),
|
|
) || rows.find((r) => r.profile.id === profileId);
|
|
if (match) {
|
|
setSelected(match.key);
|
|
restoredPage.current = page;
|
|
}
|
|
}
|
|
// Resolve old profile links after the settings payload arrives.
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [page, draft, providers, connectionTargets]);
|
|
// Apply refused a blank model and named it here, so the owning page opens
|
|
// that row even when the URL stays on the same route.
|
|
useEffect(() => {
|
|
if (!focusModel) return;
|
|
const match = rows.find(
|
|
(r) =>
|
|
r.profile.id === focusModel.profileId &&
|
|
r.model?.id === focusModel.modelId,
|
|
);
|
|
if (!match) return;
|
|
setSelected(match.key);
|
|
setAdding(false);
|
|
clearFocusModel();
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [focusModel, rows.length, clearFocusModel]);
|
|
// Below xl the detail pane sits under the rail, so anything that changes what
|
|
// it shows has to bring it into view.
|
|
const revealDetail = () => {
|
|
if (window.matchMedia("(max-width: 1279px)").matches)
|
|
requestAnimationFrame(() =>
|
|
scrollToSettingsElement(editorRef.current),
|
|
);
|
|
};
|
|
const selectModel = (key: string) => {
|
|
setSelected(key);
|
|
setAdding(false);
|
|
const row = rows.find((r) => r.key === key);
|
|
if (row)
|
|
syncQuery({
|
|
add: null,
|
|
service: null,
|
|
provider: null,
|
|
profile: row.profile.id,
|
|
model: row.model?.id ?? null,
|
|
});
|
|
revealDetail();
|
|
};
|
|
const selectedRow = rows.find((r) => r.key === selected);
|
|
// Providers and models can be created together in the same draft.
|
|
const sources = providerRegistry(draft);
|
|
const declared = (source: ProviderSource, service: ServiceName) =>
|
|
providerServiceSupport(source, service, connectionTargets, providers).enabled;
|
|
// Keep compatible custom connections available behind an explicit choice.
|
|
const selectable = sources.filter(
|
|
(source) => !("managed_by" in source.source && source.source.managed_by),
|
|
);
|
|
const chooseNewProvider = (id: string) => {
|
|
const source = id ? selectable.find((p) => p.id === id) : undefined;
|
|
const model = source
|
|
? defaultModelFor(source, newService, connectionTargets, providers)
|
|
: "";
|
|
setNewProvider(id);
|
|
setNewModelId(model);
|
|
syncQuery({ provider: id || null, model });
|
|
};
|
|
const addSource = selectable.find((p) => p.id === newProvider);
|
|
const addModelOptions = addSource
|
|
? [
|
|
...new Set(
|
|
[
|
|
defaultModelFor(
|
|
addSource,
|
|
newService,
|
|
connectionTargets,
|
|
providers,
|
|
),
|
|
...(addSource.source.discovery?.models ?? [])
|
|
.filter(
|
|
(item) =>
|
|
!item.services?.length ||
|
|
item.services.includes(
|
|
newService === "task" ? "llm" : newService,
|
|
),
|
|
)
|
|
.map((item) => item.id),
|
|
].filter(Boolean),
|
|
),
|
|
]
|
|
: [];
|
|
const start = () => {
|
|
setAdding(true);
|
|
revealDetail();
|
|
const preferred = new URLSearchParams(window.location.search).get(
|
|
"provider",
|
|
);
|
|
const source =
|
|
preferred && selectable.some((p) => p.id === preferred)
|
|
? selectable.find((p) => p.id === preferred)
|
|
: undefined;
|
|
setNewProvider(source?.id ?? "");
|
|
setNewModelId(
|
|
source
|
|
? defaultModelFor(source, newService, connectionTargets, providers)
|
|
: "",
|
|
);
|
|
syncQuery({
|
|
add: "1",
|
|
service: newService,
|
|
provider: source?.id ?? null,
|
|
profile: null,
|
|
model: null,
|
|
});
|
|
};
|
|
const cancelAdd = () => {
|
|
setAdding(false);
|
|
const row = rows.find((r) => r.key === selected);
|
|
syncQuery(
|
|
row
|
|
? {
|
|
add: null,
|
|
service: null,
|
|
provider: null,
|
|
profile: row.profile.id,
|
|
model: row.model?.id ?? null,
|
|
}
|
|
: {
|
|
add: null,
|
|
service: null,
|
|
provider: null,
|
|
profile: null,
|
|
model: null,
|
|
},
|
|
);
|
|
};
|
|
const create = (requested?: string[]) => {
|
|
const source = selectable.find((p) => p.id === newProvider);
|
|
if (!source) return;
|
|
const modelValue = newService === "search" ? "" : newModelId.trim();
|
|
if (!requested && newService !== "search" && !modelValue) return;
|
|
const existing = new Set(
|
|
flattenModels(draft, [newService])
|
|
.filter((row) => modelProvider(draft, row.service, row.profile, row.model)?.id === source.id)
|
|
.map((row) => row.model?.model),
|
|
);
|
|
const values = requested
|
|
? [...new Set(requested.map((id) => id.trim()).filter(Boolean))].filter((id) => !existing.has(id))
|
|
: [modelValue];
|
|
if (!values.length) return;
|
|
const entries = values.map((value) => ({
|
|
value,
|
|
profileId: `${newService}-profile-${randomUuid()}`,
|
|
modelId: `${newService}-model-${randomUuid()}`,
|
|
}));
|
|
const { profileId, modelId } = entries[0];
|
|
const ref = providerAdapter(
|
|
source,
|
|
newService,
|
|
connectionTargets,
|
|
providers,
|
|
);
|
|
const target = providers[newService]?.find((p) => p.value === ref.binding);
|
|
mutateCatalog((next) => {
|
|
for (const { value, profileId, modelId } of entries) {
|
|
const profile: CatalogProfile = {
|
|
id: profileId,
|
|
name: source.name,
|
|
binding: ref.binding,
|
|
provider: newService === "search" ? ref.binding : undefined,
|
|
provider_ref: ref,
|
|
api_key: "",
|
|
base_url: "",
|
|
api_version: "",
|
|
models:
|
|
newService === "search"
|
|
? []
|
|
: [
|
|
{
|
|
id: modelId,
|
|
model: value,
|
|
name: value,
|
|
provider_ref: ref,
|
|
...(newService === "tts"
|
|
? {
|
|
voice: "",
|
|
response_format:
|
|
voiceModelOptions(
|
|
target?.voice_options,
|
|
value,
|
|
)?.formats[0] || "mp3",
|
|
}
|
|
: {}),
|
|
},
|
|
],
|
|
};
|
|
if (newService === "search") profile.display_name = source.name;
|
|
next.services[newService].profiles.push(profile);
|
|
}
|
|
});
|
|
setSelected(
|
|
newService === "search"
|
|
? `${newService}:${profileId}`
|
|
: `${newService}:${profileId}:${modelId}`,
|
|
);
|
|
setAdding(false);
|
|
setNewModelId("");
|
|
setQuery("");
|
|
setFilter("all");
|
|
syncQuery({
|
|
add: null,
|
|
service: null,
|
|
provider: null,
|
|
profile: profileId,
|
|
model: newService === "search" ? null : modelId,
|
|
});
|
|
};
|
|
if (!catalogEditable)
|
|
return (
|
|
<p className="text-sm text-[var(--muted-foreground)]">
|
|
{t("Only administrators can manage models.")}
|
|
</p>
|
|
);
|
|
const filtered = rows.filter(
|
|
(row) =>
|
|
(filter === "all" || row.service === filter) &&
|
|
`${row.model?.name || row.profile.display_name || row.profile.name} ${row.model?.model || ""} ${modelProvider(draft, row.service, row.profile, row.model)?.name || ""}`
|
|
.toLowerCase()
|
|
.includes(query.toLowerCase()),
|
|
);
|
|
const addLabel = t(
|
|
page === "search" ? "Add search configuration" : "Add model",
|
|
);
|
|
return (
|
|
<div className="space-y-5">
|
|
{!sources.length && (
|
|
<div className="rounded-xl border border-[var(--border)] p-5 text-sm">
|
|
<p>{t("Add a provider before adding models.")}</p>
|
|
<Link
|
|
href="/settings/connections"
|
|
className="mt-3 inline-block underline underline-offset-4"
|
|
>
|
|
{t("Go to providers")}
|
|
</Link>
|
|
</div>
|
|
)}
|
|
<WorkspaceSplit
|
|
rail={
|
|
<WorkspaceRail
|
|
// The add action sits with the list it appends to. It used to head a
|
|
// description row above the split that only repeated the page
|
|
// description, costing a band of height and telling nobody anything.
|
|
action={
|
|
<button
|
|
type="button"
|
|
onClick={start}
|
|
className={`${registryButton} w-full py-2`}
|
|
>
|
|
<Plus size={14} />
|
|
{addLabel}
|
|
</button>
|
|
}
|
|
search={{
|
|
label: t(page === "search" ? "settings.serviceConfig.findSearch" : "Find model"),
|
|
value: query,
|
|
onChange: setQuery,
|
|
placeholder: t(page === "search" ? "settings.serviceConfig.findSearch" : "Search by model or provider"),
|
|
}}
|
|
filter={
|
|
page === "voice" || page === "multimodal" ? (
|
|
<select
|
|
aria-label={t("Filter model type")}
|
|
className={`${selectClass} py-1.5 text-[13px]`}
|
|
value={filter}
|
|
onChange={(e) => setFilter(e.target.value)}
|
|
>
|
|
<option value="all">{t("All model types")}</option>
|
|
{PAGE_SERVICES[page].map((s) => (
|
|
<option key={s} value={s}>
|
|
{t(SERVICE_TITLES[s])}
|
|
</option>
|
|
))}
|
|
</select>
|
|
) : undefined
|
|
}
|
|
empty={
|
|
filtered.length
|
|
? undefined
|
|
: rows.length
|
|
? t(page === "search" ? "settings.serviceConfig.noSearchMatch" : "No models match your search.")
|
|
: t(page === "search" ? "settings.serviceConfig.noSearch" : "No models configured yet.")
|
|
}
|
|
>
|
|
{filtered.map((row) => {
|
|
const provider = modelProvider(
|
|
draft,
|
|
row.service,
|
|
row.profile,
|
|
row.model,
|
|
);
|
|
const bucket = draft.services[row.service];
|
|
const isDefault =
|
|
bucket.active_profile_id === row.profile.id &&
|
|
(!row.model || bucket.active_model_id === row.model.id) &&
|
|
(row.service !== "task" ||
|
|
(bucket.mode !== "inherit" && bucket.mode !== "reference"));
|
|
const label =
|
|
row.model?.name ||
|
|
row.model?.model ||
|
|
row.profile.display_name ||
|
|
(row.model ? t("New model") : row.profile.name);
|
|
const providerName = provider ? formatConfiguredProviderName(provider.provider, provider.name, uiLanguage) : t("Provider unavailable");
|
|
const editing = !adding && row.key === selected;
|
|
return (
|
|
<button
|
|
key={row.key}
|
|
type="button"
|
|
aria-pressed={editing}
|
|
// The card leads with the model, because that is what you are
|
|
// looking for, but the accessible name keeps the provider
|
|
// first so the row still reads as "provider, model".
|
|
aria-label={`${providerName} ${label}${row.model?.model ? ` ${row.model.model}` : ""}`}
|
|
onClick={() => selectModel(row.key)}
|
|
className={workspaceCardClass(editing)}
|
|
>
|
|
<span className="flex items-center gap-2">
|
|
<ProviderIcon
|
|
provider={provider?.provider || "custom"}
|
|
size={15}
|
|
/>
|
|
<span className="min-w-0 flex-1 truncate text-[14px] font-medium">
|
|
{label}
|
|
</span>
|
|
{isDefault && (
|
|
<span
|
|
className="inline-flex shrink-0 items-center gap-0.5 text-[11px] text-[var(--primary)]"
|
|
>
|
|
<Check size={13} />
|
|
{t(row.service === "search" ? "settings.serviceConfig.defaultSearch" : "Default model")}
|
|
</span>
|
|
)}
|
|
</span>
|
|
<span className="mt-1 flex items-center gap-1.5 pl-[23px] text-[12px] text-[var(--muted-foreground)]">
|
|
<span className="max-w-[45%] truncate">{providerName}</span>
|
|
{row.model?.model && (
|
|
<>
|
|
<span aria-hidden>·</span>
|
|
<span className="truncate">{row.model.model}</span>
|
|
</>
|
|
)}
|
|
</span>
|
|
{(page === "voice" || page === "multimodal" || row.service === "task") && (
|
|
<span className="mt-1.5 ml-[23px] inline-flex rounded-md bg-[color-mix(in_srgb,var(--muted)_70%,transparent)] px-1.5 py-0.5 text-[11px] text-[var(--muted-foreground)]">
|
|
{t(SERVICE_TITLES[row.service])}
|
|
</span>
|
|
)}
|
|
</button>
|
|
);
|
|
})}
|
|
</WorkspaceRail>
|
|
}
|
|
detail={
|
|
<div ref={editorRef} className="min-w-0 scroll-mt-4">
|
|
{/* One configuring surface at a time. The add form used to open as a
|
|
band above the split while an existing model's editor kept
|
|
rendering below it, so two things claimed to be "currently
|
|
configuring". Cancel returns to whatever was open before. */}
|
|
{adding ? (
|
|
<AddModelPanel
|
|
page={page}
|
|
service={newService}
|
|
onService={(value) => {
|
|
setNewService(value);
|
|
setNewProvider("");
|
|
setNewModelId("");
|
|
syncQuery({ service: value, provider: null, model: null });
|
|
}}
|
|
provider={newProvider}
|
|
onProvider={chooseNewProvider}
|
|
modelId={newModelId}
|
|
onModelId={(value) => {
|
|
setNewModelId(value);
|
|
syncQuery({ model: value });
|
|
}}
|
|
modelOptions={addModelOptions}
|
|
sources={selectable}
|
|
declared={(source) => declared(source, newService)}
|
|
existingModels={flattenModels(draft, [newService])
|
|
.filter((row) => modelProvider(draft, row.service, row.profile, row.model)?.id === newProvider)
|
|
.map((row) => row.model?.model || "")}
|
|
onImport={create}
|
|
onCreate={() => create()}
|
|
onCancel={cancelAdd}
|
|
/>
|
|
) : selectedRow ? (
|
|
<ModelEditor
|
|
key={selectedRow.key}
|
|
row={selectedRow}
|
|
sources={selectable}
|
|
declared={(source) => declared(source, selectedRow.service)}
|
|
onRemoved={() => {
|
|
setSelected(null);
|
|
syncQuery({ profile: null, model: null });
|
|
}}
|
|
/>
|
|
) : (
|
|
<WorkspaceDetailEmpty
|
|
icon={<SlidersHorizontal size={17} />}
|
|
title={t("Nothing selected")}
|
|
hint={t(
|
|
page === "search" ? "settings.serviceConfig.selectSearch" : "Select a model to view its settings and connection test.",
|
|
)}
|
|
/>
|
|
)}
|
|
</div>
|
|
}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/** Group known adapters before explicitly requested custom connections. */
|
|
function ProviderOptions({
|
|
sources,
|
|
declared,
|
|
}: {
|
|
sources: ProviderSource[];
|
|
declared: (source: ProviderSource) => boolean;
|
|
}) {
|
|
const { t, i18n } = useTranslation();
|
|
const uiLanguage = i18n?.resolvedLanguage ?? i18n?.language ?? "en";
|
|
const option = (p: ProviderSource) => (
|
|
<option key={p.id} value={p.id}>
|
|
{formatConfiguredProviderName(p.provider, p.name, uiLanguage)}
|
|
</option>
|
|
);
|
|
const unverified = sources.filter((source) => !declared(source));
|
|
if (!unverified.length) return <>{sources.map(option)}</>;
|
|
const known = sources.filter(declared);
|
|
return (
|
|
<>
|
|
{known.length > 0 && (
|
|
<optgroup label={t("Supported for this model type")}>
|
|
{known.map(option)}
|
|
</optgroup>
|
|
)}
|
|
<optgroup label={t("Not on record — verify with the model test")}>
|
|
{unverified.map(option)}
|
|
</optgroup>
|
|
</>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* The add flow. It lives in the detail pane, opposite the list, because that is
|
|
* the one place on the page that means "what you are configuring right now" —
|
|
* and only one thing can be there at a time.
|
|
*/
|
|
function AddModelPanel({
|
|
page,
|
|
service,
|
|
onService,
|
|
provider,
|
|
onProvider,
|
|
modelId,
|
|
onModelId,
|
|
modelOptions,
|
|
sources,
|
|
declared,
|
|
onCreate,
|
|
onImport,
|
|
existingModels,
|
|
onCancel,
|
|
}: {
|
|
page: ModelPage;
|
|
service: ServiceName;
|
|
onService: (value: ServiceName) => void;
|
|
provider: string;
|
|
onProvider: (value: string) => void;
|
|
modelId: string;
|
|
onModelId: (value: string) => void;
|
|
modelOptions: string[];
|
|
sources: ProviderSource[];
|
|
declared: (source: ProviderSource) => boolean;
|
|
onCreate: () => void;
|
|
onImport: (models: string[]) => void;
|
|
existingModels: string[];
|
|
onCancel: () => void;
|
|
}) {
|
|
const { t } = useTranslation();
|
|
const [custom, setCustom] = useState(false);
|
|
const visible = sources.filter(source => declared(source) || (service !== "search" && custom && source.source.service_overrides?.[service === "task" ? "llm" : service]?.enabled !== false));
|
|
const title = t(
|
|
page === "search" ? "Add search configuration" : "Add model",
|
|
);
|
|
return (
|
|
<section aria-label={title} className={`min-w-0 p-5 ${subPanelClass}`}>
|
|
<div className="mb-4 flex flex-wrap items-center justify-between gap-3">
|
|
<h3 className="text-base font-semibold">{title}</h3>
|
|
<Link
|
|
href="/settings/connections"
|
|
className="shrink-0 text-[13px] text-[var(--muted-foreground)] underline underline-offset-4 transition-colors hover:text-[var(--foreground)]"
|
|
>
|
|
{t("Manage providers")}
|
|
</Link>
|
|
</div>
|
|
<div className="grid gap-4 sm:grid-cols-2">
|
|
{(page === "voice" || page === "multimodal") && (
|
|
<label className="space-y-1.5 text-[13px] font-medium">
|
|
<span className="block">{t("Model type")}</span>
|
|
<select
|
|
className={selectClass}
|
|
value={service}
|
|
onChange={(e) => onService(e.target.value as ServiceName)}
|
|
>
|
|
{PAGE_SERVICES[page].map((s) => (
|
|
<option key={s} value={s}>
|
|
{t(SERVICE_TITLES[s])}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</label>
|
|
)}
|
|
<label className="space-y-1.5 text-[13px] font-medium">
|
|
<span className="block">{t("Configured provider")}</span>
|
|
<select
|
|
aria-label={t("Configured provider")}
|
|
className={selectClass}
|
|
value={provider}
|
|
onChange={(e) => onProvider(e.target.value)}
|
|
>
|
|
<option value="">{t("Choose a provider")}</option>
|
|
<ProviderOptions sources={visible} declared={declared} />
|
|
</select>
|
|
</label>
|
|
</div>
|
|
{service !== "search" && sources.some(source => !declared(source)) && <label className="mt-3 flex items-center gap-2 text-[13px]">
|
|
<input type="checkbox" checked={custom} onChange={e => { setCustom(e.target.checked); onProvider(""); }} />
|
|
{t("settings.serviceConfig.custom")}
|
|
</label>}
|
|
{service !== "search" && visible.find((source) => source.id === provider) && (
|
|
<BulkModelImport
|
|
source={visible.find((source) => source.id === provider)!}
|
|
service={service}
|
|
existingModels={existingModels}
|
|
onImport={onImport}
|
|
/>
|
|
)}
|
|
{/* A model row cannot be created without an ID, so the field lives here
|
|
rather than only in the editor: the empty row used to reach the draft
|
|
and blocked Apply from a page that could not show it. */}
|
|
{service !== "search" && (
|
|
<div className="mt-4 max-w-md">
|
|
<RegistryModelIdField
|
|
label={t("Model ID")}
|
|
value={modelId}
|
|
options={modelOptions}
|
|
onChange={onModelId}
|
|
placeholder={t("Choose a listed model or enter a model ID")}
|
|
required
|
|
/>
|
|
{!modelId.trim() && (
|
|
<p className="mt-1.5 text-[13px] text-[var(--muted-foreground)]">
|
|
{t("Model ID is required.")}
|
|
</p>
|
|
)}
|
|
</div>
|
|
)}
|
|
<p className="mt-3 text-[13px] leading-relaxed text-[var(--muted-foreground)]">
|
|
{t(service === "search" ? "settings.serviceConfig.search" : service === "videogen" ? "settings.serviceConfig.video" : "settings.serviceConfig.providers")}
|
|
</p>
|
|
<div className="mt-5 flex flex-wrap items-center gap-2 border-t border-[color-mix(in_srgb,var(--border)_70%,transparent)] pt-4">
|
|
<button
|
|
type="button"
|
|
disabled={
|
|
!provider ||
|
|
!visible.some(source => source.id === provider) ||
|
|
(service !== "search" && !modelId.trim())
|
|
}
|
|
onClick={onCreate}
|
|
className={registryPrimary}
|
|
>
|
|
{t("Continue")}
|
|
</button>
|
|
<button type="button" onClick={onCancel} className={registryButton}>
|
|
{t("Cancel")}
|
|
</button>
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
type ModelRow = ReturnType<typeof flattenModels>[number];
|
|
function ModelEditor({
|
|
row,
|
|
sources,
|
|
declared,
|
|
onRemoved,
|
|
}: {
|
|
row: ModelRow;
|
|
sources: ProviderSource[];
|
|
declared: (source: ProviderSource) => boolean;
|
|
onRemoved: () => void;
|
|
}) {
|
|
const { t, i18n } = useTranslation();
|
|
const uiLanguage = i18n?.resolvedLanguage ?? i18n?.language ?? "en";
|
|
const [custom, setCustom] = useState(false);
|
|
const {
|
|
draft,
|
|
providers,
|
|
connectionTargets,
|
|
mutateCatalog,
|
|
applying,
|
|
} = useSettings();
|
|
const stageRegistry = async (edit: RegistryEdit) => {
|
|
mutateCatalog((next) => stageRegistryAction(next, edit));
|
|
return true;
|
|
};
|
|
const { service, profile, model } = row;
|
|
const provider = modelProvider(draft, service, profile, model);
|
|
const visible = sources.filter(source => declared(source) || source.id === provider?.id || (service !== "search" && custom && source.source.service_overrides?.[service === "task" ? "llm" : service]?.enabled !== false));
|
|
const speechProvider = (provider?.source.service_overrides?.[service]?.enabled && provider.source.service_overrides[service]?.binding) || model?.provider_ref?.binding || profile.provider_ref?.binding || provider?.provider || profile.binding || "custom";
|
|
const speechOptions = providers[service]?.find(p => p.value === speechProvider)?.voice_options;
|
|
const speechPreset = voiceModelOptions(speechOptions, model?.model ?? "");
|
|
const [listed, setListed] = useState<{
|
|
provider: string;
|
|
models: { id: string; services?: ServiceName[] }[];
|
|
} | null>(null);
|
|
const name = model
|
|
? model.name || model.model || t("New model")
|
|
: profile.display_name || profile.name;
|
|
const managed = Boolean(
|
|
model?.managed_by || profile.read_only || profile.managed_by,
|
|
);
|
|
// A blank ID cannot reach the provider; say so at the field instead of
|
|
// letting Apply fail from another page with no visible culprit.
|
|
const modelIdMissing = Boolean(model && !managed && !model.model.trim());
|
|
const saved = draft.services[service].profiles.find(
|
|
(p) => p.id === profile.id,
|
|
);
|
|
const savedModel =
|
|
service === "search"
|
|
? Boolean(saved && !saved.provider_only)
|
|
: saved?.models.some((m) => m.id === model?.id);
|
|
const active =
|
|
savedModel &&
|
|
draft.services[service].active_profile_id === profile.id &&
|
|
(!model || draft.services[service].active_model_id === model.id);
|
|
const task = draft.services.task;
|
|
const assignedToTask = Boolean(model && [task, ...Object.values(task.overrides ?? {})].some((choice) =>
|
|
(service === "llm" && choice.mode === "reference" && choice.selection?.profile_id === profile.id && choice.selection?.model_id === model.id) ||
|
|
(service === "task" && choice.mode === "profiles" && choice.active_profile_id === profile.id && choice.active_model_id === model.id)
|
|
));
|
|
const update = (field: keyof CatalogModel, value: unknown) =>
|
|
mutateCatalog((next) => {
|
|
const target = next.services[service].profiles
|
|
.find((p) => p.id === profile.id)
|
|
?.models.find((m) => m.id === model?.id);
|
|
if (!target) return;
|
|
if (field === "model" && (!target.name || target.name === target.model))
|
|
target.name = String(value);
|
|
if (field === "model" && (service === "tts" || service === "stt")) {
|
|
const before = voiceModelOptions(speechOptions, target.model);
|
|
const after = voiceModelOptions(speechOptions, String(value));
|
|
if (after && after !== speechOptions?.fallback) {
|
|
if (before?.formats.includes(target.response_format ?? "") && !after.formats.includes(target.response_format ?? ""))
|
|
target.response_format = after.formats[0] ?? "";
|
|
if (before?.languages.some(l => l.id === target.language) && !after.languages.some(l => l.id === target.language))
|
|
target.language = "";
|
|
if (!after.instructions) delete target.instructions;
|
|
if (!after.speed) delete target.speed;
|
|
}
|
|
}
|
|
Object.assign(target, { [field]: value });
|
|
if (field === "name" && managed) target.user_name = String(value);
|
|
if (field === "context_window") {
|
|
target.context_window_source = value ? "manual" : "default";
|
|
delete target.context_window_tokens;
|
|
delete target.context_window_detected_at;
|
|
}
|
|
});
|
|
const updateSearch = (field: string, value: unknown) =>
|
|
mutateCatalog((next) => {
|
|
const target = next.services.search.profiles.find(
|
|
(p) => p.id === profile.id,
|
|
);
|
|
if (target) Object.assign(target, { [field]: value });
|
|
});
|
|
const chooseProvider = (id: string) => {
|
|
const source = sources.find((p) => p.id === id);
|
|
if (!source) return;
|
|
const ref = providerAdapter(source, service, connectionTargets, providers);
|
|
if (model) update("provider_ref", ref);
|
|
else updateSearch("provider_ref", ref);
|
|
setListed(null);
|
|
};
|
|
const list = (listed && listed.provider === provider?.id
|
|
? listed.models : provider?.source.discovery?.models || [])
|
|
.filter(item => !item.services?.length || item.services.includes(service === "task" ? "llm" : service));
|
|
const remove = async () => {
|
|
await stageRegistry({ kind: "model", service, profile_id: profile.id, model_id: model?.id, delete: true });
|
|
onRemoved();
|
|
};
|
|
|
|
return (
|
|
<section
|
|
aria-label={t("Model settings")}
|
|
// `border-[var(--primary)]/35` compiled to no rule at all, so this pane
|
|
// was drawing preflight's default grey border and read as unstyled.
|
|
className="min-w-0 overflow-clip rounded-2xl border border-[color-mix(in_srgb,var(--primary)_35%,var(--border))]"
|
|
>
|
|
{/* Opaque on purpose: it stays put over the scrolling body. */}
|
|
<header className="sticky top-14 z-10 border-b border-[var(--border)] bg-[color-mix(in_srgb,var(--primary)_4%,var(--background))] px-4 py-5 sm:px-6 lg:top-0">
|
|
<div className="mb-2 flex flex-wrap items-center gap-2 text-[12px]">
|
|
<span className="font-medium text-[var(--primary)]">
|
|
{t("Currently configuring")}
|
|
</span>
|
|
<span className="text-[var(--muted-foreground)]">
|
|
{t(SERVICE_TITLES[service])}
|
|
</span>
|
|
{!savedModel && (
|
|
<span className="text-[var(--muted-foreground)]">
|
|
· {t("Not saved")}
|
|
</span>
|
|
)}
|
|
</div>
|
|
<EditableRegistryName
|
|
name={name}
|
|
label={t(service === "search" ? "settings.serviceConfig.renameSearch" : "Rename model")}
|
|
onChange={(value) =>
|
|
model ? update("name", value) : updateSearch("display_name", value)
|
|
}
|
|
/>
|
|
<div className="mt-2 flex items-center gap-2 text-[13px] text-[var(--muted-foreground)]">
|
|
<ProviderIcon provider={provider?.provider || "custom"} size={16} />
|
|
<span className="break-all">
|
|
{provider ? formatConfiguredProviderName(provider.provider, provider.name, uiLanguage) : t("Provider unavailable")}
|
|
</span>
|
|
</div>
|
|
{model?.model && (
|
|
<p className="mt-2 break-all font-mono text-[12px] text-[var(--muted-foreground)]">
|
|
{model.model}
|
|
</p>
|
|
)}
|
|
</header>
|
|
<div className="space-y-6 p-4 sm:p-6">
|
|
{service === "embedding" && model && <EmbeddingModelUsage key={JSON.stringify([profile.id, model.id])} profileId={profile.id} modelId={model.id} />}
|
|
<div className="grid gap-x-5 gap-y-4 lg:grid-cols-2">
|
|
<div className="space-y-2">
|
|
<label className="block space-y-1.5 text-[13px] font-medium">
|
|
<span className="block">{t("Configured provider")}</span>
|
|
<select
|
|
aria-label={t("Configured provider")}
|
|
className={selectClass}
|
|
disabled={managed}
|
|
value={provider?.id || ""}
|
|
onChange={(e) => chooseProvider(e.target.value)}
|
|
>
|
|
<option value="" disabled>
|
|
{t("Choose a provider")}
|
|
</option>
|
|
{provider && !sources.some((p) => p.id === provider.id) && (
|
|
<option value={provider.id}>{formatConfiguredProviderName(provider.provider, provider.name, uiLanguage)}</option>
|
|
)}
|
|
<ProviderOptions sources={visible} declared={declared} />
|
|
</select>
|
|
</label>
|
|
{service !== "search" && sources.some(source => !declared(source) && source.id !== provider?.id) && <label className="flex items-center gap-2 text-[13px]">
|
|
<input type="checkbox" checked={custom} disabled={managed} onChange={e => setCustom(e.target.checked)} />
|
|
{t("settings.serviceConfig.custom")}
|
|
</label>}
|
|
{/* Why the test below matters more here: nothing vouches for this
|
|
pairing yet, so say what request it will actually make. */}
|
|
{provider && !declared(provider) && (
|
|
<p className="text-[13px] leading-relaxed text-[var(--muted-foreground)]">
|
|
{t(
|
|
service === "search"
|
|
? "settings.serviceConfig.unsupportedSearch"
|
|
: service === "videogen" ? "settings.serviceConfig.video" : "settings.serviceConfig.providers",
|
|
)}
|
|
</p>
|
|
)}
|
|
<Link
|
|
href={`/settings/connections${provider ? `?provider=${encodeURIComponent(provider.id)}` : ""}`}
|
|
className="inline-block text-[13px] text-[var(--muted-foreground)] underline underline-offset-4 transition-colors hover:text-[var(--foreground)]"
|
|
>
|
|
{t("Manage provider connection")}
|
|
</Link>
|
|
</div>
|
|
{model && (
|
|
<div className="space-y-2">
|
|
<RegistryModelIdField
|
|
label={t(speechProvider === "volcengine_speech" && service === "tts" ? "Model / resource ID" : "Model ID")}
|
|
value={model.model}
|
|
options={[...new Set([...(speechOptions?.models.map(m => m.id) ?? []), ...list.map((item) => item.id)])]}
|
|
disabled={managed}
|
|
onChange={(value) => update("model", value)}
|
|
placeholder={t("Choose a listed model or enter a model ID")}
|
|
required={!managed}
|
|
invalid={modelIdMissing}
|
|
/>
|
|
<p className="text-[13px] leading-relaxed text-[var(--muted-foreground)]">
|
|
{t(
|
|
"The display name is used in chat. Double-click the name above or use the edit button to rename it.",
|
|
)}
|
|
</p>
|
|
</div>
|
|
)}
|
|
{service === "search" && (
|
|
<div className="space-y-2">
|
|
<RegistryField
|
|
label={t("Maximum results")}
|
|
type="number"
|
|
value={String(profile.max_results ?? 5)}
|
|
onChange={(value) =>
|
|
updateSearch(
|
|
"max_results",
|
|
Math.max(1, Math.min(10, Number(value) || 5)),
|
|
)
|
|
}
|
|
/>
|
|
<p className="text-[13px] leading-relaxed text-[var(--muted-foreground)]">
|
|
{t(
|
|
"Search APIs use an engine configuration rather than a model ID or context window.",
|
|
)}
|
|
</p>
|
|
</div>
|
|
)}
|
|
</div>
|
|
{model && provider && !managed && service !== "search" && (
|
|
<details open={service === "llm" || service === "task" || service === "embedding"}>
|
|
<summary className="mb-3 cursor-pointer text-[13px] text-[var(--muted-foreground)]">{t("settings.serviceConfig.discovery")}</summary>
|
|
<RegistryProbe
|
|
input={providerProbeInput(
|
|
provider,
|
|
providers[provider.service || "llm"]?.find(
|
|
(p) => p.value === provider.provider,
|
|
)?.base_url ||
|
|
providers[service]?.find((p) => p.value === provider.provider)
|
|
?.base_url,
|
|
)}
|
|
discovery={provider.source.discovery}
|
|
listing
|
|
onResult={(result) =>
|
|
setListed({ provider: provider.id, models: result.models })
|
|
}
|
|
/>
|
|
</details>
|
|
)}
|
|
{service === "tts" && model && <VoiceDiscoveryField profileId={profile.id} modelId={model.id} value={model.voice || ""} update={value => update("voice", value)} disabled={managed} />}
|
|
{model && (service === "tts" || service === "stt") ? (
|
|
<VoiceModelFields service={service} provider={speechProvider} model={model}
|
|
options={speechOptions} preset={speechPreset} update={update} disabled={managed} />
|
|
) : model && <ModelParameters service={service} model={model} update={update} managed={managed} />}
|
|
{service === "tts" && model ? <VoicePreviewPanel profileId={profile.id} modelId={model.id} maxChars={Math.min(500, speechPreset?.max_input_chars ?? 500)} /> : (service === "search" || service === "stt" || service === "imagegen" || service === "videogen") ? <ServicePreviewPanel service={service} profile={profile} model={model} /> : <ModelTestPanel service={service} profile={profile} model={model} />}
|
|
{(service === "search" || service === "imagegen" || service === "videogen") && <p className="text-[13px] leading-relaxed text-[var(--muted-foreground)]">
|
|
{t("settings.serviceConfig.tools")} {" "}
|
|
<Link href="/settings/tools" className="underline underline-offset-4">{t("settings.serviceConfig.openTools")}</Link>
|
|
</p>}
|
|
<div className="flex flex-wrap items-center gap-2 border-t border-[var(--border)] pt-4">
|
|
|
|
<button
|
|
type="button"
|
|
disabled={applying || !savedModel || Boolean(active) || modelIdMissing}
|
|
onClick={() =>
|
|
void stageRegistry({
|
|
kind: "default",
|
|
service,
|
|
profile_id: profile.id,
|
|
model_id: model?.id,
|
|
})
|
|
}
|
|
className={registryButton}
|
|
>
|
|
{active && <Check size={13} />}{" "}
|
|
{t(active ? (service === "search" ? "settings.serviceConfig.defaultSearch" : "Default model") : "Set as default")}
|
|
</button>
|
|
<Tooltip label={assignedToTask ? t("Choose another background task model before removing this model.") : t(service === "search" ? "settings.serviceConfig.removeSearch" : "Remove model")} side="top">
|
|
<button
|
|
type="button"
|
|
aria-label={t(service === "search" ? "settings.serviceConfig.removeSearch" : "Remove model")}
|
|
disabled={applying || managed || assignedToTask}
|
|
onClick={() => void remove()}
|
|
className={`${registryDanger} ml-auto`}
|
|
>
|
|
<Trash2 size={14} />
|
|
</button>
|
|
</Tooltip>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
function ModelParameters({
|
|
service,
|
|
model,
|
|
update,
|
|
managed,
|
|
}: {
|
|
service: ServiceName;
|
|
model: CatalogModel;
|
|
update: (field: keyof CatalogModel, value: unknown) => void;
|
|
managed: boolean;
|
|
}) {
|
|
const { t } = useTranslation();
|
|
const contextId = useId();
|
|
const language = service === "llm" || service === "task";
|
|
const fields: [keyof CatalogModel, string][] =
|
|
service === "embedding"
|
|
? [
|
|
["dimension", "Dimensions"],
|
|
["supported_dimensions", "Supported dimensions"],
|
|
]
|
|
: service === "tts"
|
|
? [
|
|
["voice", "Voice"],
|
|
["response_format", "Response format"],
|
|
]
|
|
: service === "stt"
|
|
? [["language", "Language"]]
|
|
: service === "imagegen"
|
|
? [
|
|
["size", "Image size"],
|
|
["quality", "Quality"],
|
|
["style", "Style"],
|
|
["response_format", "Response format"],
|
|
]
|
|
: service === "videogen"
|
|
? [
|
|
["aspect_ratio", "Aspect ratio"],
|
|
["duration", "Duration (seconds)"],
|
|
["resolution", "Resolution"],
|
|
]
|
|
: [];
|
|
return (
|
|
<div className="space-y-4">
|
|
{language && (
|
|
<div className="space-y-4">
|
|
{/* Two knobs of the same kind, so they sit side by side instead of
|
|
stacking into one more column of full-width inputs. */}
|
|
<div className="grid gap-x-5 gap-y-4 lg:grid-cols-2">
|
|
<div className="space-y-2">
|
|
{/* The heading *is* this field's label. It used to sit above a
|
|
second one that said the same thing, which read as a repeat
|
|
and — the visible part — pushed this input a whole label row
|
|
below the select beside it, so the pair never lined up. */}
|
|
<div className="space-y-1.5">
|
|
<div className="flex min-h-5 flex-wrap items-center justify-between gap-2">
|
|
<label htmlFor={contextId} className="text-[13px] font-medium">
|
|
{t("Context length (tokens)")}
|
|
</label>
|
|
<button
|
|
type="button"
|
|
onClick={() => update("context_window", "")}
|
|
disabled={
|
|
managed ||
|
|
!(model.context_window || model.context_window_tokens)
|
|
}
|
|
className="rounded text-[13px] text-[var(--muted-foreground)] underline underline-offset-4 transition-colors hover:text-[var(--foreground)] disabled:opacity-40 disabled:hover:text-[var(--muted-foreground)]"
|
|
>
|
|
{t("Use default")}
|
|
</button>
|
|
</div>
|
|
<input
|
|
id={contextId}
|
|
type="number"
|
|
className={inputClass}
|
|
value={
|
|
model.context_window ??
|
|
String(model.context_window_tokens || "")
|
|
}
|
|
disabled={managed}
|
|
onChange={(e) => update("context_window", e.target.value)}
|
|
placeholder={t("Default")}
|
|
/>
|
|
</div>
|
|
<p className="text-[13px] leading-relaxed text-[var(--muted-foreground)]">
|
|
{t(
|
|
"Keep the default, enter a custom value, or use the detected value after testing. Testing does not overwrite your choice.",
|
|
)}
|
|
</p>
|
|
</div>
|
|
<div className="space-y-1.5">
|
|
<p className="flex min-h-5 items-center text-[13px] font-medium">
|
|
{t("Reasoning effort")}
|
|
</p>
|
|
<select
|
|
aria-label={t("Reasoning effort")}
|
|
className={selectClass}
|
|
value={model.reasoning_effort || ""}
|
|
onChange={(e) => update("reasoning_effort", e.target.value)}
|
|
>
|
|
<option value="">{t("Default")}</option>
|
|
{[
|
|
...new Set([
|
|
...(model.codex_supported_reasoning_levels || [
|
|
"none",
|
|
"minimal",
|
|
"low",
|
|
"medium",
|
|
"high",
|
|
"xhigh",
|
|
"max",
|
|
]),
|
|
...(model.reasoning_effort ? [model.reasoning_effort] : []),
|
|
]),
|
|
].map((v) => (
|
|
<option key={v} value={v}>
|
|
{v}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<details className={`p-3.5 ${subPanelClass}`}>
|
|
<summary className="cursor-pointer select-none rounded text-[13px] font-medium marker:text-[var(--muted-foreground)]">
|
|
{t("Model capabilities")}
|
|
</summary>
|
|
<div className="mt-3 grid gap-3 sm:grid-cols-2">
|
|
{(["tools", "vision", "json_output", "reasoning"] as const).map(
|
|
(key) => (
|
|
<label key={key} className="space-y-1.5 text-[13px]">
|
|
<span className="block">
|
|
{t(
|
|
{
|
|
tools: "Tool calling",
|
|
vision: "Vision",
|
|
json_output: "JSON output",
|
|
reasoning: "Reasoning",
|
|
}[key],
|
|
)}
|
|
</span>
|
|
<select
|
|
className={selectClass}
|
|
disabled={managed}
|
|
value={
|
|
model.capabilities?.[key] === undefined
|
|
? "auto"
|
|
: String(model.capabilities[key])
|
|
}
|
|
onChange={(e) => {
|
|
const capabilities = { ...model.capabilities };
|
|
if (e.target.value === "auto") delete capabilities[key];
|
|
else capabilities[key] = e.target.value === "true";
|
|
update("capabilities", capabilities);
|
|
}}
|
|
>
|
|
<option value="auto">{t("Auto")}</option>
|
|
<option value="true">{t("Supported")}</option>
|
|
<option value="false">{t("Not supported")}</option>
|
|
</select>
|
|
</label>
|
|
),
|
|
)}
|
|
</div>
|
|
</details>
|
|
</div>
|
|
)}
|
|
{!!fields.length && (
|
|
<div className="grid gap-4 sm:grid-cols-2">
|
|
{fields.map(([field, label]) => (
|
|
<RegistryField
|
|
key={field}
|
|
label={t(label)}
|
|
value={String(model[field] ?? "")}
|
|
onChange={(v) => update(field, v)}
|
|
placeholder={t("Default")}
|
|
/>
|
|
))}
|
|
</div>
|
|
)}
|
|
{service === "embedding" && (
|
|
<label className="block space-y-1.5 text-[13px] font-medium">
|
|
<span className="block">{t("Send dimensions in embedding requests")}</span>
|
|
<select
|
|
className={selectClass}
|
|
value={
|
|
typeof model.send_dimensions === "boolean"
|
|
? String(model.send_dimensions)
|
|
: "auto"
|
|
}
|
|
onChange={(e) =>
|
|
update(
|
|
"send_dimensions",
|
|
e.target.value === "auto" ? null : e.target.value === "true",
|
|
)
|
|
}
|
|
>
|
|
<option value="auto">{t("Auto")}</option>
|
|
<option value="true">{t("Enabled")}</option>
|
|
<option value="false">{t("Disabled")}</option>
|
|
</select>
|
|
</label>
|
|
)}
|
|
{managed && (
|
|
<p className="text-[13px] text-[var(--muted-foreground)]">
|
|
{t(
|
|
"This signed-in provider manages model IDs, context, and capabilities. You can rename the model and choose its reasoning effort.",
|
|
)}
|
|
</p>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|