From 39d2a0db330f613076bb4659c9047b708155f148 Mon Sep 17 00:00:00 2001 From: Ivan Pegashev Date: Sun, 12 May 2024 23:16:32 +0300 Subject: [PATCH] feat(chat): move to codegemma chat model --- src/common/download/index.ts | 14 ++------------ src/common/prompt/promptChat.ts | 27 ++++++++++----------------- src/common/server/index.ts | 8 -------- 3 files changed, 12 insertions(+), 37 deletions(-) diff --git a/src/common/download/index.ts b/src/common/download/index.ts index 86901b9..ca6bf1e 100644 --- a/src/common/download/index.ts +++ b/src/common/download/index.ts @@ -164,20 +164,10 @@ const getModelInfo = async ( checksum: "eb00372705e7d5d30442750e8a7c72919c8e243bee52e1cce97fcfc1008c6143", }, - "chat-small": { - url: "https://huggingface.co/TheBloke/deepseek-coder-1.3b-instruct-GGUF/resolve/main/deepseek-coder-1.3b-instruct.Q8_0.gguf", - checksum: - "36eb025121a50ee6d37fe900659393ff8fb5ea34adc0e3c11fc635e07624dcdb", - }, "chat-medium": { - url: "https://huggingface.co/TheBloke/deepseek-coder-6.7B-instruct-GGUF/resolve/main/deepseek-coder-6.7b-instruct.Q8_0.gguf", - checksum: - "02cd6ce7ccec670cf6d3dd147932f13e584f9e964d5a3297a74b401b658471ae", - }, - "chat-large": { - url: "https://huggingface.co/TheBloke/deepseek-coder-33B-instruct-GGUF/resolve/main/deepseek-coder-33b-instruct.Q8_0.gguf", + url: "https://huggingface.co/lmstudio-community/codegemma-1.1-7b-it-GGUF/resolve/main/codegemma-1.1-7b-it-Q5_K_M.gguf", checksum: - "86529f8eefc87a80bd20d62229ee5acdc32d5773be8575a143bc491924865c21", + "ec11bacb9e0b8c8e0f483f209c487939202b04bbf4f815f0a0945c5b256da895", }, }; diff --git a/src/common/prompt/promptChat.ts b/src/common/prompt/promptChat.ts index 263d548..2d225d9 100644 --- a/src/common/prompt/promptChat.ts +++ b/src/common/prompt/promptChat.ts @@ -11,29 +11,22 @@ export type Chat = { title: string; }; -const promptBaseDefault = `You are an AI programming assistant, utilizing the DeepSeek Coder model, developed by DeepSeek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer. -`; - export const getPromptChat = (chatMessages: ChatMessage[]) => { + const systemPrompt = + chatMessages.find((message) => message.role === "system")?.content || ""; const promptHistory = chatMessages .filter((chatMessage) => chatMessage.role !== "system") - .map((chatMessage) => { + .map((chatMessage, index) => { const partOfPrompt = - chatMessage.role === "user" ? "### Instruction:\n" : "### Response:\n"; - return ( - partOfPrompt + - chatMessage.content + - "\n" + - (chatMessage.role === "ai" ? "<|EOT|>" : "") - ); + index === 0 && chatMessage.role === "user" + ? "user\n" + systemPrompt + "\n" + : chatMessage.role === "user" + ? "user\n" + : "model\n"; + return partOfPrompt + chatMessage.content + "\n"; }) .join(""); - const promptBase = - chatMessages.find((message) => message.role === "system")?.content ?? - promptBaseDefault; - - const prompt = promptBase + promptHistory + "### Response:\n"; - + const prompt = "" + promptHistory + "model\n"; return prompt; }; diff --git a/src/common/server/index.ts b/src/common/server/index.ts index 41ac32f..efb1d04 100644 --- a/src/common/server/index.ts +++ b/src/common/server/index.ts @@ -18,15 +18,9 @@ const modelsBase = { export type TypeModelsBase = keyof typeof modelsBase; export const modelsChat = { - "chat-small": { - port: 39725, - }, "chat-medium": { port: 39726, }, - "chat-large": { - port: 39727, - }, }; export type TypeModelsChat = keyof typeof modelsChat; @@ -311,7 +305,5 @@ class Server { export const servers = { "base-small": new Server("base-small"), "base-medium": new Server("base-medium"), - "chat-small": new Server("chat-small"), "chat-medium": new Server("chat-medium"), - "chat-large": new Server("chat-large"), };