feat(webui): show resolved Auto API in preset selector

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-10 01:33:02 +08:00
1 parent 994ce51502
commit 73a27e0726
28 files changed
+464 -259

No files matched your search

+22
View File
@@ -3,6 +3,7 @@ import type {
AutomationChatsPayload,
AutomationChatUpdate,
AutomationsPayload,
AutomaticModelAPIPayload,
AutomationUpdatePayload,
ChannelConfigurePayload,
ChannelConnectPayload,
@@ -1045,6 +1046,27 @@ export async function cancelMcpOAuth(
);
}
export async function fetchAutomaticModelAPI(
token: string,
provider: string,
model: string,
reasoningEffort: string,
base: string = "",
): Promise<AutomaticModelAPIPayload> {
const query = new URLSearchParams({ provider, model, reasoning_effort: reasoningEffort });
const payload = await request<unknown>(
`${base}/api/settings/model-api?${query}`, token, undefined, API_READ_TIMEOUT_MS,
);
if (typeof payload !== "object" || payload === null) throw new Error("Invalid model API resolution");
const result = payload as Record<string, unknown>;
const api = result.api;
if (typeof result.provider !== "string" || (
api !== "chat_completions" && api !== "responses" && api !== "anthropic_messages"
&& api !== "bedrock_converse" && api !== "transcription"
)) throw new Error("Invalid model API resolution");
return { provider: result.provider, api };
}
export async function fetchProviderModels(
token: string,
provider: string,
+11 -3
View File
@@ -600,6 +600,14 @@ export interface ModelAPIConfig {
preferred_api?: "chat_completions" | "responses" | null;
}
export type ProviderRequestAPI =
"chat_completions" | "responses" | "anthropic_messages" | "bedrock_converse" | "transcription";
export interface AutomaticModelAPIPayload {
provider: string;
api: ProviderRequestAPI;
}
interface ProviderModelInfo {
id: string;
label?: string | null;
@@ -702,6 +710,8 @@ export interface SettingsPayload {
model_call_order_editable: boolean;
/** Whether an actual legacy model configuration is available to convert. */
model_configuration_migratable?: boolean;
/** Host can resolve the default request API for an unsaved model configuration. */
model_api_resolution_supported?: boolean;
created_model_preset?: string;
created_provider?: string;
providers: Array<{
@@ -718,9 +728,7 @@ export interface SettingsPayload {
model_catalog?: ProviderModelsPayload["catalog_kind"];
model_api_configurable?: boolean;
/** Request formats implemented by the host's provider adapter. */
request_apis?: Array<
"chat_completions" | "responses" | "anthropic_messages" | "bedrock_converse" | "transcription"
>;
request_apis?: ProviderRequestAPI[];
api_type?: "auto" | "chat_completions" | "responses";
oauth_account?: string | null;
oauth_expires_at?: number | null;