Feat: tenant llm provider (#14595)

### What problem does this PR solve?

Python implementation of the Go-based model_provider API suite.

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

---------

Co-authored-by: bill <yibie_jingnian@163.com>
This commit is contained in:
Lynn
2026-05-29 17:39:41 +08:00
committed by GitHub
parent b79f79d9b9
commit dc4b82523b
148 changed files with 6059 additions and 3075 deletions

View File

@@ -1,45 +1,24 @@
import { LlmModelType } from '@/constants/knowledge';
import { useComposeLlmOptionsByModelTypes } from '@/hooks/use-llm-request';
import { ModelTreeSelect } from '@/components/model-tree-select';
import { useTranslation } from 'react-i18next';
import { SelectWithSearch } from '../originui/select-with-search';
import { RAGFlowFormItem } from '../ragflow-form';
export type LLMFormFieldProps = {
options?: any[];
modelTypes?: string[];
name?: string;
testId?: string;
optionTestIdPrefix?: string;
config?: any;
};
export const useModelOptions = () => {
const modelOptions = useComposeLlmOptionsByModelTypes([
LlmModelType.Chat,
LlmModelType.Image2text,
]);
return {
modelOptions,
};
};
export function LLMFormField({
options,
name,
testId,
optionTestIdPrefix,
config,
}: LLMFormFieldProps) {
export function LLMFormField({ name, config, modelTypes }: LLMFormFieldProps) {
const { t } = useTranslation();
const { modelOptions } = useModelOptions();
return (
<RAGFlowFormItem name={name || 'llm_id'} label={t('chat.model')}>
<SelectWithSearch
options={options || modelOptions}
testId={testId}
optionTestIdPrefix={optionTestIdPrefix}
{...config}
></SelectWithSearch>
<ModelTreeSelect
allowClear={config?.allowClear ?? false}
modelTypes={modelTypes}
/>
</RAGFlowFormItem>
);
}

View File

@@ -27,7 +27,7 @@ import { useHandleFreedomChange } from './use-watch-change';
interface LlmSettingFieldItemsProps {
prefix?: string;
options?: any[];
modelTypes?: string[];
llmId?: string;
llmSelectTestId?: string;
llmOptionTestIdPrefix?: string;
@@ -69,7 +69,7 @@ export const LlmSettingSchema = {
export function LlmSettingFieldItems({
prefix,
options,
modelTypes,
llmSelectTestId,
llmOptionTestIdPrefix,
showFields = [
@@ -137,7 +137,7 @@ export function LlmSettingFieldItems({
return (
<div className="space-y-5">
<LLMFormField
options={options}
modelTypes={modelTypes}
name={llmId ?? getFieldWithPrefix('llm_id')}
testId={llmSelectTestId}
optionTestIdPrefix={llmOptionTestIdPrefix}