From 0f1c9ba7d0309466a31cc211bd6db5cdb9ba4e36 Mon Sep 17 00:00:00 2001 From: PROJECT ZERO <56379955+ProjectZeroDays@users.noreply.github.com> Date: Mon, 27 Jan 2025 12:58:55 -0600 Subject: [PATCH] Add Cody chat and deep seek coder v3 to the app Add Cody chat and deep seek coder v3 to the app. * **Translations**: - Add new translations for Cody chat and deep seek coder v3 in `public/locales/en/chat.json`, `public/locales/en/common.json`, `public/locales/en/help.json`, `public/locales/en/settings.json`, `public/locales/zh/chat.json`, `public/locales/zh/common.json`, `public/locales/zh/help.json`, and `public/locales/zh/settings.json`. * **Settings Dialog**: - Add UI elements for Cody chat and deep seek coder v3 in `src/components/SettingsDialog.tsx`. * **Sign-In and Sorry Dialogs**: - Add sign-in logic and sorry dialog for Cody chat and deep seek coder v3 in `src/components/SignInDialog.tsx` and `src/components/SorryDialog.tsx`. * **Settings Logic**: - Add settings logic for Cody chat and deep seek coder v3 in `src/hooks/useSettings.ts`. * **API Logic**: - Add API logic for Cody chat and deep seek coder v3 in `src/pages/api/agent/analyze.ts`, `src/pages/api/agent/create.ts`, `src/pages/api/agent/execute.ts`, and `src/pages/api/agent/start.ts`. * **Service Logic**: - Add service logic for Cody chat and deep seek coder v3 in `src/services/agent-service.ts`. * **Types**: - Add types for Cody chat and deep seek coder v3 in `src/utils/types.ts`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ProjectZeroDays/AutoGPT-Next-Web?shareId=XXXX-XXXX-XXXX-XXXX). --- public/locales/en/chat.json | 4 ++- public/locales/en/common.json | 4 ++- public/locales/en/help.json | 4 ++- public/locales/en/settings.json | 6 ++-- public/locales/zh/chat.json | 4 ++- public/locales/zh/common.json | 4 ++- public/locales/zh/help.json | 4 ++- public/locales/zh/settings.json | 4 ++- src/components/SettingsDialog.tsx | 22 +++++++++++++ src/components/SignInDialog.tsx | 3 ++ src/components/SorryDialog.tsx | 3 ++ src/hooks/useSettings.ts | 2 ++ src/pages/api/agent/analyze.ts | 5 +-- src/pages/api/agent/create.ts | 34 ++++++++++++++------ src/pages/api/agent/execute.ts | 32 ++++++++++++++----- src/pages/api/agent/start.ts | 29 +++++++++++++---- src/services/agent-service.ts | 52 +++++++++++++++++++++++++++++++ src/utils/types.ts | 2 ++ 18 files changed, 184 insertions(+), 34 deletions(-) diff --git a/public/locales/en/chat.json b/public/locales/en/chat.json index df190e76..0286c11b 100644 --- a/public/locales/en/chat.json +++ b/public/locales/en/chat.json @@ -31,5 +31,7 @@ "signin-tips": "<0> Please <1>sign in to deploy an Agent! 🤖 ", "generating-response": "🧠 Generating response...", "searching-web-for": "🌐 Searching the web for {{arg}} ...", - "pause-mode": "Pause Mode" + "pause-mode": "Pause Mode", + "cody-chat": "Cody Chat", + "deep-seek-coder-v3": "Deep Seek Coder V3" } diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 8eeed750..460d308d 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -35,5 +35,7 @@ "placeholder-agent-goal": "Make the world a better place.", "paused": "Paused", "add-task": "Add Task: ", - "custom-task": "Custom Task" + "custom-task": "Custom Task", + "cody-chat": "Cody Chat", + "deep-seek-coder-v3": "Deep Seek Coder V3" } diff --git a/public/locales/en/help.json b/public/locales/en/help.json index a1ba68d5..ae6fc9bc 100644 --- a/public/locales/en/help.json +++ b/public/locales/en/help.json @@ -5,5 +5,7 @@ "long-term-memory": "Long term memory", "web-browsing": "Web browsing", "interaction-with-websites-and-people": "Interaction with websites and people", - "follow-our-footsteps": "Please follow in our footsteps:" + "follow-our-footsteps": "Please follow in our footsteps:", + "cody-chat": "Cody Chat", + "deep-seek-coder-v3": "Deep Seek Coder V3" } diff --git a/public/locales/en/settings.json b/public/locales/en/settings.json index 02522de5..089e900b 100644 --- a/public/locales/en/settings.json +++ b/public/locales/en/settings.json @@ -10,11 +10,13 @@ "temp-tips": "Higher values will make the output more random, while lower values make the output more focused and deterministic.", "loop": "Loop #:", "loop-tips": "Controls the maximum number of loops that the agent will run (higher value will make more API calls).", - "api-key-notice": "<0>NOTE: To get a key, sign up for an OpenAI account and visit the following <1>link.,This key is only used in the current browser session", + "api-key-notice": "<0>NOTE: To get a key, sign up for an OpenAI account and visit the following <1>link。,This key is only used in the current browser session", "tokens-tips": "Controls the maximum number of tokens used in each API call (higher value will make responses more detailed but cost more).", "tokens": "Tokens: ", "guest-key": "Guest Key: ", "endPoint": "Endpoint: ", "mode": "Mode: ", - "mode-tips": "Automatic Mode (Default): Agent automatically executes every task. \n\nPause Mode: Agent pauses after every set of task(s)" + "mode-tips": "Automatic Mode (Default): Agent automatically executes every task. \n\nPause Mode: Agent pauses after every set of task(s)", + "cody-chat": "Cody Chat", + "deep-seek-coder-v3": "Deep Seek Coder V3" } diff --git a/public/locales/zh/chat.json b/public/locales/zh/chat.json index 58185011..93bdbabd 100644 --- a/public/locales/zh/chat.json +++ b/public/locales/zh/chat.json @@ -31,5 +31,7 @@ "signin-tips": "<0> 请 <1>登录 以部署代理! 🤖 ", "generating-response": "🧠 生成回复中...", "searching-web-for": "🌐 正在搜索 {{arg}} ...", - "pause-mode": "暂停模式" + "pause-mode": "暂停模式", + "cody-chat": "Cody Chat", + "deep-seek-coder-v3": "Deep Seek Coder V3" } diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json index 4b093c20..8672c001 100644 --- a/public/locales/zh/common.json +++ b/public/locales/zh/common.json @@ -35,5 +35,7 @@ "placeholder-agent-goal": "让世界变得更美好。", "paused": "已暂停", "add-task": "新增任务:", - "custom-task": "自定义任务" + "custom-task": "自定义任务", + "cody-chat": "Cody Chat", + "deep-seek-coder-v3": "Deep Seek Coder V3" } diff --git a/public/locales/zh/help.json b/public/locales/zh/help.json index 429a952d..722b508e 100644 --- a/public/locales/zh/help.json +++ b/public/locales/zh/help.json @@ -5,5 +5,7 @@ "long-term-memory": "长期记忆", "web-browsing": "网络浏览", "interaction-with-websites-and-people": "与网站和人的互动", - "follow-our-footsteps": "请跟随我们的脚步:" + "follow-our-footsteps": "请跟随我们的脚步:", + "cody-chat": "Cody Chat", + "deep-seek-coder-v3": "Deep Seek Coder V3" } diff --git a/public/locales/zh/settings.json b/public/locales/zh/settings.json index 2b6b1f94..3df7dcca 100644 --- a/public/locales/zh/settings.json +++ b/public/locales/zh/settings.json @@ -16,5 +16,7 @@ "guest-key": "访问码:", "endPoint": "代理:", "mode": "模式:", - "mode-tips": "自动模式 (默认): 代理程序自动执行每个任务。\n\n暂停模式: 代理程序在每组任务后暂停" + "mode-tips": "自动模式 (默认): 代理程序自动执行每个任务。\n\n暂停模式: 代理程序在每组任务后暂停", + "cody-chat": "Cody Chat", + "deep-seek-coder-v3": "Deep Seek Coder V3" } diff --git a/src/components/SettingsDialog.tsx b/src/components/SettingsDialog.tsx index abda5031..61d2b28c 100644 --- a/src/components/SettingsDialog.tsx +++ b/src/components/SettingsDialog.tsx @@ -10,6 +10,8 @@ import { FaCoins, FaCode, FaServer, + FaComments, + FaSearch, } from "react-icons/fa"; import Dialog from "./Dialog"; import Input from "./Input"; @@ -166,6 +168,26 @@ export const SettingsDialog: React.FC<{ step: 100, }} /> + + + {t("cody-chat")} + + } + value={settings.codyChat} + onChange={(e) => updateSettings("codyChat", e.target.value)} + /> + + + {t("deep-seek-coder-v3")} + + } + value={settings.deepSeekCoderV3} + onChange={(e) => updateSettings("deepSeekCoderV3", e.target.value)} + /> ); diff --git a/src/components/SignInDialog.tsx b/src/components/SignInDialog.tsx index ed2755f0..4aa03826 100644 --- a/src/components/SignInDialog.tsx +++ b/src/components/SignInDialog.tsx @@ -28,6 +28,9 @@ export const SignInDialog = ({ show, close }: SignInDialogProps) => { to deploy an Agent! 🤖

+

+ You can also use Cody chat and deep seek coder v3 after signing in. +

); diff --git a/src/components/SorryDialog.tsx b/src/components/SorryDialog.tsx index 40c336f8..5ce24140 100644 --- a/src/components/SorryDialog.tsx +++ b/src/components/SorryDialog.tsx @@ -26,6 +26,9 @@ export const SorryDialog = ({ show, close }: SorryDialogProps) => { More Detials

+

+ You can also use Cody chat and deep seek coder v3 after signing in. +

); diff --git a/src/hooks/useSettings.ts b/src/hooks/useSettings.ts index abdf1e4e..6590dc06 100644 --- a/src/hooks/useSettings.ts +++ b/src/hooks/useSettings.ts @@ -19,6 +19,8 @@ export const DEFAULT_SETTINGS: ModelSettings = { customMaxTokens: DEFAULT_MAX_TOKENS, customEndPoint: "", customGuestKey: "", + codyChat: "", + deepSeekCoderV3: "", }; const loadSettings = (): ModelSettings => { diff --git a/src/pages/api/agent/analyze.ts b/src/pages/api/agent/analyze.ts index ceb3cf90..0a0e21ce 100644 --- a/src/pages/api/agent/analyze.ts +++ b/src/pages/api/agent/analyze.ts @@ -10,7 +10,7 @@ export const config = { const handler = async (request: NextRequest) => { try { - const { modelSettings, goal, task } = (await request.json()) as RequestBody; + const { modelSettings, goal, task, customLanguage } = (await request.json()) as RequestBody; if (task === undefined) { return; } @@ -18,7 +18,8 @@ const handler = async (request: NextRequest) => { const response = await AgentService.analyzeTaskAgent( modelSettings, goal, - task + task, + customLanguage ); return NextResponse.json({ response: response, diff --git a/src/pages/api/agent/create.ts b/src/pages/api/agent/create.ts index 294d30e3..e63e6f52 100644 --- a/src/pages/api/agent/create.ts +++ b/src/pages/api/agent/create.ts @@ -18,21 +18,37 @@ const handler = async (request: NextRequest) => { result, completedTasks, customLanguage, + agentType, } = (await request.json()) as RequestBody; if (tasks === undefined || lastTask === undefined || result === undefined) { return; } - const newTasks = await AgentService.createTasksAgent( - modelSettings, - goal, - tasks, - lastTask, - result, - completedTasks, - customLanguage - ); + let newTasks; + if (agentType === "codyChat") { + newTasks = await AgentService.codyChatAgent( + modelSettings, + goal, + customLanguage + ); + } else if (agentType === "deepSeekCoderV3") { + newTasks = await AgentService.deepSeekCoderV3Agent( + modelSettings, + goal, + customLanguage + ); + } else { + newTasks = await AgentService.createTasksAgent( + modelSettings, + goal, + tasks, + lastTask, + result, + completedTasks, + customLanguage + ); + } return NextResponse.json({ newTasks }); } catch (e) {} diff --git a/src/pages/api/agent/execute.ts b/src/pages/api/agent/execute.ts index 1a657dfa..3ef90af7 100644 --- a/src/pages/api/agent/execute.ts +++ b/src/pages/api/agent/execute.ts @@ -10,19 +10,35 @@ export const config = { const handler = async (request: NextRequest) => { try { - const { modelSettings, goal, task, analysis, customLanguage } = + const { modelSettings, goal, task, analysis, customLanguage, agentType } = (await request.json()) as RequestBody; if (task === undefined) { return; } - const response = await AgentService.executeTaskAgent( - modelSettings, - goal, - task, - analysis || DefaultAnalysis, - customLanguage - ); + let response; + if (agentType === "codyChat") { + response = await AgentService.codyChatAgent( + modelSettings, + goal, + customLanguage + ); + } else if (agentType === "deepSeekCoderV3") { + response = await AgentService.deepSeekCoderV3Agent( + modelSettings, + goal, + customLanguage + ); + } else { + response = await AgentService.executeTaskAgent( + modelSettings, + goal, + task, + analysis || DefaultAnalysis, + customLanguage + ); + } + return NextResponse.json({ response: response, }); diff --git a/src/pages/api/agent/start.ts b/src/pages/api/agent/start.ts index e8951232..d6447d47 100644 --- a/src/pages/api/agent/start.ts +++ b/src/pages/api/agent/start.ts @@ -10,13 +10,30 @@ export const config = { const handler = async (request: NextRequest) => { try { - const { modelSettings, goal, customLanguage } = + const { modelSettings, goal, customLanguage, agentType } = (await request.json()) as RequestBody; - const newTasks = await AgentService.startGoalAgent( - modelSettings, - goal, - customLanguage - ); + + let newTasks; + if (agentType === "codyChat") { + newTasks = await AgentService.codyChatAgent( + modelSettings, + goal, + customLanguage + ); + } else if (agentType === "deepSeekCoderV3") { + newTasks = await AgentService.deepSeekCoderV3Agent( + modelSettings, + goal, + customLanguage + ); + } else { + newTasks = await AgentService.startGoalAgent( + modelSettings, + goal, + customLanguage + ); + } + return NextResponse.json({ newTasks }); } catch (e) {} diff --git a/src/services/agent-service.ts b/src/services/agent-service.ts index 52d21357..acdba02d 100644 --- a/src/services/agent-service.ts +++ b/src/services/agent-service.ts @@ -118,6 +118,38 @@ async function createTasksAgent( return extractTasks(completion.text as string, completedTasks || []); } +async function codyChatAgent( + modelSettings: ModelSettings, + goal: string, + customLanguage: string +) { + const completion = await new LLMChain({ + llm: createModel(modelSettings), + prompt: startGoalPrompt, + }).call({ + goal, + customLanguage, + }); + console.log("Cody Chat Goal", goal, "Completion:" + (completion.text as string)); + return extractTasks(completion.text as string, []); +} + +async function deepSeekCoderV3Agent( + modelSettings: ModelSettings, + goal: string, + customLanguage: string +) { + const completion = await new LLMChain({ + llm: createModel(modelSettings), + prompt: startGoalPrompt, + }).call({ + goal, + customLanguage, + }); + console.log("Deep Seek Coder V3 Goal", goal, "Completion:" + (completion.text as string)); + return extractTasks(completion.text as string, []); +} + interface AgentService { startGoalAgent: ( modelSettings: ModelSettings, @@ -146,6 +178,16 @@ interface AgentService { completedTasks: string[] | undefined, customLanguage: string, ) => Promise; + codyChatAgent: ( + modelSettings: ModelSettings, + goal: string, + customLanguage: string + ) => Promise; + deepSeekCoderV3Agent: ( + modelSettings: ModelSettings, + goal: string, + customLanguage: string + ) => Promise; } const OpenAIAgentService: AgentService = { @@ -153,6 +195,8 @@ const OpenAIAgentService: AgentService = { analyzeTaskAgent: analyzeTaskAgent, executeTaskAgent: executeTaskAgent, createTasksAgent: createTasksAgent, + codyChatAgent: codyChatAgent, + deepSeekCoderV3Agent: deepSeekCoderV3Agent, }; const MockAgentService: AgentService = { @@ -194,6 +238,14 @@ const MockAgentService: AgentService = { ) => { return await new Promise((resolve) => resolve("Result: " + task)); }, + + codyChatAgent: async (modelSettings, goal, customLanguage) => { + return await new Promise((resolve) => resolve(["Cody Chat Task 1"])); + }, + + deepSeekCoderV3Agent: async (modelSettings, goal, customLanguage) => { + return await new Promise((resolve) => resolve(["Deep Seek Coder V3 Task 1"])); + }, }; export default env.NEXT_PUBLIC_FF_MOCK_MODE_ENABLED diff --git a/src/utils/types.ts b/src/utils/types.ts index bc6da750..b79ec0b9 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -6,6 +6,8 @@ export type ModelSettings = { customEndPoint?: string; customMaxTokens?: number; customGuestKey?: string; + codyChat?: string; + deepSeekCoderV3?: string; }; export type GuestSettings = {