feat(webui): explain API settings on hover
This commit is contained in:
1 parent
9aff0787ff
commit
87a1e36833
14 files changed
+84
-6
No files matched your search
@@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { modelAPIConfigurable, preferredModelAPI, REQUEST_API_LABELS } from "@/components/settings/models/modelAPI";
|
||||
import { ToggleButton } from "@/components/settings/ToggleButton";
|
||||
import { SettingsRow } from "@/components/settings/shared/SettingsControls";
|
||||
import { SettingsHint } from "@/components/settings/shared/SettingsHint";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { ModelAPIConfig, ProviderRequestAPI, SettingsPayload } from "@/lib/types";
|
||||
@@ -12,12 +13,14 @@ export function ModelAPIControl({
|
||||
provider,
|
||||
automaticAPI,
|
||||
title,
|
||||
description,
|
||||
value,
|
||||
onChange,
|
||||
}: {
|
||||
provider: SettingsPayload["providers"][number] | undefined;
|
||||
automaticAPI?: ProviderRequestAPI;
|
||||
title?: string;
|
||||
description?: string;
|
||||
value: ModelAPIConfig | null;
|
||||
onChange: (api: ModelAPIConfig | null) => void;
|
||||
}) {
|
||||
@@ -50,7 +53,12 @@ export function ModelAPIControl({
|
||||
|
||||
return (
|
||||
<div>
|
||||
<SettingsRow title={controlTitle}>
|
||||
<SettingsRow
|
||||
title={controlTitle}
|
||||
description={description ?? (configurable
|
||||
? t("settings.models.requestAPIDescription")
|
||||
: t("settings.models.fixedAPIDescription", { api: fixedLabel }))}
|
||||
>
|
||||
{configurable ? (
|
||||
<Select value={selectedAPI} onValueChange={(api) => {
|
||||
if (api === selectedAPI) return;
|
||||
@@ -86,7 +94,11 @@ export function ModelAPIControl({
|
||||
{configurable && selectedAPI === "responses" && (!requestAPIs || requestAPIs.includes("chat_completions")) ? (
|
||||
<div className="mx-4 mb-3 flex items-start justify-between gap-4 rounded-xl bg-muted/30 px-3 py-3 sm:mx-5">
|
||||
<div className="min-w-0">
|
||||
<p className="text-[13px] leading-5 text-foreground">{t("settings.models.apiFallback")}</p>
|
||||
<p className="text-[13px] leading-5 text-foreground">
|
||||
<SettingsHint description={t("settings.models.apiFallbackDescription")}>
|
||||
{t("settings.models.apiFallback")}
|
||||
</SettingsHint>
|
||||
</p>
|
||||
</div>
|
||||
<div className="pt-0.5">
|
||||
<ToggleButton
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useTranslation } from "react-i18next";
|
||||
|
||||
import { MODEL_REQUEST_APIS, REQUEST_API_LABELS } from "@/components/settings/models/modelAPI";
|
||||
import { ToggleButton } from "@/components/settings/ToggleButton";
|
||||
import { SettingsHint } from "@/components/settings/shared/SettingsHint";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import type { ModelAPIConfig, ModelRequestAPI } from "@/lib/types";
|
||||
@@ -26,7 +27,9 @@ export function ProviderAPIControl({ value, onChange }: {
|
||||
<div className="space-y-3">
|
||||
<fieldset className="space-y-3 rounded-xl border border-border/60 p-3">
|
||||
<legend className="px-1 text-[12px] font-medium text-muted-foreground">
|
||||
{t("settings.providers.supportedAPIs")}
|
||||
<SettingsHint description={t("settings.providers.supportedAPIsDescription")}>
|
||||
{t("settings.providers.supportedAPIs")}
|
||||
</SettingsHint>
|
||||
</legend>
|
||||
{MODEL_REQUEST_APIS.map((api) => {
|
||||
const checked = supported.includes(api);
|
||||
@@ -48,7 +51,9 @@ export function ProviderAPIControl({ value, onChange }: {
|
||||
</fieldset>
|
||||
<div className="space-y-1.5">
|
||||
<span className="text-[12px] font-medium text-muted-foreground">
|
||||
{t("settings.providers.defaultAPI")}
|
||||
<SettingsHint description={t("settings.providers.defaultAPIDescription")}>
|
||||
{t("settings.providers.defaultAPI")}
|
||||
</SettingsHint>
|
||||
</span>
|
||||
<Select value={preferred} onValueChange={(api) => onChange({
|
||||
supported_apis: supported, preferred_api: api as ModelRequestAPI,
|
||||
|
||||
@@ -1015,6 +1015,7 @@ export function ProvidersSettings({
|
||||
<ModelAPIControl
|
||||
provider={provider}
|
||||
title={t("settings.providers.defaultAPI")}
|
||||
description={t("settings.providers.openaiDefaultAPIDescription")}
|
||||
value={form.api}
|
||||
onChange={(api) => onChangeProviderForm(provider.name, { api })}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user