From 15af137728a3a38c22e39fa0ccf8be3ca3b9a908 Mon Sep 17 00:00:00 2001 From: Petr Mironychev <9195189+Palm1r@users.noreply.github.com> Date: Sun, 8 Sep 2024 02:25:21 +0200 Subject: [PATCH] Add examples of customs request --- CMakeLists.txt | 1 - qodeassist.cpp | 2 - rawPromptExamples/OllamaStarCoder2FIM.json | 19 ++++++++++ rawPromptExamples/OpenAICodeqwenChat.json | 16 ++++++++ settings/CustomPromptSettings.cpp | 1 + templates/CodeQwenChat.hpp | 44 ---------------------- 6 files changed, 36 insertions(+), 47 deletions(-) create mode 100644 rawPromptExamples/OllamaStarCoder2FIM.json create mode 100644 rawPromptExamples/OpenAICodeqwenChat.json delete mode 100644 templates/CodeQwenChat.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 343e53c..9e98f4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,6 @@ add_qtc_plugin(QodeAssist templates/PromptTemplate.hpp templates/CodeLLamaTemplate.hpp templates/StarCoder2Template.hpp - templates/CodeQwenChat.hpp templates/DeepSeekCoderV2.hpp templates/CustomTemplate.hpp providers/LLMProvider.hpp diff --git a/qodeassist.cpp b/qodeassist.cpp index 43ed118..a679547 100644 --- a/qodeassist.cpp +++ b/qodeassist.cpp @@ -45,7 +45,6 @@ #include "providers/OllamaProvider.hpp" #include "providers/OpenAICompatProvider.hpp" #include "templates/CodeLLamaTemplate.hpp" -#include "templates/CodeQwenChat.hpp" #include "templates/CustomTemplate.hpp" #include "templates/DeepSeekCoderV2.hpp" #include "templates/StarCoder2Template.hpp" @@ -81,7 +80,6 @@ public: auto &templateManager = PromptTemplateManager::instance(); templateManager.registerTemplate(); templateManager.registerTemplate(); - templateManager.registerTemplate(); templateManager.registerTemplate(); templateManager.registerTemplate(); diff --git a/rawPromptExamples/OllamaStarCoder2FIM.json b/rawPromptExamples/OllamaStarCoder2FIM.json new file mode 100644 index 0000000..7ce65cc --- /dev/null +++ b/rawPromptExamples/OllamaStarCoder2FIM.json @@ -0,0 +1,19 @@ +{ + "prompt": "{{QODE_INSTRUCTIONS}}{{QODE_PREFIX}}{{QODE_SUFFIX}}", + "options": { + "temperature": 0.7, + "top_p": 0.95, + "top_k": 40, + "num_predict": 175, + "stop": [ + "<|endoftext|>", + "", + "", + "", + "" + ], + "frequency_penalty": 0, + "presence_penalty": 0 + }, + "stream": true +} \ No newline at end of file diff --git a/rawPromptExamples/OpenAICodeqwenChat.json b/rawPromptExamples/OpenAICodeqwenChat.json new file mode 100644 index 0000000..6ff0546 --- /dev/null +++ b/rawPromptExamples/OpenAICodeqwenChat.json @@ -0,0 +1,16 @@ +{ + "max_tokens": 150, + "messages": [ + { + "content": "{{QODE_INSTRUCTIONS}}\n### Instruction:{{QODE_PREFIX}}{{QODE_SUFFIX}} ### Response:\n", + "role": "user" + } + ], + "stop": [ + "### Instruction:", + "### Response:", + "\n\n### " + ], + "stream": true, + "temperature": 0.2 +} \ No newline at end of file diff --git a/settings/CustomPromptSettings.cpp b/settings/CustomPromptSettings.cpp index 74ae7f9..ee5ad78 100644 --- a/settings/CustomPromptSettings.cpp +++ b/settings/CustomPromptSettings.cpp @@ -47,6 +47,7 @@ CustomPromptSettings::CustomPromptSettings() customJsonLabel.setDisplayStyle(Utils::StringAspect::LabelDisplay); customJsonLegend.setLabelText(Tr::tr(R"(Prompt components: +- model is set on General Page - {{QODE_INSTRUCTIONS}}: Placeholder for specific instructions or context. - {{QODE_PREFIX}}: Will be replaced with the actual code before the cursor. - {{QODE_SUFFIX}}: Will be replaced with the actual code after the cursor. diff --git a/templates/CodeQwenChat.hpp b/templates/CodeQwenChat.hpp deleted file mode 100644 index dfae27e..0000000 --- a/templates/CodeQwenChat.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2024 Petr Mironychev - * - * This file is part of QodeAssist. - * - * QodeAssist is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * QodeAssist is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with QodeAssist. If not, see . - */ - -#pragma once - -#include "PromptTemplate.hpp" - -namespace QodeAssist::Templates { - -class CodeQwenChatTemplate : public PromptTemplate -{ -public: - QString name() const override { return "CodeQwenChat (experimental)"; } - QString promptTemplate() const override { return "%1\n### Instruction:%2%3 ### Response:\n"; } - QStringList stopWords() const override - { - return QStringList() << "### Instruction:" << "### Response:" << "\n\n### "; - } - void prepareRequest(QJsonObject &request, const ContextData &context) const override - { - QString formattedPrompt = promptTemplate().arg(context.instriuctions, - context.prefix, - context.suffix); - request["prompt"] = formattedPrompt; - } -}; - -} // namespace QodeAssist::Templates