742 lines
20 KiB
TypeScript
742 lines
20 KiB
TypeScript
|
|
import type { ConfigFormItem, DocLinkConfig } from './ConfigurationDialog';
|
|||
|
|
import { LLM_FACTORY_LIST } from '@/constants/llm';
|
|||
|
|
|
|||
|
|
// AWS Bedrock 支持的区域列表
|
|||
|
|
export const BEDROCK_REGIONS = [
|
|||
|
|
'us-east-2',
|
|||
|
|
'us-east-1',
|
|||
|
|
'us-west-1',
|
|||
|
|
'us-west-2',
|
|||
|
|
'af-south-1',
|
|||
|
|
'ap-east-1',
|
|||
|
|
'ap-south-2',
|
|||
|
|
'ap-southeast-3',
|
|||
|
|
'ap-southeast-5',
|
|||
|
|
'ap-southeast-4',
|
|||
|
|
'ap-south-1',
|
|||
|
|
'ap-northeast-3',
|
|||
|
|
'ap-northeast-2',
|
|||
|
|
'ap-southeast-1',
|
|||
|
|
'ap-southeast-2',
|
|||
|
|
'ap-east-2',
|
|||
|
|
'ap-southeast-7',
|
|||
|
|
'ap-northeast-1',
|
|||
|
|
'ca-central-1',
|
|||
|
|
'ca-west-1',
|
|||
|
|
'eu-central-1',
|
|||
|
|
'eu-west-1',
|
|||
|
|
'eu-west-2',
|
|||
|
|
'eu-south-1',
|
|||
|
|
'eu-west-3',
|
|||
|
|
'eu-south-2',
|
|||
|
|
'eu-north-1',
|
|||
|
|
'eu-central-2',
|
|||
|
|
'il-central-1',
|
|||
|
|
'mx-central-1',
|
|||
|
|
'me-south-1',
|
|||
|
|
'me-central-1',
|
|||
|
|
'sa-east-1',
|
|||
|
|
'us-gov-east-1',
|
|||
|
|
'us-gov-west-1',
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
// 模型类型选项
|
|||
|
|
export const MODEL_TYPE_OPTIONS = [
|
|||
|
|
{ value: 'chat', label: 'Chat' },
|
|||
|
|
{ value: 'embedding', label: 'Embedding' },
|
|||
|
|
{ value: 'rerank', label: 'Rerank' },
|
|||
|
|
{ value: 'image2text', label: 'Image2Text' },
|
|||
|
|
{ value: 'speech2text', label: 'Speech2Text' },
|
|||
|
|
{ value: 'tts', label: 'TTS' },
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
// 文档链接映射
|
|||
|
|
export const DOC_LINKS: Record<string, DocLinkConfig> = {
|
|||
|
|
[LLM_FACTORY_LIST.AzureOpenAI]: {
|
|||
|
|
url: 'https://azure.microsoft.com/en-us/products/ai-services/openai-service',
|
|||
|
|
text: '如何集成 Azure OpenAI',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.Bedrock]: {
|
|||
|
|
url: 'https://console.aws.amazon.com/',
|
|||
|
|
text: '如何集成 Bedrock',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.Ollama]: {
|
|||
|
|
url: 'https://github.com/infiniflow/ragflow/blob/main/docs/guides/models/deploy_local_llm.mdx',
|
|||
|
|
text: '如何集成 Ollama',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.Xinference]: {
|
|||
|
|
url: 'https://inference.readthedocs.io/en/latest/user_guide',
|
|||
|
|
text: '如何集成 Xinference',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.ModelScope]: {
|
|||
|
|
url: 'https://www.modelscope.cn/docs/model-service/API-Inference/intro',
|
|||
|
|
text: '如何集成 ModelScope',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.LocalAI]: {
|
|||
|
|
url: 'https://localai.io/docs/getting-started/models/',
|
|||
|
|
text: '如何集成 LocalAI',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.LMStudio]: {
|
|||
|
|
url: 'https://lmstudio.ai/docs/basics',
|
|||
|
|
text: '如何集成 LMStudio',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.OpenAiAPICompatible]: {
|
|||
|
|
url: 'https://platform.openai.com/docs/models/gpt-4',
|
|||
|
|
text: '如何集成 OpenAI API Compatible',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.TogetherAI]: {
|
|||
|
|
url: 'https://docs.together.ai/docs/deployment-options',
|
|||
|
|
text: '如何集成 TogetherAI',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.Replicate]: {
|
|||
|
|
url: 'https://replicate.com/docs/topics/deployments',
|
|||
|
|
text: '如何集成 Replicate',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.OpenRouter]: {
|
|||
|
|
url: 'https://openrouter.ai/docs',
|
|||
|
|
text: '如何集成 OpenRouter',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.HuggingFace]: {
|
|||
|
|
url: 'https://huggingface.co/docs/text-embeddings-inference/quick_tour',
|
|||
|
|
text: '如何集成 HuggingFace',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.GPUStack]: {
|
|||
|
|
url: 'https://docs.gpustack.ai/latest/quickstart',
|
|||
|
|
text: '如何集成 GPUStack',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.VLLM]: {
|
|||
|
|
url: 'https://docs.vllm.ai/en/latest/',
|
|||
|
|
text: '如何集成 VLLM',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.FishAudio]: {
|
|||
|
|
url: 'https://www.fish.audio/',
|
|||
|
|
text: '如何集成 Fish Audio',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.TencentCloud]: {
|
|||
|
|
url: 'https://cloud.tencent.com/document/api/1093/37823',
|
|||
|
|
text: '如何集成 腾讯云语音识别',
|
|||
|
|
},
|
|||
|
|
[LLM_FACTORY_LIST.VolcEngine]: {
|
|||
|
|
url: 'https://www.volcengine.com/docs/82379/1302008',
|
|||
|
|
text: '如何集成 VolcEngine',
|
|||
|
|
},
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// Azure OpenAI 配置
|
|||
|
|
export const AZURE_OPENAI_CONFIG: ConfigFormItem[] = [
|
|||
|
|
{
|
|||
|
|
name: 'model_type',
|
|||
|
|
label: '模型类型',
|
|||
|
|
type: 'select',
|
|||
|
|
required: true,
|
|||
|
|
options: [
|
|||
|
|
{ value: 'chat', label: 'Chat' },
|
|||
|
|
{ value: 'embedding', label: 'Embedding' },
|
|||
|
|
{ value: 'image2text', label: 'Image2Text' },
|
|||
|
|
],
|
|||
|
|
defaultValue: 'embedding',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'llm_name',
|
|||
|
|
label: '模型名称',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: 'gpt-3.5-turbo',
|
|||
|
|
helperText: '请输入模型名称',
|
|||
|
|
defaultValue: 'gpt-3.5-turbo',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'api_base',
|
|||
|
|
label: '基础 Url',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: 'https://your-resource.openai.azure.com/',
|
|||
|
|
helperText: 'Azure OpenAI 服务的端点 URL',
|
|||
|
|
validation: {
|
|||
|
|
pattern: {
|
|||
|
|
value: /^https?:\/\/.+/,
|
|||
|
|
message: '基础 URL 必须是有效的 URL',
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'api_key',
|
|||
|
|
label: 'API-Key',
|
|||
|
|
type: 'password',
|
|||
|
|
helperText: '输入api key(如果是本地部署的模型,请忽略)',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'api_version',
|
|||
|
|
label: 'API Version',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '2024-02-01',
|
|||
|
|
helperText: 'Azure OpenAI API 版本',
|
|||
|
|
defaultValue: '2024-02-01',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'max_tokens',
|
|||
|
|
label: '最大token数',
|
|||
|
|
type: 'number',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '设置了模型输出的最大长度,以token(单词片段)的数量表示',
|
|||
|
|
helperText: '设置了模型输出的最大长度,以token(单词片段)的数量表示',
|
|||
|
|
defaultValue: 4096,
|
|||
|
|
validation: {
|
|||
|
|
min: { value: 1, message: '最大token数必须大于0' },
|
|||
|
|
max: { value: 100000, message: '最大token数不能超过100000' },
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
// Bedrock 配置
|
|||
|
|
export const BEDROCK_CONFIG: ConfigFormItem[] = [
|
|||
|
|
{
|
|||
|
|
name: 'model_type',
|
|||
|
|
label: '模型类型',
|
|||
|
|
type: 'select',
|
|||
|
|
required: true,
|
|||
|
|
options: MODEL_TYPE_OPTIONS.slice(0, 2), // 只支持 chat 和 embedding
|
|||
|
|
defaultValue: 'chat',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'llm_name',
|
|||
|
|
label: '模型名称',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入模型名称',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'bedrock_ak',
|
|||
|
|
label: 'ACCESS KEY',
|
|||
|
|
type: 'password',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 ACCESS KEY',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'bedrock_sk',
|
|||
|
|
label: 'SECRET KEY',
|
|||
|
|
type: 'password',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 SECRET KEY',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'bedrock_region',
|
|||
|
|
label: 'AWS Region',
|
|||
|
|
type: 'select',
|
|||
|
|
required: true,
|
|||
|
|
options: BEDROCK_REGIONS.map(region => ({ value: region, label: region })),
|
|||
|
|
defaultValue: 'us-east-1',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'max_tokens',
|
|||
|
|
label: '最大token数',
|
|||
|
|
type: 'number',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '这设置了模型输出的最大长度,以token(单词或词片段)的数量来衡量',
|
|||
|
|
helperText: '这设置了模型输出的最大长度,以token(单词或词片段)的数量来衡量',
|
|||
|
|
defaultValue: 4096,
|
|||
|
|
validation: {
|
|||
|
|
min: { value: 1, message: '最大token数必须大于0' },
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
// Ollama 配置
|
|||
|
|
export const OLLAMA_CONFIG: ConfigFormItem[] = [
|
|||
|
|
{
|
|||
|
|
name: 'model_type',
|
|||
|
|
label: '模型类型',
|
|||
|
|
type: 'select',
|
|||
|
|
required: true,
|
|||
|
|
options: MODEL_TYPE_OPTIONS,
|
|||
|
|
defaultValue: 'chat',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'llm_name',
|
|||
|
|
label: '模型名称',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '例如: llama2, mistral',
|
|||
|
|
helperText: '请输入模型名称',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'api_base',
|
|||
|
|
label: '基础 URL',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: 'http://localhost:8888',
|
|||
|
|
helperText: '基础 URL',
|
|||
|
|
defaultValue: 'http://localhost:11434',
|
|||
|
|
validation: {
|
|||
|
|
pattern: {
|
|||
|
|
value: /^https?:\/\/.+/,
|
|||
|
|
message: '基础 URL 必须是有效的 URL',
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'api_key',
|
|||
|
|
label: 'API Key',
|
|||
|
|
type: 'text',
|
|||
|
|
placeholder: '如果需要认证,请输入 API Key',
|
|||
|
|
helperText: 'API Key (可选)',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'max_tokens',
|
|||
|
|
label: '最大 Token 数',
|
|||
|
|
type: 'number',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '4096',
|
|||
|
|
helperText: '模型支持的最大 Token 数',
|
|||
|
|
defaultValue: 4096,
|
|||
|
|
validation: {
|
|||
|
|
min: { value: 1, message: '最大 Token 数必须大于 0' },
|
|||
|
|
max: { value: 100000, message: '最大 Token 数不能超过 100000' },
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
export const BAIDU_YIYAN_CONFIG: ConfigFormItem[] = [
|
|||
|
|
{
|
|||
|
|
name: 'model_type',
|
|||
|
|
label: '模型类型',
|
|||
|
|
type: 'select',
|
|||
|
|
required: true,
|
|||
|
|
options: MODEL_TYPE_OPTIONS.slice(0, 3),
|
|||
|
|
defaultValue: 'chat',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'llm_name',
|
|||
|
|
label: '模型名称',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入模型名称',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'yiyan_ak',
|
|||
|
|
label: '一言 API KEY',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 API KEY',
|
|||
|
|
helperText: 'Baidu YiYan API KEY',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'yiyan_sk',
|
|||
|
|
label: '一言 Secret KEY',
|
|||
|
|
type: 'password',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 Secret KEY',
|
|||
|
|
helperText: 'Baidu YiYan Secret KEY',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'max_tokens',
|
|||
|
|
label: '最大token数',
|
|||
|
|
type: 'number',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '设置了模型输出的最大长度,以token(单词片段)的数量表示',
|
|||
|
|
helperText: '设置了模型输出的最大长度,以token(单词片段)的数量表示',
|
|||
|
|
defaultValue: 4096,
|
|||
|
|
validation: {
|
|||
|
|
min: { value: 1, message: '最大token数必须大于0' },
|
|||
|
|
max: { value: 100000, message: '最大token数不能超过100000' },
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
export const FISH_AUDIO_CONFIG: ConfigFormItem[] = [
|
|||
|
|
{
|
|||
|
|
name: 'model_type',
|
|||
|
|
label: '模型类型',
|
|||
|
|
type: 'select',
|
|||
|
|
required: true,
|
|||
|
|
options: [{ value: 'tts', label: 'TTS' },],
|
|||
|
|
defaultValue: 'tts',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'llm_name',
|
|||
|
|
label: '模型名称',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入模型名称',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'fish_audio_ak',
|
|||
|
|
label: 'Fish Audio API KEY',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 API KEY',
|
|||
|
|
helperText: 'Fish Audio API KEY',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'fish_audio_refid',
|
|||
|
|
label: 'FishAudio Refrence ID',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 Refrence ID',
|
|||
|
|
helperText: 'Fish Audio Refrence ID',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'max_tokens',
|
|||
|
|
label: '最大token数',
|
|||
|
|
type: 'number',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '设置了模型输出的最大长度,以token(单词片段)的数量表示',
|
|||
|
|
helperText: '设置了模型输出的最大长度,以token(单词片段)的数量表示',
|
|||
|
|
defaultValue: 4096,
|
|||
|
|
validation: {
|
|||
|
|
min: { value: 1, message: '最大token数必须大于0' },
|
|||
|
|
max: { value: 100000, message: '最大token数不能超过100000' },
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
export const GOOGLE_CLOUD_CONFIG: ConfigFormItem[] = [
|
|||
|
|
{
|
|||
|
|
name: 'model_type',
|
|||
|
|
label: '模型类型',
|
|||
|
|
type: 'select',
|
|||
|
|
required: true,
|
|||
|
|
options: [{ value: 'chat', label: 'Chat' }, { value: 'image2text', label: 'Image2Text' }],
|
|||
|
|
defaultValue: 'chat',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'llm_name',
|
|||
|
|
label: '模型名称',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入模型名称',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'google_project_id',
|
|||
|
|
label: 'Project ID',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 Project ID',
|
|||
|
|
helperText: 'Google Cloud Project ID',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'google_region',
|
|||
|
|
label: 'Google Cloud 区域',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 Google Cloud 区域',
|
|||
|
|
helperText: 'Google Cloud 区域',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'google_service_account_key',
|
|||
|
|
label: 'Google Cloud Service Account Key',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 Google Cloud Service Account Key',
|
|||
|
|
helperText: 'Google Cloud Service Account Key',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'max_tokens',
|
|||
|
|
label: '最大token数',
|
|||
|
|
type: 'number',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '设置了模型输出的最大长度,以token(单词片段)的数量表示',
|
|||
|
|
helperText: '设置了模型输出的最大长度,以token(单词片段)的数量表示',
|
|||
|
|
defaultValue: 4096,
|
|||
|
|
validation: {
|
|||
|
|
min: { value: 1, message: '最大token数必须大于0' },
|
|||
|
|
max: { value: 100000, message: '最大token数不能超过100000' },
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
export const TENCENT_CLOUD_CONFIG: ConfigFormItem[] = [
|
|||
|
|
{
|
|||
|
|
name: 'model_type',
|
|||
|
|
label: '模型类型',
|
|||
|
|
type: 'select',
|
|||
|
|
required: true,
|
|||
|
|
options: [{ value: 'speech2text', label: 'Speech2Text' }],
|
|||
|
|
defaultValue: 'speech2text',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'llm_name',
|
|||
|
|
label: '模型名称',
|
|||
|
|
type: 'select',
|
|||
|
|
required: true,
|
|||
|
|
options: [
|
|||
|
|
'16k_zh', '16k_zh_large', '16k_multi_lang', '16k_zh_dialect', '16k_en', '16k_yue', '16k_zh-PY',
|
|||
|
|
'16k_ja', '16k_ko', '16k_vi', '16k_ms', '16k_id', '16k_fil', '16k_th', '16k_pt', '16k_tr',
|
|||
|
|
'16k_ar', '16k_es', '16k_hi', '16k_fr', '16k_zh_medical', '16k_de'
|
|||
|
|
].map((item) => ({ value: item, label: item })),
|
|||
|
|
defaultValue: '16k_zh',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'tencent_ak',
|
|||
|
|
label: '腾讯云 Secret ID',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 Secret ID',
|
|||
|
|
helperText: '腾讯云 Secret ID',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'tencent_sk',
|
|||
|
|
label: '腾讯云 Secret KEY',
|
|||
|
|
type: 'password',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 Secret KEY',
|
|||
|
|
helperText: '腾讯云 Secret KEY',
|
|||
|
|
},
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
export const TENCENT_HUNYUAN_CONFIG: ConfigFormItem[] = [
|
|||
|
|
{
|
|||
|
|
name: 'hunyuan_sid',
|
|||
|
|
label: '混元 Secret ID',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 Secret ID',
|
|||
|
|
helperText: '混元 Secret ID',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'hunyuan_sk',
|
|||
|
|
label: '混元 Secret KEY',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 Secret KEY',
|
|||
|
|
helperText: '混元 Secret KEY',
|
|||
|
|
},
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
// XunFeiSpark
|
|||
|
|
export const XUNFEI_SPARK_CONFIG: ConfigFormItem[] = [
|
|||
|
|
{
|
|||
|
|
name: 'model_type',
|
|||
|
|
label: '模型类型',
|
|||
|
|
type: 'select',
|
|||
|
|
required: true,
|
|||
|
|
options: [{ value: 'chat', label: 'Chat' }, { value: 'tts', label: 'TTS' }],
|
|||
|
|
defaultValue: 'chat',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'llm_name',
|
|||
|
|
label: '模型名称',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入模型名称',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'xunfei_spark_password',
|
|||
|
|
label: '讯飞星火 API Password',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 API Password',
|
|||
|
|
helperText: '讯飞星火 API Password',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'max_tokens',
|
|||
|
|
label: '最大token数',
|
|||
|
|
type: 'number',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '设置了模型输出的最大长度,以token(单词片段)的数量表示',
|
|||
|
|
helperText: '设置了模型输出的最大长度,以token(单词片段)的数量表示',
|
|||
|
|
defaultValue: 4096,
|
|||
|
|
validation: {
|
|||
|
|
min: { value: 1, message: '最大token数必须大于0' },
|
|||
|
|
max: { value: 100000, message: '最大token数不能超过100000' },
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
// VolcEngine
|
|||
|
|
export const VOLC_ENGINE_CONFIG: ConfigFormItem[] = [
|
|||
|
|
{
|
|||
|
|
name: 'model_type',
|
|||
|
|
label: '模型类型',
|
|||
|
|
type: 'select',
|
|||
|
|
required: true,
|
|||
|
|
options: [{ value: 'chat', label: 'Chat' }, { value: 'embedding', label: 'Embedding' }],
|
|||
|
|
defaultValue: 'chat',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'llm_name',
|
|||
|
|
label: '模型名称',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入模型名称',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'endpoint_id',
|
|||
|
|
label: '模型 EndpointID',
|
|||
|
|
type: 'text',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 EndpointID',
|
|||
|
|
helperText: '模型 EndpointID',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'ark_api_key',
|
|||
|
|
label: '火山 ARK_API_KEY',
|
|||
|
|
type: 'password',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '请输入 ARK_API_KEY',
|
|||
|
|
helperText: '模型 ARK_API_KEY',
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'max_tokens',
|
|||
|
|
label: '最大token数',
|
|||
|
|
type: 'number',
|
|||
|
|
required: true,
|
|||
|
|
placeholder: '设置了模型输出的最大长度,以token(单词片段)的数量表示',
|
|||
|
|
helperText: '设置了模型输出的最大长度,以token(单词片段)的数量表示',
|
|||
|
|
defaultValue: 4096,
|
|||
|
|
validation: {
|
|||
|
|
min: { value: 1, message: '最大token数必须大于0' },
|
|||
|
|
max: { value: 100000, message: '最大token数不能超过100000' },
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
// 根据 LLM Factory 获取配置
|
|||
|
|
export function getLLMConfig(factory: string): {
|
|||
|
|
formItems: ConfigFormItem[];
|
|||
|
|
docLink?: DocLinkConfig;
|
|||
|
|
title: string;
|
|||
|
|
defaultValues: Record<string, any>;
|
|||
|
|
} {
|
|||
|
|
const docLink: DocLinkConfig | undefined = DOC_LINKS[factory];
|
|||
|
|
|
|||
|
|
switch (factory) {
|
|||
|
|
case LLM_FACTORY_LIST.AzureOpenAI:
|
|||
|
|
return {
|
|||
|
|
formItems: AZURE_OPENAI_CONFIG,
|
|||
|
|
docLink,
|
|||
|
|
title: 'Azure OpenAI',
|
|||
|
|
defaultValues: { llm_factory: factory },
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
case LLM_FACTORY_LIST.Bedrock:
|
|||
|
|
return {
|
|||
|
|
formItems: BEDROCK_CONFIG,
|
|||
|
|
docLink,
|
|||
|
|
title: 'Bedrock',
|
|||
|
|
defaultValues: { llm_factory: factory },
|
|||
|
|
};
|
|||
|
|
case LLM_FACTORY_LIST.BaiduYiYan:
|
|||
|
|
return {
|
|||
|
|
formItems: BAIDU_YIYAN_CONFIG,
|
|||
|
|
docLink,
|
|||
|
|
title: 'Baidu YiYan',
|
|||
|
|
defaultValues: { llm_factory: factory },
|
|||
|
|
};
|
|||
|
|
case LLM_FACTORY_LIST.FishAudio:
|
|||
|
|
return {
|
|||
|
|
formItems: FISH_AUDIO_CONFIG,
|
|||
|
|
docLink,
|
|||
|
|
title: 'Fish Audio',
|
|||
|
|
defaultValues: { llm_factory: factory },
|
|||
|
|
};
|
|||
|
|
case LLM_FACTORY_LIST.GoogleCloud:
|
|||
|
|
return {
|
|||
|
|
formItems: GOOGLE_CLOUD_CONFIG,
|
|||
|
|
docLink,
|
|||
|
|
title: 'Google Cloud',
|
|||
|
|
defaultValues: { llm_factory: factory },
|
|||
|
|
};
|
|||
|
|
case LLM_FACTORY_LIST.TencentCloud:
|
|||
|
|
return {
|
|||
|
|
formItems: TENCENT_CLOUD_CONFIG,
|
|||
|
|
docLink,
|
|||
|
|
title: 'Tencent Cloud',
|
|||
|
|
defaultValues: { llm_factory: factory },
|
|||
|
|
};
|
|||
|
|
case LLM_FACTORY_LIST.TencentHunYuan:
|
|||
|
|
return {
|
|||
|
|
formItems: TENCENT_HUNYUAN_CONFIG,
|
|||
|
|
docLink,
|
|||
|
|
title: 'Tencent HunYuan',
|
|||
|
|
defaultValues: { llm_factory: factory },
|
|||
|
|
};
|
|||
|
|
case LLM_FACTORY_LIST.XunFeiSpark:
|
|||
|
|
return {
|
|||
|
|
formItems: XUNFEI_SPARK_CONFIG,
|
|||
|
|
docLink,
|
|||
|
|
title: 'XunFei Spark',
|
|||
|
|
defaultValues: { llm_factory: factory },
|
|||
|
|
};
|
|||
|
|
case LLM_FACTORY_LIST.VolcEngine:
|
|||
|
|
return {
|
|||
|
|
formItems: VOLC_ENGINE_CONFIG,
|
|||
|
|
docLink,
|
|||
|
|
title: 'Volc Engine',
|
|||
|
|
defaultValues: { llm_factory: factory },
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// local llm
|
|||
|
|
case LLM_FACTORY_LIST.Ollama:
|
|||
|
|
case LLM_FACTORY_LIST.Xinference:
|
|||
|
|
case LLM_FACTORY_LIST.ModelScope:
|
|||
|
|
case LLM_FACTORY_LIST.LocalAI:
|
|||
|
|
case LLM_FACTORY_LIST.LMStudio:
|
|||
|
|
case LLM_FACTORY_LIST.OpenAiAPICompatible:
|
|||
|
|
case LLM_FACTORY_LIST.TogetherAI:
|
|||
|
|
case LLM_FACTORY_LIST.Replicate:
|
|||
|
|
case LLM_FACTORY_LIST.OpenRouter:
|
|||
|
|
case LLM_FACTORY_LIST.HuggingFace:
|
|||
|
|
case LLM_FACTORY_LIST.GPUStack:
|
|||
|
|
case LLM_FACTORY_LIST.VLLM:
|
|||
|
|
default:
|
|||
|
|
// 根据不同的 factory 调整模型类型选项
|
|||
|
|
let modelTypeOptions = MODEL_TYPE_OPTIONS;
|
|||
|
|
let defaultApiBase = 'http://localhost:11434';
|
|||
|
|
|
|||
|
|
if (factory === LLM_FACTORY_LIST.HuggingFace) {
|
|||
|
|
modelTypeOptions = [
|
|||
|
|
{ value: 'embedding', label: 'Embedding' },
|
|||
|
|
{ value: 'chat', label: 'Chat' },
|
|||
|
|
{ value: 'rerank', label: 'Rerank' },
|
|||
|
|
];
|
|||
|
|
} else if (factory === LLM_FACTORY_LIST.Xinference) {
|
|||
|
|
modelTypeOptions = [
|
|||
|
|
{ value: 'chat', label: 'Chat' },
|
|||
|
|
{ value: 'embedding', label: 'Embedding' },
|
|||
|
|
{ value: 'rerank', label: 'Rerank' },
|
|||
|
|
{ value: 'image2text', label: 'Image2Text' },
|
|||
|
|
{ value: 'speech2text', label: 'Speech2Text' },
|
|||
|
|
{ value: 'tts', label: 'TTS' },
|
|||
|
|
];
|
|||
|
|
} else if (factory === LLM_FACTORY_LIST.ModelScope) {
|
|||
|
|
modelTypeOptions = [{ value: 'chat', label: 'Chat' }];
|
|||
|
|
} else if (factory === LLM_FACTORY_LIST.GPUStack) {
|
|||
|
|
modelTypeOptions = [
|
|||
|
|
{ value: 'chat', label: 'Chat' },
|
|||
|
|
{ value: 'embedding', label: 'Embedding' },
|
|||
|
|
{ value: 'rerank', label: 'Rerank' },
|
|||
|
|
{ value: 'image2text', label: 'Image2Text' },
|
|||
|
|
];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 根据不同 factory 设置不同的默认 API Base
|
|||
|
|
if (factory === LLM_FACTORY_LIST.Xinference) {
|
|||
|
|
defaultApiBase = 'http://localhost:9997';
|
|||
|
|
} else if (factory === LLM_FACTORY_LIST.LocalAI) {
|
|||
|
|
defaultApiBase = 'http://localhost:8080';
|
|||
|
|
} else if (factory === LLM_FACTORY_LIST.LMStudio) {
|
|||
|
|
defaultApiBase = 'http://localhost:1234';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const ollamaConfig = [...OLLAMA_CONFIG];
|
|||
|
|
// 更新模型类型选项
|
|||
|
|
ollamaConfig[0] = {
|
|||
|
|
...ollamaConfig[0],
|
|||
|
|
options: modelTypeOptions,
|
|||
|
|
};
|
|||
|
|
// 更新默认 API Base
|
|||
|
|
ollamaConfig[2] = {
|
|||
|
|
...ollamaConfig[2],
|
|||
|
|
defaultValue: defaultApiBase,
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
return {
|
|||
|
|
formItems: ollamaConfig,
|
|||
|
|
docLink,
|
|||
|
|
title: factory,
|
|||
|
|
defaultValues: { llm_factory: factory },
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
}
|