refactor: remove models config enabled

This commit is contained in:
kangfenmao 2024-09-03 11:40:46 +08:00
parent ace0cb7823
commit 9ee763337d
2 changed files with 69 additions and 101 deletions

View File

@ -1,37 +1,34 @@
import { Model } from '@renderer/types' import { Model } from '@renderer/types'
type SystemModel = Model & { enabled: boolean } const TEXT_TO_IMAGE_REGEX = /flux|diffusion|stabilityai|sd-turbo|dall|cogview/i
const EMBEDDING_REGEX = /embedding/i
export const SYSTEM_MODELS: Record<string, SystemModel[]> = { export const SYSTEM_MODELS: Record<string, Model[]> = {
ollama: [], ollama: [],
openai: [ openai: [
{ {
id: 'gpt-4o', id: 'gpt-4o',
provider: 'openai', provider: 'openai',
name: ' GPT-4o', name: ' GPT-4o',
group: 'GPT 4o', group: 'GPT 4o'
enabled: true
}, },
{ {
id: 'gpt-4o-mini', id: 'gpt-4o-mini',
provider: 'openai', provider: 'openai',
name: ' GPT-4o-mini', name: ' GPT-4o-mini',
group: 'GPT 4o', group: 'GPT 4o'
enabled: true
}, },
{ {
id: 'gpt-4-turbo', id: 'gpt-4-turbo',
provider: 'openai', provider: 'openai',
name: ' GPT-4 Turbo', name: ' GPT-4 Turbo',
group: 'GPT 4', group: 'GPT 4'
enabled: true
}, },
{ {
id: 'gpt-4', id: 'gpt-4',
provider: 'openai', provider: 'openai',
name: ' GPT-4', name: ' GPT-4',
group: 'GPT 4', group: 'GPT 4'
enabled: true
} }
], ],
gemini: [ gemini: [
@ -39,15 +36,13 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'gemini-1.5-flash', id: 'gemini-1.5-flash',
provider: 'gemini', provider: 'gemini',
name: 'Gemini 1.5 Flash', name: 'Gemini 1.5 Flash',
group: 'Gemini 1.5', group: 'Gemini 1.5'
enabled: true
}, },
{ {
id: 'gemini-1.5-pro-exp-0801', id: 'gemini-1.5-pro-exp-0801',
provider: 'gemini', provider: 'gemini',
name: 'Gemini 1.5 Pro Experimental 0801', name: 'Gemini 1.5 Pro Experimental 0801',
group: 'Gemini 1.5', group: 'Gemini 1.5'
enabled: true
} }
], ],
anthropic: [ anthropic: [
@ -55,29 +50,25 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'claude-3-5-sonnet-20240620', id: 'claude-3-5-sonnet-20240620',
provider: 'anthropic', provider: 'anthropic',
name: 'Claude 3.5 Sonnet', name: 'Claude 3.5 Sonnet',
group: 'Claude 3.5', group: 'Claude 3.5'
enabled: true
}, },
{ {
id: 'claude-3-opus-20240229', id: 'claude-3-opus-20240229',
provider: 'anthropic', provider: 'anthropic',
name: 'Claude 3 Opus', name: 'Claude 3 Opus',
group: 'Claude 3', group: 'Claude 3'
enabled: true
}, },
{ {
id: 'claude-3-sonnet-20240229', id: 'claude-3-sonnet-20240229',
provider: 'anthropic', provider: 'anthropic',
name: 'Claude 3 Sonnet', name: 'Claude 3 Sonnet',
group: 'Claude 3', group: 'Claude 3'
enabled: true
}, },
{ {
id: 'claude-3-haiku-20240307', id: 'claude-3-haiku-20240307',
provider: 'anthropic', provider: 'anthropic',
name: 'Claude 3 Haiku', name: 'Claude 3 Haiku',
group: 'Claude 3', group: 'Claude 3'
enabled: true
} }
], ],
silicon: [ silicon: [
@ -85,8 +76,7 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'Qwen/Qwen2-7B-Instruct', id: 'Qwen/Qwen2-7B-Instruct',
provider: 'silicon', provider: 'silicon',
name: 'Qwen2-7B-Instruct', name: 'Qwen2-7B-Instruct',
group: 'Qwen2', group: 'Qwen2'
enabled: true
}, },
{ {
id: 'Qwen/Qwen2-1.5B-Instruct', id: 'Qwen/Qwen2-1.5B-Instruct',
@ -106,8 +96,7 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'Qwen/Qwen2-72B-Instruct', id: 'Qwen/Qwen2-72B-Instruct',
provider: 'silicon', provider: 'silicon',
name: 'Qwen2-72B-Instruct', name: 'Qwen2-72B-Instruct',
group: 'Qwen2', group: 'Qwen2'
enabled: true
}, },
{ {
id: 'Qwen/Qwen2-57B-A14B-Instruct', id: 'Qwen/Qwen2-57B-A14B-Instruct',
@ -162,8 +151,7 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'THUDM/glm-4-9b-chat', id: 'THUDM/glm-4-9b-chat',
provider: 'silicon', provider: 'silicon',
name: 'GLM-4-9B-Chat', name: 'GLM-4-9B-Chat',
group: 'GLM', group: 'GLM'
enabled: true
}, },
{ {
id: 'THUDM/chatglm3-6b', id: 'THUDM/chatglm3-6b',
@ -199,15 +187,13 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'deepseek-chat', id: 'deepseek-chat',
provider: 'deepseek', provider: 'deepseek',
name: 'DeepSeek Chat', name: 'DeepSeek Chat',
group: 'DeepSeek Chat', group: 'DeepSeek Chat'
enabled: true
}, },
{ {
id: 'deepseek-coder', id: 'deepseek-coder',
provider: 'deepseek', provider: 'deepseek',
name: 'DeepSeek Coder', name: 'DeepSeek Coder',
group: 'DeepSeek Coder', group: 'DeepSeek Coder'
enabled: true
} }
], ],
yi: [ yi: [
@ -222,8 +208,7 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'yi-large-turbo', id: 'yi-large-turbo',
provider: 'yi', provider: 'yi',
name: 'Yi-Large-Turbo', name: 'Yi-Large-Turbo',
group: 'Yi', group: 'Yi'
enabled: true
}, },
{ {
id: 'yi-large-rag', id: 'yi-large-rag',
@ -236,8 +221,7 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'yi-medium', id: 'yi-medium',
provider: 'yi', provider: 'yi',
name: 'Yi-Medium', name: 'Yi-Medium',
group: 'Yi', group: 'Yi'
enabled: true
}, },
{ {
id: 'yi-medium-200k', id: 'yi-medium-200k',
@ -273,8 +257,7 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'glm-4-air', id: 'glm-4-air',
provider: 'zhipu', provider: 'zhipu',
name: 'GLM-4-Air', name: 'GLM-4-Air',
group: 'GLM-4', group: 'GLM-4'
enabled: true
}, },
{ {
id: 'glm-4-airx', id: 'glm-4-airx',
@ -317,22 +300,19 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'moonshot-v1-8k', id: 'moonshot-v1-8k',
provider: 'moonshot', provider: 'moonshot',
name: 'Moonshot V1 8k', name: 'Moonshot V1 8k',
group: 'Moonshot V1', group: 'Moonshot V1'
enabled: true
}, },
{ {
id: 'moonshot-v1-32k', id: 'moonshot-v1-32k',
provider: 'moonshot', provider: 'moonshot',
name: 'Moonshot V1 32k', name: 'Moonshot V1 32k',
group: 'Moonshot V1', group: 'Moonshot V1'
enabled: true
}, },
{ {
id: 'moonshot-v1-128k', id: 'moonshot-v1-128k',
provider: 'moonshot', provider: 'moonshot',
name: 'Moonshot V1 128k', name: 'Moonshot V1 128k',
group: 'Moonshot V1', group: 'Moonshot V1'
enabled: true
} }
], ],
baichuan: [ baichuan: [
@ -340,22 +320,19 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'Baichuan4', id: 'Baichuan4',
provider: 'baichuan', provider: 'baichuan',
name: 'Baichuan4', name: 'Baichuan4',
group: 'Baichuan4', group: 'Baichuan4'
enabled: true
}, },
{ {
id: 'Baichuan3-Turbo', id: 'Baichuan3-Turbo',
provider: 'baichuan', provider: 'baichuan',
name: 'Baichuan3 Turbo', name: 'Baichuan3 Turbo',
group: 'Baichuan3', group: 'Baichuan3'
enabled: true
}, },
{ {
id: 'Baichuan3-Turbo-128k', id: 'Baichuan3-Turbo-128k',
provider: 'baichuan', provider: 'baichuan',
name: 'Baichuan3 Turbo 128k', name: 'Baichuan3 Turbo 128k',
group: 'Baichuan3', group: 'Baichuan3'
enabled: true
} }
], ],
dashscope: [ dashscope: [
@ -363,22 +340,19 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'qwen-turbo', id: 'qwen-turbo',
provider: 'dashscope', provider: 'dashscope',
name: 'Qwen Turbo', name: 'Qwen Turbo',
group: 'Qwen', group: 'Qwen'
enabled: true
}, },
{ {
id: 'qwen-plus', id: 'qwen-plus',
provider: 'dashscope', provider: 'dashscope',
name: 'Qwen Plus', name: 'Qwen Plus',
group: 'Qwen', group: 'Qwen'
enabled: true
}, },
{ {
id: 'qwen-max', id: 'qwen-max',
provider: 'dashscope', provider: 'dashscope',
name: 'Qwen Max', name: 'Qwen Max',
group: 'Qwen', group: 'Qwen'
enabled: true
} }
], ],
stepfun: [ stepfun: [
@ -386,15 +360,13 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'step-1-8k', id: 'step-1-8k',
provider: 'stepfun', provider: 'stepfun',
name: 'Step 1 8K', name: 'Step 1 8K',
group: 'Step 1', group: 'Step 1'
enabled: true
}, },
{ {
id: 'step-1-flash', id: 'step-1-flash',
provider: 'stepfun', provider: 'stepfun',
name: 'Step 1 Flash', name: 'Step 1 Flash',
group: 'Step 1', group: 'Step 1'
enabled: true
} }
], ],
doubao: [], doubao: [],
@ -403,29 +375,25 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'abab6.5s-chat', id: 'abab6.5s-chat',
provider: 'minimax', provider: 'minimax',
name: 'abab6.5s', name: 'abab6.5s',
group: 'abab6', group: 'abab6'
enabled: true
}, },
{ {
id: 'abab6.5g-chat', id: 'abab6.5g-chat',
provider: 'minimax', provider: 'minimax',
name: 'abab6.5g', name: 'abab6.5g',
group: 'abab6', group: 'abab6'
enabled: true
}, },
{ {
id: 'abab6.5t-chat', id: 'abab6.5t-chat',
provider: 'minimax', provider: 'minimax',
name: 'abab6.5t', name: 'abab6.5t',
group: 'abab6', group: 'abab6'
enabled: true
}, },
{ {
id: 'abab5.5s-chat', id: 'abab5.5s-chat',
provider: 'minimax', provider: 'minimax',
name: 'abab5.5s', name: 'abab5.5s',
group: 'abab5', group: 'abab5'
enabled: true
} }
], ],
aihubmix: [ aihubmix: [
@ -433,15 +401,13 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'gpt-4o-mini', id: 'gpt-4o-mini',
provider: 'aihubmix', provider: 'aihubmix',
name: 'GPT-4o Mini', name: 'GPT-4o Mini',
group: 'GPT-4o', group: 'GPT-4o'
enabled: true
}, },
{ {
id: 'aihubmix-Llama-3-70B-Instruct', id: 'aihubmix-Llama-3-70B-Instruct',
provider: 'aihubmix', provider: 'aihubmix',
name: 'Llama 3 70B Instruct', name: 'Llama 3 70B Instruct',
group: 'Llama3', group: 'Llama3'
enabled: true
} }
], ],
openrouter: [ openrouter: [
@ -449,36 +415,31 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'google/gemma-2-9b-it:free', id: 'google/gemma-2-9b-it:free',
provider: 'openrouter', provider: 'openrouter',
name: 'Google: Gemma 2 9B', name: 'Google: Gemma 2 9B',
group: 'Gemma', group: 'Gemma'
enabled: true
}, },
{ {
id: 'microsoft/phi-3-mini-128k-instruct:free', id: 'microsoft/phi-3-mini-128k-instruct:free',
provider: 'openrouter', provider: 'openrouter',
name: 'Phi-3 Mini 128K Instruct', name: 'Phi-3 Mini 128K Instruct',
group: 'Phi', group: 'Phi'
enabled: true
}, },
{ {
id: 'microsoft/phi-3-medium-128k-instruct:free', id: 'microsoft/phi-3-medium-128k-instruct:free',
provider: 'openrouter', provider: 'openrouter',
name: 'Phi-3 Medium 128K Instruct', name: 'Phi-3 Medium 128K Instruct',
group: 'Phi', group: 'Phi'
enabled: true
}, },
{ {
id: 'meta-llama/llama-3-8b-instruct:free', id: 'meta-llama/llama-3-8b-instruct:free',
provider: 'openrouter', provider: 'openrouter',
name: 'Meta: Llama 3 8B Instruct', name: 'Meta: Llama 3 8B Instruct',
group: 'Llama3', group: 'Llama3'
enabled: true
}, },
{ {
id: 'mistralai/mistral-7b-instruct:free', id: 'mistralai/mistral-7b-instruct:free',
provider: 'openrouter', provider: 'openrouter',
name: 'Mistral: Mistral 7B Instruct', name: 'Mistral: Mistral 7B Instruct',
group: 'Mistral', group: 'Mistral'
enabled: true
} }
], ],
groq: [ groq: [
@ -493,8 +454,7 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
id: 'llama3-70b-8192', id: 'llama3-70b-8192',
provider: 'groq', provider: 'groq',
name: 'LLaMA3 70B', name: 'LLaMA3 70B',
group: 'Llama3', group: 'Llama3'
enabled: true
}, },
{ {
id: 'mixtral-8x7b-32768', id: 'mixtral-8x7b-32768',
@ -512,3 +472,11 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
} }
] ]
} }
export function isTextToImageModel(model: Model): boolean {
return TEXT_TO_IMAGE_REGEX.test(model.id)
}
export function isEmbeddingModel(model: Model): boolean {
return EMBEDDING_REGEX.test(model.id)
}

View File

@ -28,7 +28,7 @@ const initialState: LlmState = {
name: 'OpenAI', name: 'OpenAI',
apiKey: '', apiKey: '',
apiHost: 'https://api.openai.com', apiHost: 'https://api.openai.com',
models: SYSTEM_MODELS.openai.filter((m) => m.enabled), models: SYSTEM_MODELS.openai,
isSystem: true, isSystem: true,
enabled: true enabled: true
}, },
@ -37,7 +37,7 @@ const initialState: LlmState = {
name: 'Gemini', name: 'Gemini',
apiKey: '', apiKey: '',
apiHost: 'https://generativelanguage.googleapis.com', apiHost: 'https://generativelanguage.googleapis.com',
models: SYSTEM_MODELS.gemini.filter((m) => m.enabled), models: SYSTEM_MODELS.gemini,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -46,7 +46,7 @@ const initialState: LlmState = {
name: 'Anthropic', name: 'Anthropic',
apiKey: '', apiKey: '',
apiHost: 'https://api.anthropic.com/', apiHost: 'https://api.anthropic.com/',
models: SYSTEM_MODELS.anthropic.filter((m) => m.enabled), models: SYSTEM_MODELS.anthropic,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -55,7 +55,7 @@ const initialState: LlmState = {
name: 'Ollama', name: 'Ollama',
apiKey: '', apiKey: '',
apiHost: 'http://localhost:11434/v1/', apiHost: 'http://localhost:11434/v1/',
models: SYSTEM_MODELS.ollama.filter((m) => m.enabled), models: SYSTEM_MODELS.ollama,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -64,7 +64,7 @@ const initialState: LlmState = {
name: 'Silicon', name: 'Silicon',
apiKey: '', apiKey: '',
apiHost: 'https://api.siliconflow.cn', apiHost: 'https://api.siliconflow.cn',
models: SYSTEM_MODELS.silicon.filter((m) => m.enabled), models: SYSTEM_MODELS.silicon,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -73,7 +73,7 @@ const initialState: LlmState = {
name: 'deepseek', name: 'deepseek',
apiKey: '', apiKey: '',
apiHost: 'https://api.deepseek.com', apiHost: 'https://api.deepseek.com',
models: SYSTEM_MODELS.deepseek.filter((m) => m.enabled), models: SYSTEM_MODELS.deepseek,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -82,7 +82,7 @@ const initialState: LlmState = {
name: 'Yi', name: 'Yi',
apiKey: '', apiKey: '',
apiHost: 'https://api.lingyiwanwu.com', apiHost: 'https://api.lingyiwanwu.com',
models: SYSTEM_MODELS.yi.filter((m) => m.enabled), models: SYSTEM_MODELS.yi,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -91,7 +91,7 @@ const initialState: LlmState = {
name: 'ZhiPu', name: 'ZhiPu',
apiKey: '', apiKey: '',
apiHost: 'https://open.bigmodel.cn/api/paas/v4/', apiHost: 'https://open.bigmodel.cn/api/paas/v4/',
models: SYSTEM_MODELS.zhipu.filter((m) => m.enabled), models: SYSTEM_MODELS.zhipu,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -100,7 +100,7 @@ const initialState: LlmState = {
name: 'Moonshot AI', name: 'Moonshot AI',
apiKey: '', apiKey: '',
apiHost: 'https://api.moonshot.cn', apiHost: 'https://api.moonshot.cn',
models: SYSTEM_MODELS.moonshot.filter((m) => m.enabled), models: SYSTEM_MODELS.moonshot,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -109,7 +109,7 @@ const initialState: LlmState = {
name: 'BAICHUAN AI', name: 'BAICHUAN AI',
apiKey: '', apiKey: '',
apiHost: 'https://api.baichuan-ai.com', apiHost: 'https://api.baichuan-ai.com',
models: SYSTEM_MODELS.baichuan.filter((m) => m.enabled), models: SYSTEM_MODELS.baichuan,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -118,7 +118,7 @@ const initialState: LlmState = {
name: 'DashScope', name: 'DashScope',
apiKey: '', apiKey: '',
apiHost: 'https://dashscope.aliyuncs.com/compatible-mode/v1/', apiHost: 'https://dashscope.aliyuncs.com/compatible-mode/v1/',
models: SYSTEM_MODELS.dashscope.filter((m) => m.enabled), models: SYSTEM_MODELS.dashscope,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -127,7 +127,7 @@ const initialState: LlmState = {
name: 'StepFun', name: 'StepFun',
apiKey: '', apiKey: '',
apiHost: 'https://api.stepfun.com', apiHost: 'https://api.stepfun.com',
models: SYSTEM_MODELS.stepfun.filter((m) => m.enabled), models: SYSTEM_MODELS.stepfun,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -136,7 +136,7 @@ const initialState: LlmState = {
name: 'doubao', name: 'doubao',
apiKey: '', apiKey: '',
apiHost: 'https://ark.cn-beijing.volces.com/api/v3/', apiHost: 'https://ark.cn-beijing.volces.com/api/v3/',
models: SYSTEM_MODELS.doubao.filter((m) => m.enabled), models: SYSTEM_MODELS.doubao,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -145,7 +145,7 @@ const initialState: LlmState = {
name: 'MiniMax', name: 'MiniMax',
apiKey: '', apiKey: '',
apiHost: 'https://api.minimax.chat/v1/', apiHost: 'https://api.minimax.chat/v1/',
models: SYSTEM_MODELS.minimax.filter((m) => m.enabled), models: SYSTEM_MODELS.minimax,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -154,7 +154,7 @@ const initialState: LlmState = {
name: 'AiHubMix', name: 'AiHubMix',
apiKey: '', apiKey: '',
apiHost: 'https://aihubmix.com', apiHost: 'https://aihubmix.com',
models: SYSTEM_MODELS.aihubmix.filter((m) => m.enabled), models: SYSTEM_MODELS.aihubmix,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -172,7 +172,7 @@ const initialState: LlmState = {
name: 'OpenRouter', name: 'OpenRouter',
apiKey: '', apiKey: '',
apiHost: 'https://openrouter.ai/api/v1/', apiHost: 'https://openrouter.ai/api/v1/',
models: SYSTEM_MODELS.openrouter.filter((m) => m.enabled), models: SYSTEM_MODELS.openrouter,
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
@ -181,7 +181,7 @@ const initialState: LlmState = {
name: 'Groq', name: 'Groq',
apiKey: '', apiKey: '',
apiHost: 'https://api.groq.com/openai', apiHost: 'https://api.groq.com/openai',
models: SYSTEM_MODELS.groq.filter((m) => m.enabled), models: SYSTEM_MODELS.groq,
isSystem: true, isSystem: true,
enabled: false enabled: false
} }