From 3b90afba48d6b47642368aa301fd104804ff081e Mon Sep 17 00:00:00 2001 From: zenith110 Date: Tue, 22 Oct 2024 18:19:27 -0400 Subject: [PATCH] Added deepseek models --- app/lib/.server/llm/api-key.ts | 2 ++ app/lib/.server/llm/model.ts | 10 ++++++++++ app/utils/constants.ts | 2 ++ worker-configuration.d.ts | 1 + 4 files changed, 15 insertions(+) diff --git a/app/lib/.server/llm/api-key.ts b/app/lib/.server/llm/api-key.ts index b1a47f428..54f7a3102 100644 --- a/app/lib/.server/llm/api-key.ts +++ b/app/lib/.server/llm/api-key.ts @@ -19,6 +19,8 @@ export function getAPIKey(cloudflareEnv: Env, provider: string) { return env.GROQ_API_KEY || cloudflareEnv.GROQ_API_KEY; case 'OpenRouter': return env.OPEN_ROUTER_API_KEY || cloudflareEnv.OPEN_ROUTER_API_KEY; + case 'Deepseek': + return env.DEEPSEEK_API_KEY || cloudflareEnv.DEEPSEEK_API_KEY default: return ""; } diff --git a/app/lib/.server/llm/model.ts b/app/lib/.server/llm/model.ts index 68983756d..6d5e4be97 100644 --- a/app/lib/.server/llm/model.ts +++ b/app/lib/.server/llm/model.ts @@ -40,6 +40,14 @@ export function getGroqModel(apiKey: string, model: string) { return openai(model); } +export function getDeepseekModel(apiKey: string, model: string){ + const openai = createOpenAI({ + baseURL: 'https://api.deepseek.com/beta', + apiKey, + }); + + return openai(model); +} export function getOllamaModel(model: string) { return ollama(model); } @@ -67,6 +75,8 @@ export function getModel(provider: string, model: string, env: Env) { return getOpenRouterModel(apiKey, model); case 'Google': return getGoogleModel(apiKey, model) + case 'Deepseek': + return getDeepseekModel(apiKey, model) default: return getOllamaModel(model); } diff --git a/app/utils/constants.ts b/app/utils/constants.ts index 6db860c53..c080423f8 100644 --- a/app/utils/constants.ts +++ b/app/utils/constants.ts @@ -30,6 +30,8 @@ const staticModels: ModelInfo[] = [ { name: 'gpt-4-turbo', label: 'GPT-4 Turbo', provider: 'OpenAI' }, { name: 'gpt-4', label: 'GPT-4', provider: 'OpenAI' }, { name: 'gpt-3.5-turbo', label: 'GPT-3.5 Turbo', provider: 'OpenAI' }, + { name: 'deepseek-coder', label: 'Deepseek-Coder', provider: 'Deepseek'}, + { name: 'deepseek-chat', label: 'Deepseek-Chat', provider: 'Deepseek'}, ]; export let MODEL_LIST: ModelInfo[] = [...staticModels]; diff --git a/worker-configuration.d.ts b/worker-configuration.d.ts index f3259893e..2f7f64234 100644 --- a/worker-configuration.d.ts +++ b/worker-configuration.d.ts @@ -4,4 +4,5 @@ interface Env { GROQ_API_KEY: string; OPEN_ROUTER_API_KEY: string; OLLAMA_API_BASE_URL: string; + DEEPSEEK_API_KEY: string; }