Update from api_base to base_url (#17158)

This commit is contained in:
Wang Qi
2026-07-21 16:36:46 +08:00
committed by GitHub
parent 859006c79a
commit a6c3dd10ab
9 changed files with 24 additions and 39 deletions

View File

@@ -62,7 +62,7 @@ export interface IProviderInstance {
status: string;
/**
* Optional: only returned by the showProviderInstance endpoint. Used
* to pre-fill the base_url/api_base form field when opening a saved
* to pre-fill the base_url form field when opening a saved
* instance.
*/
base_url?: string;

View File

@@ -105,7 +105,7 @@ function pickDefaultUrl(
/**
* Fetch the catalog of available providers and derive the
* `base_url` / `api_base` dropdown options for the current provider.
* `base_url` dropdown options for the current provider.
* Used to pre-fill the URL field with the provider's default URL when
* creating a new instance.
*/
@@ -157,7 +157,7 @@ export function useProviderBaseUrlOptions(providerName: string) {
* lazy-loaded `showProviderInstance` details, and the provider's default
* base URL.
*
* - Draft: empty form, with `base_url` / `api_base` pre-filled from the
* - Draft: empty form, with `base_url` pre-filled from the
* provider's `default` URL when available.
* - Saved: prefer `instanceDetails` (which carries api_key / base_url);
* normalise api_key into the bare key plus any nested credential
@@ -176,7 +176,6 @@ export function useProviderInitialValues(
const values: Record<string, any> = { instance_name: '' };
if (defaultBaseUrl) {
values.base_url = defaultBaseUrl;
values.api_base = defaultBaseUrl;
}
return values;
}
@@ -200,10 +199,8 @@ export function useProviderInitialValues(
}
if (merged.base_url) {
values.base_url = merged.base_url;
values.api_base = merged.base_url;
} else if (defaultBaseUrl) {
values.base_url = defaultBaseUrl;
values.api_base = defaultBaseUrl;
}
// The /providers/<p>/instances/<i> endpoint also returns `region`
// for providers where it applies; surface it so the form / region
@@ -290,7 +287,7 @@ export function useFormResetOnDetailsLoad(
* maps provider-specific form field names (e.g. OpenDataLoader's
* `opendataloader_apiserver`) onto the `{ apiKey, baseUrl, modelInfo }`
* shape the verify endpoint expects. When absent the generic mapping
* (`values.api_key` / `values.base_url ?? values.api_base`) is used. */
* (`values.api_key` / `values.base_url`) is used. */
type VerifyTransform = (values: Record<string, any>) => {
apiKey: string | object | Record<string, any>;
baseUrl?: string;
@@ -336,7 +333,7 @@ export function useVerifyProvider(
} else {
verifyArgs = {
api_key: values.api_key ?? '',
base_url: values.base_url ?? values.api_base,
base_url: values.base_url,
model_info: values.model_info,
};
}
@@ -481,7 +478,7 @@ export function useInstanceSaveState({
// Provider-specific field mapping (e.g. OpenDataLoader's nested
// `opendataloader_apiserver` / `opendataloader_api_key`). The
// transform produces the canonical submit body shape
// (`instance_name`, `llm_factory`, `api_key`, `api_base`,
// (`instance_name`, `llm_factory`, `api_key`, `base_url`,
// `model_info`); we then layer on the card's own state (typed /
// edited name, model_info ref, update-only fields for saved cards).
if (submitTransform) {
@@ -505,7 +502,7 @@ export function useInstanceSaveState({
provider_name: providerName,
instance_name: editedNameRef.current,
id: resolvedId,
base_url: transformed.base_url ?? transformed.api_base ?? '',
base_url: transformed.base_url ?? '',
region: values.region || 'default',
model_info: modelInfo,
verify: false,
@@ -519,7 +516,7 @@ export function useInstanceSaveState({
llm_factory: providerName,
instance_name: trimmed,
api_key: buildApiKeyValue(values) ?? '',
base_url: values.base_url ?? values.api_base,
base_url: values.base_url,
};
if (modelInfoRef.current.length > 0) {
payload.model_info = modelInfoRef.current;
@@ -536,7 +533,7 @@ export function useInstanceSaveState({
instance_name: editedNameRef.current,
id: resolvedId,
api_key: apiKeyValue ?? '',
base_url: values.base_url ?? values.api_base,
base_url: values.base_url,
region: values.region || 'default',
model_info: modelInfoRef.current.length > 0 ? modelInfoRef.current : [],
verify: false,
@@ -570,7 +567,7 @@ export function useInstanceSaveState({
instance_name: instanceName,
id: resolvedId,
api_key: buildApiKeyValue(initialValues),
base_url: initialValues.base_url ?? initialValues.api_base,
base_url: initialValues.base_url,
region: initialValues.region,
// model_info baseline is `[]`; `markModelsEdited` rewrites it after
// a model PATCH so the next top-save short-circuits. The first

View File

@@ -101,11 +101,7 @@ export function useResolveCreds(
const fv = getFormValues?.() ?? {};
return {
apiKey: (fv.api_key as string) ?? instance?.api_key ?? '',
baseUrl:
(fv.base_url as string) ??
(fv.api_base as string) ??
instance?.base_url ??
'',
baseUrl: (fv.base_url as string) ?? instance?.base_url ?? '',
};
}, [getFormValues, instance]);

View File

@@ -47,7 +47,7 @@ export interface ModelsSectionProps {
hideIfEmpty?: boolean;
/**
* Optional getter returning the host card's current form values
* (`api_key`, `base_url` / `api_base`, region-specific fields, ...).
* (`api_key`, `base_url`, region-specific fields, ...).
* When provided, ModelsSection prefers these over the persisted
* `instance` props when calling listProviderModels / verifyProviderConnection,
* so the user can verify with values they are still editing (before

View File

@@ -30,7 +30,6 @@ const INSTANCE_RESERVED_KEYS = new Set([
'instance_name',
'llm_factory',
'provider_name',
'api_base',
'base_url',
'region',
'verify',
@@ -113,20 +112,13 @@ const collectModelExtras = (payload: FlatPayload) => {
};
export const splitProviderPayload = (payload: FlatPayload): SplitResult => {
const {
instance_name,
llm_factory,
base_url,
api_base,
region,
model_info,
...other
} = payload;
const { instance_name, llm_factory, base_url, region, model_info, ...other } =
payload;
const instancePayload = {
instance_name: instance_name as string,
llm_factory: llm_factory as string,
api_key: collectApiKeyExtras(payload),
base_url: (base_url ?? api_base) as string | undefined,
base_url: base_url as string | undefined,
region: (region as string | undefined) || 'default',
model_info: model_info,
...other,

View File

@@ -84,7 +84,7 @@ export const GenericApiKeyConfig: ProviderConfig = {
return {
instance_name: values.instance_name,
api_key: apiKey,
api_base: values.base_url || '',
base_url: values.base_url || '',
};
},
};

View File

@@ -306,7 +306,7 @@ function buildLocalConfig(
instance_name: values.instance_name,
llm_factory: llmFactory,
model_info: buildModelInfoFromValues(values),
api_base: values.base_url,
base_url: values.base_url,
api_key: apiKey,
};
},

View File

@@ -39,7 +39,7 @@ export const ProviderConfigMap: Record<string, ProviderConfig> = {
validation: { message: 'instanceNameMessage' },
},
{
name: 'api_base',
name: 'base_url',
label: 'addLlmBaseUrl',
type: 'inputSelect',
required: true,
@@ -67,7 +67,7 @@ export const ProviderConfigMap: Record<string, ProviderConfig> = {
],
verifyTransform: (values) => ({
apiKey: values.api_key,
baseUrl: values.api_base,
baseUrl: values.base_url,
modelInfo: [],
}),
submitTransform: (values) => {
@@ -77,7 +77,7 @@ export const ProviderConfigMap: Record<string, ProviderConfig> = {
return {
instance_name: values.instance_name,
llm_factory: LLMFactory.AzureOpenAI,
api_base: values.api_base,
base_url: values.base_url,
api_key: apiKey,
model_info: [],
};
@@ -464,7 +464,7 @@ export const ProviderConfigMap: Record<string, ProviderConfig> = {
instance_name: values.instance_name,
llm_factory: LLMFactory.OpenDataLoader,
api_key: cfg,
api_base: '',
base_url: '',
model_info: [],
};
},
@@ -543,7 +543,7 @@ export const ProviderConfigMap: Record<string, ProviderConfig> = {
instance_name: values.instance_name,
llm_factory: LLMFactory.PaddleOCR,
api_key: cfg,
api_base: '',
base_url: '',
model_info: [],
};
},
@@ -638,7 +638,7 @@ export const ProviderConfigMap: Record<string, ProviderConfig> = {
instance_name: values.instance_name,
llm_factory: LLMFactory.MinerU,
api_key: cfg,
api_base: '',
base_url: '',
model_info: [],
};
},

View File

@@ -189,7 +189,7 @@ export interface ProviderModalProps {
initialValues?: Record<string, any>;
/**
* Base URL options for the input+select combo (from IAvailableProvider.url)
* Used by base_url/api_base fields of type inputSelect
* Used by base_url fields of type inputSelect
*/
baseUrlOptions?: SelectOption[];
onOk: (payload: any, isVerify?: boolean) => Promise<any>;