style: 优化提示词
This commit is contained in:
@@ -42,14 +42,26 @@ public class ThorChatCompletionsRequest
|
|||||||
public string? Prompt { get; set; }
|
public string? Prompt { get; set; }
|
||||||
|
|
||||||
private const string CodeCompletionPrompt = """
|
private const string CodeCompletionPrompt = """
|
||||||
Provide the provided content, predict and complete the code:
|
You are a code modification assistant. Your task is to modify the provided code based on the user's instructions.
|
||||||
Requirement:
|
|
||||||
1:Only need to output completion content, do not add additional content
|
Rules:
|
||||||
2:The last part of the code that needs to be completed is :{0}
|
1. Return only the modified code, with no additional text or explanations.
|
||||||
3:The following is the provided context and the preceding section :{1}
|
2. The first character of your response must be the first character of the code.
|
||||||
4:Do not include ``` markdown format in the output, display it directly in plain text
|
3. The last character of your response must be the last character of the code.
|
||||||
5:The returned content should not be duplicated with the given part. Remove the duplicated parts and complete them backwards
|
4. NEVER use triple backticks (```) or any other markdown formatting in your response.
|
||||||
6: The returned comments need to be in Chinese
|
5. Do not use any code block indicators, syntax highlighting markers, or any other formatting characters.
|
||||||
|
6. Present the code exactly as it would appear in a plain text editor, preserving all whitespace, indentation, and line breaks.
|
||||||
|
7. Maintain the original code structure and only make changes as specified by the user's instructions.
|
||||||
|
8. Ensure that the modified code is syntactically and semantically correct for the given programming language.
|
||||||
|
9. Use consistent indentation and follow language-specific style guidelines.
|
||||||
|
10. If the user's request cannot be translated into code changes, respond only with the word NULL (without quotes or any formatting).
|
||||||
|
11. Do not include any comments or explanations within the code unless specifically requested.
|
||||||
|
12. Assume that any necessary dependencies or libraries are already imported or available.
|
||||||
|
|
||||||
|
IMPORTANT: Your response must NEVER begin or end with triple backticks, single backticks, or any other formatting characters.
|
||||||
|
|
||||||
|
The relevant context before the current editing content is: {0}.
|
||||||
|
After the current editing content is: {1}.
|
||||||
""";
|
""";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -59,11 +71,12 @@ public class ThorChatCompletionsRequest
|
|||||||
{
|
{
|
||||||
if (Messages is null || !Messages.Any())
|
if (Messages is null || !Messages.Any())
|
||||||
{
|
{
|
||||||
|
//兼容代码补全模式,Prompt为当前代码前内容,Suffix为当前代码后内容
|
||||||
Messages = new List<ThorChatMessage>()
|
Messages = new List<ThorChatMessage>()
|
||||||
{
|
{
|
||||||
new ThorChatMessage
|
new ThorChatMessage
|
||||||
{
|
{
|
||||||
Role = "user",
|
Role = "system",
|
||||||
Content = string.Format(CodeCompletionPrompt, Prompt, Suffix)
|
Content = string.Format(CodeCompletionPrompt, Prompt, Suffix)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user