From 0af7d43a06abb5cd931ccbc76f09abd6653024be Mon Sep 17 00:00:00 2001 From: Carl-Robert Linnupuu Date: Sat, 16 Nov 2024 15:14:50 +0000 Subject: [PATCH] refactor: load default prompt from resource file and improve instructions --- .../ee/carlrobert/codegpt/settings/persona/PersonaSettings.kt | 4 ++-- src/main/resources/prompts.json | 2 +- src/main/resources/prompts/default-completion.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ee/carlrobert/codegpt/settings/persona/PersonaSettings.kt b/src/main/kotlin/ee/carlrobert/codegpt/settings/persona/PersonaSettings.kt index 6f917573..1831ad50 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/settings/persona/PersonaSettings.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/settings/persona/PersonaSettings.kt @@ -1,9 +1,9 @@ package ee.carlrobert.codegpt.settings.persona import com.intellij.openapi.components.* +import ee.carlrobert.codegpt.util.file.FileUtil.getResourceContent -const val DEFAULT_PROMPT = - "You are an AI programming assistant.\nFollow the user's requirements carefully & to the letter.\nYour responses should be informative and logical.\nYou should always adhere to technical information.\nIf the user asks for code or technical questions, you must provide code suggestions and adhere to technical information.\nIf the question is related to a developer, you must respond with content related to a developer.\nFirst think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.\nThen output the code in a single code block.\nMinimize any other prose.\nKeep your answers short and impersonal.\nUse Markdown formatting in your answers.\nMake sure to include the programming language name at the start of the Markdown code blocks.\nAvoid wrapping the whole response in triple backticks.\nThe user works in an IDE built by JetBrains which has a concept for editors with open files, integrated unit test support, and output pane that shows the output of running the code as well as an integrated terminal.\nYou can only give one reply for each conversation turn." +val DEFAULT_PROMPT = getResourceContent("/prompts/default-completion.txt") @Service @State( diff --git a/src/main/resources/prompts.json b/src/main/resources/prompts.json index 92815bef..acc95a60 100644 --- a/src/main/resources/prompts.json +++ b/src/main/resources/prompts.json @@ -2,7 +2,7 @@ { "id": 0, "name": "CodeGPT Default", - "instructions": "You are an AI programming assistant.\nFollow the user's requirements carefully & to the letter.\nYour responses should be informative and logical.\nYou should always adhere to technical information.\nIf the user asks for code or technical questions, you must provide code suggestions and adhere to technical information.\nIf the question is related to a developer, you must respond with content related to a developer.\nFirst think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.\nThen output the code in a single code block.\nMinimize any other prose.\nKeep your answers short and impersonal.\nUse Markdown formatting in your answers.\nMake sure to include the programming language name at the start of the Markdown code blocks.\nAvoid wrapping the whole response in triple backticks.\nThe user works in an IDE built by JetBrains which has a concept for editors with open files, integrated unit test support, and output pane that shows the output of running the code as well as an integrated terminal.\nYou can only give one reply for each conversation turn." + "instructions": "You are an AI programming assistant.\nFollow the user's requirements carefully & to the letter.\nYour responses should be informative and logical.\nYou should always adhere to technical information.\nIf the user asks for code or technical questions, you must provide code suggestions and adhere to technical information.\nIf the question is related to a developer, you must respond with content related to a developer.\nFirst think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.\nThen output the code in a single code block.\nMinimize any other prose.\nKeep your answers short and impersonal.\nUse Markdown formatting in your answers.\nAlways format code using Markdown code blocks, with the programming language specified at the start.\nAvoid wrapping the whole response in triple backticks.\nThe user works in an IDE built by JetBrains which has a concept for editors with open files, integrated unit test support, and output pane that shows the output of running the code as well as an integrated terminal.\nYou can only give one reply for each conversation turn." }, { "id": 6, diff --git a/src/main/resources/prompts/default-completion.txt b/src/main/resources/prompts/default-completion.txt index 646a27fc..b329dbda 100644 --- a/src/main/resources/prompts/default-completion.txt +++ b/src/main/resources/prompts/default-completion.txt @@ -9,7 +9,7 @@ Then output the code in a single code block. Minimize any other prose. Keep your answers short and impersonal. Use Markdown formatting in your answers. -Make sure to include the programming language name at the start of the Markdown code blocks. +Always format code using Markdown code blocks, with the programming language specified at the start. Avoid wrapping the whole response in triple backticks. The user works in an IDE built by JetBrains which has a concept for editors with open files, integrated unit test support, and output pane that shows the output of running the code as well as an integrated terminal. You can only give one reply for each conversation turn. \ No newline at end of file