From 112395002c60dbf65464ba11ec59be1d02737610 Mon Sep 17 00:00:00 2001 From: cesar Date: Sun, 21 Jul 2024 21:36:40 +0800 Subject: [PATCH 1/3] Add DeepSeek API bots --- public/bots/deepseek.svg | 6 ++ src/bots/deepseek/DeepSeekAPIBot.js | 40 ++++++++++++ src/bots/deepseek/DeepSeekAPIChatBot.js | 10 +++ src/bots/deepseek/DeepSeekAPICoderBot.js | 10 +++ src/bots/index.js | 4 ++ .../BotSettings/DeepSeekAPIBotSettings.vue | 63 +++++++++++++++++++ src/components/SettingsModal.vue | 2 + src/i18n/locales/en.json | 5 ++ src/i18n/locales/zh.json | 5 ++ src/store/index.js | 8 +++ 10 files changed, 153 insertions(+) create mode 100644 public/bots/deepseek.svg create mode 100644 src/bots/deepseek/DeepSeekAPIBot.js create mode 100644 src/bots/deepseek/DeepSeekAPIChatBot.js create mode 100644 src/bots/deepseek/DeepSeekAPICoderBot.js create mode 100644 src/components/BotSettings/DeepSeekAPIBotSettings.vue diff --git a/public/bots/deepseek.svg b/public/bots/deepseek.svg new file mode 100644 index 000000000..a76ba1b10 --- /dev/null +++ b/public/bots/deepseek.svg @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/src/bots/deepseek/DeepSeekAPIBot.js b/src/bots/deepseek/DeepSeekAPIBot.js new file mode 100644 index 000000000..ef24f3e5e --- /dev/null +++ b/src/bots/deepseek/DeepSeekAPIBot.js @@ -0,0 +1,40 @@ +import LangChainBot from "../LangChainBot"; +import { ChatOpenAI } from "@langchain/openai"; +import store from "@/store"; + +export default class DeepSeekAPIBot extends LangChainBot { + static _brandId = "deepSeekApi"; // Brand id of the bot, should be unique. Used in i18n. + static _className = "DeepSeekAPIBot"; + static _logoFilename = "deepseek.svg"; + + constructor() { + super(); + } + + async _checkAvailability() { + let available = false; + + if (store.state.deepSeekApi.apiKey) { + this.setupModel(); + available = true; + } + return available; + } + + _setupModel() { + const chatModel = new ChatOpenAI({ + configuration: { + basePath: "https://api.deepseek.com/v1", + }, + openAIApiKey: store.state.deepSeekApi.apiKey, + modelName: this.constructor._model ? this.constructor._model : "", + temperature: store.state.deepSeekApi.temperature, + streaming: true, + }); + return chatModel; + } + + getPastRounds() { + return store.state.deepSeekApi.pastRounds; + } +} diff --git a/src/bots/deepseek/DeepSeekAPIChatBot.js b/src/bots/deepseek/DeepSeekAPIChatBot.js new file mode 100644 index 000000000..d1622aff2 --- /dev/null +++ b/src/bots/deepseek/DeepSeekAPIChatBot.js @@ -0,0 +1,10 @@ +import DeepSeekAPIBot from "./DeepSeekAPIBot"; + +export default class DeepSeekAPIChatBot extends DeepSeekAPIBot { + static _className = "DeepSeekAPIChatBot"; + static _model = "deepseek-chat"; + + constructor() { + super(); + } +} diff --git a/src/bots/deepseek/DeepSeekAPICoderBot.js b/src/bots/deepseek/DeepSeekAPICoderBot.js new file mode 100644 index 000000000..ea1f66467 --- /dev/null +++ b/src/bots/deepseek/DeepSeekAPICoderBot.js @@ -0,0 +1,10 @@ +import DeepSeekAPIBot from "./DeepSeekAPIBot"; + +export default class DeepSeekAPICoderBot extends DeepSeekAPIBot { + static _className = "DeepSeekAPICoderBot"; + static _model = "deepseek-coder"; + + constructor() { + super(); + } +} diff --git a/src/bots/index.js b/src/bots/index.js index ffbcbca80..94afd2cfa 100644 --- a/src/bots/index.js +++ b/src/bots/index.js @@ -85,6 +85,8 @@ import ClaudeAPISonnetBot from "./anthropic/ClaudeAPISonnetBot"; import ClaudeAPI35SonnetBot from "./anthropic/ClaudeAPI35SonnetBot"; import ClaudeAPIHaikuBot from "./anthropic/ClaudeAPIHaikuBot"; import ClaudeAPIInstant12Bot from "./anthropic/ClaudeAPIInstant12Bot"; +import DeepSeekAPICoderBot from "./deepseek/DeepSeekAPICoderBot"; +import DeepSeekAPIChatBot from "./deepseek/DeepSeekAPIChatBot"; const all = [ Qihoo360AIBrainBot.getInstance(), @@ -172,6 +174,8 @@ const all = [ Wizardlm70bBot.getInstance(), Zephyr7bBot.getInstance(), YouChatBot.getInstance(), + DeepSeekAPICoderBot.getInstance(), + DeepSeekAPIChatBot.getInstance(), ]; const disabled = [ diff --git a/src/components/BotSettings/DeepSeekAPIBotSettings.vue b/src/components/BotSettings/DeepSeekAPIBotSettings.vue new file mode 100644 index 000000000..7f74fc1d0 --- /dev/null +++ b/src/components/BotSettings/DeepSeekAPIBotSettings.vue @@ -0,0 +1,63 @@ + + + diff --git a/src/components/SettingsModal.vue b/src/components/SettingsModal.vue index c47aedf88..760b85bd3 100644 --- a/src/components/SettingsModal.vue +++ b/src/components/SettingsModal.vue @@ -126,6 +126,7 @@ import ClaudeAIBotSettings from "./BotSettings/ClaudeAIBotSettings.vue"; import ChatGLMBotSettings from "./BotSettings/ChatGLMBotSettings.vue"; import CohereAPIBotSettings from "./BotSettings/CohereAPIBotSettings.vue"; import KimiBotSettings from "./BotSettings/KimiBotSettings.vue"; +import DeepSeekAPIBotSettings from "./BotSettings/DeepSeekAPIBotSettings.vue"; import { resolveTheme, applyTheme, Mode } from "../theme"; import ClaudeAPIBotSettings from "./BotSettings/ClaudeAPIBotSettings.vue"; @@ -152,6 +153,7 @@ const botSettings = [ { brand: "claudeAi", component: ClaudeAIBotSettings }, { brand: "claudeApi", component: ClaudeAPIBotSettings }, { brand: "cohereApi", component: CohereAPIBotSettings }, + { brand: "deepSeekApi", component: DeepSeekAPIBotSettings }, { brand: "falcon", component: Falcon180bBotSettings }, { brand: "geminiApi", component: GeminiAPIBotSettings }, { brand: "gradio", component: GradioAppBotSettings }, diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index d6db59f9b..8041f82b9 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -243,6 +243,11 @@ "temperature0": "More deterministic", "temperature2": "More random" }, + "deepSeekApi": { + "name": "DeepSeek API", + "deepseek-chat": "deepseek-chat", + "deepseek-coder": "deepseek-coder" + }, "poe": { "name": "Poe", "a2": "Claude-instant", diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index 5e2d488e3..65c614ae6 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -243,6 +243,11 @@ "temperature0": "更具确定性", "temperature2": "更具随机性" }, + "deepSeekApi": { + "name": "DeepSeek API", + "deepseek-chat": "deepseek-chat", + "deepseek-coder": "deepseek-coder" + }, "poe": { "name": "Poe", "a2": "Claude-instant", diff --git a/src/store/index.js b/src/store/index.js index 85ff9b15f..5e899c25b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -45,6 +45,11 @@ export default createStore({ temperature: 0.8, pastRounds: 5, }, + deepSeekApi: { + apiKey: "", + temperature: 1.0, + pastRounds: 10, + }, openaiApi: { apiKey: "", temperature: 1, @@ -213,6 +218,9 @@ export default createStore({ setChatgpt(state, refreshCycle) { state.chatgpt.refreshCycle = refreshCycle; }, + setDeepSeekApi(state, values) { + state.deepSeekApi = { ...state.deepSeekApi, ...values }; + }, setGeminiApi(state, values) { state.geminiApi = { ...state.geminiApi, ...values }; }, From 21c678238a9fe7c1d0ce54ad4d42f9735c374067 Mon Sep 17 00:00:00 2001 From: cesar Date: Sun, 21 Jul 2024 22:07:57 +0800 Subject: [PATCH 2/3] Add DeepSeek to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 00b3e859a..e252d6824 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Typical users of ChatALL are: | [Cohere Command R Models](https://cohere.com/command) | No | Yes | | | [Copilot](https://copilot.microsoft.com/) | Yes | No API | | | [Dedao Learning Assistant](https://ai.dedao.cn/) | Coming soon | No API | | +| [DeepSeek](https://chat.deepseek.com/) | Coming soon | Yes | | | [Falcon 180B](https://huggingface.co/tiiuae/falcon-180B-chat) | Yes | No API | | | [Gemini](https://gemini.google.com/) | Yes | Yes | | | [Gemma 2B & 7B](https://blog.google/technology/developers/gemma-open-models/) | Yes | No API | | From 78327456fc97e83405fa20240a7d8c6521a38b45 Mon Sep 17 00:00:00 2001 From: cesar Date: Mon, 22 Jul 2024 16:48:53 +0800 Subject: [PATCH 3/3] Add tags for DeepSeek bots --- src/bots/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bots/index.js b/src/bots/index.js index 94afd2cfa..fde1f7d90 100644 --- a/src/bots/index.js +++ b/src/bots/index.js @@ -293,6 +293,8 @@ export const botTags = { bots.getBotByClassName("Gemma7bItBot"), bots.getBotByClassName("Claude3SonnetBot"), bots.getBotByClassName("Claude3OpusBot"), + bots.getBotByClassName("DeepSeekAPICoderBot"), + bots.getBotByClassName("DeepSeekAPIChatBot"), ], api: [ bots.getBotByClassName("GeminiAPIBot"), @@ -323,6 +325,8 @@ export const botTags = { bots.getBotByClassName("Llama38bGroqAPIBot"), bots.getBotByClassName("Llama370bGroqAPIBot"), bots.getBotByClassName("Mixtral8x7bGroqAPIBot"), + bots.getBotByClassName("DeepSeekAPICoderBot"), + bots.getBotByClassName("DeepSeekAPIChatBot"), ], madeInChina: [ bots.getBotByClassName("Qihoo360AIBrainBot"), @@ -338,6 +342,8 @@ export const botTags = { bots.getBotByClassName("ChatGLM6bBot"), bots.getBotByClassName("ChatGLM36bBot"), bots.getBotByClassName("KimiBot"), + bots.getBotByClassName("DeepSeekAPICoderBot"), + bots.getBotByClassName("DeepSeekAPIChatBot"), ], }; export default bots;