diff --git a/src/renderer/src/config/models.ts b/src/renderer/src/config/models.ts index e519152b..55d3b1a8 100644 --- a/src/renderer/src/config/models.ts +++ b/src/renderer/src/config/models.ts @@ -1,37 +1,34 @@ 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 = { +export const SYSTEM_MODELS: Record = { ollama: [], openai: [ { id: 'gpt-4o', provider: 'openai', name: ' GPT-4o', - group: 'GPT 4o', - enabled: true + group: 'GPT 4o' }, { id: 'gpt-4o-mini', provider: 'openai', name: ' GPT-4o-mini', - group: 'GPT 4o', - enabled: true + group: 'GPT 4o' }, { id: 'gpt-4-turbo', provider: 'openai', name: ' GPT-4 Turbo', - group: 'GPT 4', - enabled: true + group: 'GPT 4' }, { id: 'gpt-4', provider: 'openai', name: ' GPT-4', - group: 'GPT 4', - enabled: true + group: 'GPT 4' } ], gemini: [ @@ -39,15 +36,13 @@ export const SYSTEM_MODELS: Record = { id: 'gemini-1.5-flash', provider: 'gemini', name: 'Gemini 1.5 Flash', - group: 'Gemini 1.5', - enabled: true + group: 'Gemini 1.5' }, { id: 'gemini-1.5-pro-exp-0801', provider: 'gemini', name: 'Gemini 1.5 Pro Experimental 0801', - group: 'Gemini 1.5', - enabled: true + group: 'Gemini 1.5' } ], anthropic: [ @@ -55,29 +50,25 @@ export const SYSTEM_MODELS: Record = { id: 'claude-3-5-sonnet-20240620', provider: 'anthropic', name: 'Claude 3.5 Sonnet', - group: 'Claude 3.5', - enabled: true + group: 'Claude 3.5' }, { id: 'claude-3-opus-20240229', provider: 'anthropic', name: 'Claude 3 Opus', - group: 'Claude 3', - enabled: true + group: 'Claude 3' }, { id: 'claude-3-sonnet-20240229', provider: 'anthropic', name: 'Claude 3 Sonnet', - group: 'Claude 3', - enabled: true + group: 'Claude 3' }, { id: 'claude-3-haiku-20240307', provider: 'anthropic', name: 'Claude 3 Haiku', - group: 'Claude 3', - enabled: true + group: 'Claude 3' } ], silicon: [ @@ -85,8 +76,7 @@ export const SYSTEM_MODELS: Record = { id: 'Qwen/Qwen2-7B-Instruct', provider: 'silicon', name: 'Qwen2-7B-Instruct', - group: 'Qwen2', - enabled: true + group: 'Qwen2' }, { id: 'Qwen/Qwen2-1.5B-Instruct', @@ -106,8 +96,7 @@ export const SYSTEM_MODELS: Record = { id: 'Qwen/Qwen2-72B-Instruct', provider: 'silicon', name: 'Qwen2-72B-Instruct', - group: 'Qwen2', - enabled: true + group: 'Qwen2' }, { id: 'Qwen/Qwen2-57B-A14B-Instruct', @@ -162,8 +151,7 @@ export const SYSTEM_MODELS: Record = { id: 'THUDM/glm-4-9b-chat', provider: 'silicon', name: 'GLM-4-9B-Chat', - group: 'GLM', - enabled: true + group: 'GLM' }, { id: 'THUDM/chatglm3-6b', @@ -199,15 +187,13 @@ export const SYSTEM_MODELS: Record = { id: 'deepseek-chat', provider: 'deepseek', name: 'DeepSeek Chat', - group: 'DeepSeek Chat', - enabled: true + group: 'DeepSeek Chat' }, { id: 'deepseek-coder', provider: 'deepseek', name: 'DeepSeek Coder', - group: 'DeepSeek Coder', - enabled: true + group: 'DeepSeek Coder' } ], yi: [ @@ -222,8 +208,7 @@ export const SYSTEM_MODELS: Record = { id: 'yi-large-turbo', provider: 'yi', name: 'Yi-Large-Turbo', - group: 'Yi', - enabled: true + group: 'Yi' }, { id: 'yi-large-rag', @@ -236,8 +221,7 @@ export const SYSTEM_MODELS: Record = { id: 'yi-medium', provider: 'yi', name: 'Yi-Medium', - group: 'Yi', - enabled: true + group: 'Yi' }, { id: 'yi-medium-200k', @@ -273,8 +257,7 @@ export const SYSTEM_MODELS: Record = { id: 'glm-4-air', provider: 'zhipu', name: 'GLM-4-Air', - group: 'GLM-4', - enabled: true + group: 'GLM-4' }, { id: 'glm-4-airx', @@ -317,22 +300,19 @@ export const SYSTEM_MODELS: Record = { id: 'moonshot-v1-8k', provider: 'moonshot', name: 'Moonshot V1 8k', - group: 'Moonshot V1', - enabled: true + group: 'Moonshot V1' }, { id: 'moonshot-v1-32k', provider: 'moonshot', name: 'Moonshot V1 32k', - group: 'Moonshot V1', - enabled: true + group: 'Moonshot V1' }, { id: 'moonshot-v1-128k', provider: 'moonshot', name: 'Moonshot V1 128k', - group: 'Moonshot V1', - enabled: true + group: 'Moonshot V1' } ], baichuan: [ @@ -340,22 +320,19 @@ export const SYSTEM_MODELS: Record = { id: 'Baichuan4', provider: 'baichuan', name: 'Baichuan4', - group: 'Baichuan4', - enabled: true + group: 'Baichuan4' }, { id: 'Baichuan3-Turbo', provider: 'baichuan', name: 'Baichuan3 Turbo', - group: 'Baichuan3', - enabled: true + group: 'Baichuan3' }, { id: 'Baichuan3-Turbo-128k', provider: 'baichuan', name: 'Baichuan3 Turbo 128k', - group: 'Baichuan3', - enabled: true + group: 'Baichuan3' } ], dashscope: [ @@ -363,22 +340,19 @@ export const SYSTEM_MODELS: Record = { id: 'qwen-turbo', provider: 'dashscope', name: 'Qwen Turbo', - group: 'Qwen', - enabled: true + group: 'Qwen' }, { id: 'qwen-plus', provider: 'dashscope', name: 'Qwen Plus', - group: 'Qwen', - enabled: true + group: 'Qwen' }, { id: 'qwen-max', provider: 'dashscope', name: 'Qwen Max', - group: 'Qwen', - enabled: true + group: 'Qwen' } ], stepfun: [ @@ -386,15 +360,13 @@ export const SYSTEM_MODELS: Record = { id: 'step-1-8k', provider: 'stepfun', name: 'Step 1 8K', - group: 'Step 1', - enabled: true + group: 'Step 1' }, { id: 'step-1-flash', provider: 'stepfun', name: 'Step 1 Flash', - group: 'Step 1', - enabled: true + group: 'Step 1' } ], doubao: [], @@ -403,29 +375,25 @@ export const SYSTEM_MODELS: Record = { id: 'abab6.5s-chat', provider: 'minimax', name: 'abab6.5s', - group: 'abab6', - enabled: true + group: 'abab6' }, { id: 'abab6.5g-chat', provider: 'minimax', name: 'abab6.5g', - group: 'abab6', - enabled: true + group: 'abab6' }, { id: 'abab6.5t-chat', provider: 'minimax', name: 'abab6.5t', - group: 'abab6', - enabled: true + group: 'abab6' }, { id: 'abab5.5s-chat', provider: 'minimax', name: 'abab5.5s', - group: 'abab5', - enabled: true + group: 'abab5' } ], aihubmix: [ @@ -433,15 +401,13 @@ export const SYSTEM_MODELS: Record = { id: 'gpt-4o-mini', provider: 'aihubmix', name: 'GPT-4o Mini', - group: 'GPT-4o', - enabled: true + group: 'GPT-4o' }, { id: 'aihubmix-Llama-3-70B-Instruct', provider: 'aihubmix', name: 'Llama 3 70B Instruct', - group: 'Llama3', - enabled: true + group: 'Llama3' } ], openrouter: [ @@ -449,36 +415,31 @@ export const SYSTEM_MODELS: Record = { id: 'google/gemma-2-9b-it:free', provider: 'openrouter', name: 'Google: Gemma 2 9B', - group: 'Gemma', - enabled: true + group: 'Gemma' }, { id: 'microsoft/phi-3-mini-128k-instruct:free', provider: 'openrouter', name: 'Phi-3 Mini 128K Instruct', - group: 'Phi', - enabled: true + group: 'Phi' }, { id: 'microsoft/phi-3-medium-128k-instruct:free', provider: 'openrouter', name: 'Phi-3 Medium 128K Instruct', - group: 'Phi', - enabled: true + group: 'Phi' }, { id: 'meta-llama/llama-3-8b-instruct:free', provider: 'openrouter', name: 'Meta: Llama 3 8B Instruct', - group: 'Llama3', - enabled: true + group: 'Llama3' }, { id: 'mistralai/mistral-7b-instruct:free', provider: 'openrouter', name: 'Mistral: Mistral 7B Instruct', - group: 'Mistral', - enabled: true + group: 'Mistral' } ], groq: [ @@ -493,8 +454,7 @@ export const SYSTEM_MODELS: Record = { id: 'llama3-70b-8192', provider: 'groq', name: 'LLaMA3 70B', - group: 'Llama3', - enabled: true + group: 'Llama3' }, { id: 'mixtral-8x7b-32768', @@ -512,3 +472,11 @@ export const SYSTEM_MODELS: Record = { } ] } + +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) +} diff --git a/src/renderer/src/store/llm.ts b/src/renderer/src/store/llm.ts index 37846edf..dc25672f 100644 --- a/src/renderer/src/store/llm.ts +++ b/src/renderer/src/store/llm.ts @@ -28,7 +28,7 @@ const initialState: LlmState = { name: 'OpenAI', apiKey: '', apiHost: 'https://api.openai.com', - models: SYSTEM_MODELS.openai.filter((m) => m.enabled), + models: SYSTEM_MODELS.openai, isSystem: true, enabled: true }, @@ -37,7 +37,7 @@ const initialState: LlmState = { name: 'Gemini', apiKey: '', apiHost: 'https://generativelanguage.googleapis.com', - models: SYSTEM_MODELS.gemini.filter((m) => m.enabled), + models: SYSTEM_MODELS.gemini, isSystem: true, enabled: false }, @@ -46,7 +46,7 @@ const initialState: LlmState = { name: 'Anthropic', apiKey: '', apiHost: 'https://api.anthropic.com/', - models: SYSTEM_MODELS.anthropic.filter((m) => m.enabled), + models: SYSTEM_MODELS.anthropic, isSystem: true, enabled: false }, @@ -55,7 +55,7 @@ const initialState: LlmState = { name: 'Ollama', apiKey: '', apiHost: 'http://localhost:11434/v1/', - models: SYSTEM_MODELS.ollama.filter((m) => m.enabled), + models: SYSTEM_MODELS.ollama, isSystem: true, enabled: false }, @@ -64,7 +64,7 @@ const initialState: LlmState = { name: 'Silicon', apiKey: '', apiHost: 'https://api.siliconflow.cn', - models: SYSTEM_MODELS.silicon.filter((m) => m.enabled), + models: SYSTEM_MODELS.silicon, isSystem: true, enabled: false }, @@ -73,7 +73,7 @@ const initialState: LlmState = { name: 'deepseek', apiKey: '', apiHost: 'https://api.deepseek.com', - models: SYSTEM_MODELS.deepseek.filter((m) => m.enabled), + models: SYSTEM_MODELS.deepseek, isSystem: true, enabled: false }, @@ -82,7 +82,7 @@ const initialState: LlmState = { name: 'Yi', apiKey: '', apiHost: 'https://api.lingyiwanwu.com', - models: SYSTEM_MODELS.yi.filter((m) => m.enabled), + models: SYSTEM_MODELS.yi, isSystem: true, enabled: false }, @@ -91,7 +91,7 @@ const initialState: LlmState = { name: 'ZhiPu', apiKey: '', apiHost: 'https://open.bigmodel.cn/api/paas/v4/', - models: SYSTEM_MODELS.zhipu.filter((m) => m.enabled), + models: SYSTEM_MODELS.zhipu, isSystem: true, enabled: false }, @@ -100,7 +100,7 @@ const initialState: LlmState = { name: 'Moonshot AI', apiKey: '', apiHost: 'https://api.moonshot.cn', - models: SYSTEM_MODELS.moonshot.filter((m) => m.enabled), + models: SYSTEM_MODELS.moonshot, isSystem: true, enabled: false }, @@ -109,7 +109,7 @@ const initialState: LlmState = { name: 'BAICHUAN AI', apiKey: '', apiHost: 'https://api.baichuan-ai.com', - models: SYSTEM_MODELS.baichuan.filter((m) => m.enabled), + models: SYSTEM_MODELS.baichuan, isSystem: true, enabled: false }, @@ -118,7 +118,7 @@ const initialState: LlmState = { name: 'DashScope', apiKey: '', apiHost: 'https://dashscope.aliyuncs.com/compatible-mode/v1/', - models: SYSTEM_MODELS.dashscope.filter((m) => m.enabled), + models: SYSTEM_MODELS.dashscope, isSystem: true, enabled: false }, @@ -127,7 +127,7 @@ const initialState: LlmState = { name: 'StepFun', apiKey: '', apiHost: 'https://api.stepfun.com', - models: SYSTEM_MODELS.stepfun.filter((m) => m.enabled), + models: SYSTEM_MODELS.stepfun, isSystem: true, enabled: false }, @@ -136,7 +136,7 @@ const initialState: LlmState = { name: 'doubao', apiKey: '', apiHost: 'https://ark.cn-beijing.volces.com/api/v3/', - models: SYSTEM_MODELS.doubao.filter((m) => m.enabled), + models: SYSTEM_MODELS.doubao, isSystem: true, enabled: false }, @@ -145,7 +145,7 @@ const initialState: LlmState = { name: 'MiniMax', apiKey: '', apiHost: 'https://api.minimax.chat/v1/', - models: SYSTEM_MODELS.minimax.filter((m) => m.enabled), + models: SYSTEM_MODELS.minimax, isSystem: true, enabled: false }, @@ -154,7 +154,7 @@ const initialState: LlmState = { name: 'AiHubMix', apiKey: '', apiHost: 'https://aihubmix.com', - models: SYSTEM_MODELS.aihubmix.filter((m) => m.enabled), + models: SYSTEM_MODELS.aihubmix, isSystem: true, enabled: false }, @@ -172,7 +172,7 @@ const initialState: LlmState = { name: 'OpenRouter', apiKey: '', apiHost: 'https://openrouter.ai/api/v1/', - models: SYSTEM_MODELS.openrouter.filter((m) => m.enabled), + models: SYSTEM_MODELS.openrouter, isSystem: true, enabled: false }, @@ -181,7 +181,7 @@ const initialState: LlmState = { name: 'Groq', apiKey: '', apiHost: 'https://api.groq.com/openai', - models: SYSTEM_MODELS.groq.filter((m) => m.enabled), + models: SYSTEM_MODELS.groq, isSystem: true, enabled: false }