fix: miss openaiCustomUrl in get-models payload

This commit is contained in:
jialin
2026-02-24 15:36:41 +08:00
parent 053e5cca86
commit 5151f26b9e
5 changed files with 28 additions and 6 deletions
@@ -7,6 +7,7 @@ interface FormContextProps {
action: PageActionType; action: PageActionType;
currentData?: any; currentData?: any;
id?: number; id?: number;
getCustomConfig?: () => Record<string, any>;
} }
const FormContext = createContext<FormContextProps>({} as FormContextProps); const FormContext = createContext<FormContextProps>({} as FormContextProps);
+11 -1
View File
@@ -97,6 +97,11 @@ const ProviderForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
); );
}; };
const getCustomConfig = () => {
const customConfig = yaml2Json(advanceRef.current?.getYamlValue() || '');
return customConfig;
};
const handleOnFinish = (values: FormData) => { const handleOnFinish = (values: FormData) => {
const data = { const data = {
..._.omit(values, ['api_key']), ..._.omit(values, ['api_key']),
@@ -171,7 +176,12 @@ const ProviderForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
getScrollElementScrollableHeight={getScrollElementScrollableHeight} getScrollElementScrollableHeight={getScrollElementScrollableHeight}
> >
<FormContext.Provider <FormContext.Provider
value={{ action, id: currentData?.id, currentData }} value={{
action,
id: currentData?.id,
currentData,
getCustomConfig: getCustomConfig
}}
> >
<Form <Form
form={form} form={form}
+1 -1
View File
@@ -84,7 +84,7 @@ const ModelItem: React.FC<ModelItemProps> = ({
form.getFieldValue('api_key') form.getFieldValue('api_key')
) as string, ) as string,
proxy_url: proxyConfigEnabled proxy_url: proxyConfigEnabled
? form.getFieldValue('proxy_url') || undefined ? form.getFieldValue('proxy_url') || null
: null, : null,
config: { config: {
type: form.getFieldValue(['config', 'type']) || '' type: form.getFieldValue(['config', 'type']) || ''
@@ -18,7 +18,7 @@ const SupportedModels = () => {
type: string; type: string;
api_key: string; api_key: string;
}>({ type: '', api_key: '' }); }>({ type: '', api_key: '' });
const { id, action, currentData } = useFormContext(); const { id, action, currentData, getCustomConfig } = useFormContext();
const generateCurrentAPIKey = (currentAPIKey: string) => { const generateCurrentAPIKey = (currentAPIKey: string) => {
if ( if (
@@ -50,6 +50,7 @@ const SupportedModels = () => {
try { try {
await form.validateFields(['api_key', ['config', 'type']]); await form.validateFields(['api_key', ['config', 'type']]);
const proxyConfigEnabled = form.getFieldValue('proxy_enabled');
const currentAPIKey = form.getFieldValue('api_key') || ''; const currentAPIKey = form.getFieldValue('api_key') || '';
const configType = form.getFieldValue(['config', 'type']); const configType = form.getFieldValue(['config', 'type']);
@@ -66,9 +67,15 @@ const SupportedModels = () => {
id: generateID(), id: generateID(),
data: { data: {
api_token: generateCurrentAPIKey(currentAPIKey) as string, api_token: generateCurrentAPIKey(currentAPIKey) as string,
proxy_url: form.getFieldValue('proxy_url') || undefined, proxy_url: proxyConfigEnabled
? form.getFieldValue('proxy_url') || null
: null,
config: { config: {
type: form.getFieldValue(['config', 'type']) || '' type: form.getFieldValue(['config', 'type']) || '',
openaiCustomUrl:
form.getFieldValue(['config', 'openaiCustomUrl']) ||
getCustomConfig?.()?.openaiCustomUrl ||
null
} }
} }
}); });
@@ -26,7 +26,11 @@ export const useQueryProviderModels = () => {
} = useRequest( } = useRequest(
async (params: { async (params: {
id: number; id: number;
data: { api_token: string; config: { type: string }; proxy_url: string }; data: {
api_token: string;
config: { type: string; [key: string]: any };
proxy_url: string;
};
}) => { }) => {
axiosTokenRef.current?.cancel(); axiosTokenRef.current?.cancel();
axiosTokenRef.current = createAxiosToken(); axiosTokenRef.current = createAxiosToken();