mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-12 03:33:33 +08:00
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:
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user