mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-31 04:59:24 +08:00
Fix: model selection format compat and provider api_key wrapping (#17112)
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
||||
useFetchDefaultModelDictionary,
|
||||
useSetDefaultModel,
|
||||
} from '@/hooks/use-llm-request';
|
||||
import { parseModelValue } from '@/utils/llm-util';
|
||||
import { CircleQuestionMark } from 'lucide-react';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
@@ -88,8 +89,13 @@ function SystemSetting() {
|
||||
async (field: string, value: string) => {
|
||||
const modelType = FieldToModelType[field];
|
||||
if (!modelType) return;
|
||||
|
||||
await setDefaultModel({ model_id: value, model_type: modelType });
|
||||
if (!value) return;
|
||||
const parsed = parseModelValue(value);
|
||||
if (parsed) {
|
||||
await setDefaultModel({ ...parsed, model_type: modelType });
|
||||
} else {
|
||||
await setDefaultModel({ model_id: value, model_type: modelType });
|
||||
}
|
||||
},
|
||||
[setDefaultModel],
|
||||
);
|
||||
|
||||
@@ -77,13 +77,16 @@ export const GenericApiKeyConfig: ProviderConfig = {
|
||||
apiKey: values.api_key,
|
||||
baseUrl: values.base_url,
|
||||
}),
|
||||
submitTransform: (values) => ({
|
||||
instance_name: values.instance_name,
|
||||
api_key: values.api_key,
|
||||
api_base: values.base_url || '',
|
||||
group_id: values.group_id,
|
||||
max_tokens: 0,
|
||||
}),
|
||||
submitTransform: (values) => {
|
||||
const apiKey = values.group_id
|
||||
? { api_key: values.api_key ?? '', group_id: values.group_id }
|
||||
: (values.api_key ?? '');
|
||||
return {
|
||||
instance_name: values.instance_name,
|
||||
api_key: apiKey,
|
||||
api_base: values.base_url || '',
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -295,15 +295,20 @@ function buildLocalConfig(
|
||||
baseUrl: values.base_url,
|
||||
modelInfo: buildModelInfoFromValues(values),
|
||||
}),
|
||||
submitTransform: (values) => ({
|
||||
instance_name: values.instance_name,
|
||||
llm_factory: llmFactory,
|
||||
model_info: buildModelInfoFromValues(values),
|
||||
api_base: values.base_url,
|
||||
api_key: values.api_key,
|
||||
...(values.provider_order
|
||||
? { provider_order: values.provider_order }
|
||||
: {}),
|
||||
}),
|
||||
submitTransform: (values) => {
|
||||
const apiKey = values.provider_order
|
||||
? {
|
||||
api_key: values.api_key ?? '',
|
||||
provider_order: values.provider_order,
|
||||
}
|
||||
: (values.api_key ?? '');
|
||||
return {
|
||||
instance_name: values.instance_name,
|
||||
llm_factory: llmFactory,
|
||||
model_info: buildModelInfoFromValues(values),
|
||||
api_base: values.base_url,
|
||||
api_key: apiKey,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -70,14 +70,18 @@ export const ProviderConfigMap: Record<string, ProviderConfig> = {
|
||||
baseUrl: values.api_base,
|
||||
modelInfo: [],
|
||||
}),
|
||||
submitTransform: (values) => ({
|
||||
instance_name: values.instance_name,
|
||||
llm_factory: LLMFactory.AzureOpenAI,
|
||||
api_base: values.api_base,
|
||||
api_key: values.api_key,
|
||||
api_version: values.api_version,
|
||||
model_info: [],
|
||||
}),
|
||||
submitTransform: (values) => {
|
||||
const apiKey = values.api_version
|
||||
? { api_key: values.api_key ?? '', api_version: values.api_version }
|
||||
: (values.api_key ?? '');
|
||||
return {
|
||||
instance_name: values.instance_name,
|
||||
llm_factory: LLMFactory.AzureOpenAI,
|
||||
api_base: values.api_base,
|
||||
api_key: apiKey,
|
||||
model_info: [],
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
// ============ VolcEngine ============
|
||||
|
||||
Reference in New Issue
Block a user