You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
6
6
7
7
## [Unreleased]
8
8
9
+
### Added
10
+
11
+
- Adds support for OpenAI's GPT-4 Turbo and latest Anthropic models for GitLens' experimental AI features — closes [#3005](https://github.com/gitkraken/vscode-gitlens/issues/3005)
12
+
13
+
### Changed
14
+
15
+
- Refines AI prompts to provide better commit message generation and explanation results
"default": "Commit messages must have a short description that is less than 50 chars followed by a newline and a more detailed description.\n- Write concisely using an informal tone and avoid specific names from the code",
3178
+
"default": "Now, please generate a commit message. Ensure that it includes a precise and informative subject line that succinctly summarizes the crux of the changes in under 50 characters. If necessary, follow with an explanatory body providing insight into the nature of the changes, the reasoning behind them, and any significant consequences or considerations arising from them. Conclude with any relevant issue references at the end of the message.",
3179
3179
"markdownDescription": "Specifies the prompt to use to tell OpenAI how to structure or format the generated commit message",
3180
3180
"scope": "window",
3181
3181
"order": 2
@@ -3202,19 +3202,23 @@
3202
3202
"gpt-3.5-turbo",
3203
3203
"gpt-3.5-turbo-16k",
3204
3204
"gpt-3.5-turbo-0613",
3205
+
"gpt-3.5-turbo-1106",
3205
3206
"gpt-4",
3206
3207
"gpt-4-0613",
3207
3208
"gpt-4-32k",
3208
-
"gpt-4-32k-0613"
3209
+
"gpt-4-32k-0613",
3210
+
"gpt-4-1106-preview"
3209
3211
],
3210
3212
"enumDescriptions": [
3211
-
"GPT 3.5 Turbo",
3212
-
"GPT 3.5 Turbo 16k",
3213
-
"GPT 3.5 Turbo (June 13)",
3214
-
"GPT 4",
3215
-
"GPT 4 (June 13)",
3216
-
"GPT 4 32k",
3217
-
"GPT 4 32k (June 13)"
3213
+
"GPT-3.5 Turbo",
3214
+
"GPT-3.5 Turbo 16k",
3215
+
"GPT-3.5 Turbo (June 13)",
3216
+
"GPT-3.5 Turbo (Nov 6)",
3217
+
"GPT-4",
3218
+
"GPT-4 (June 13)",
3219
+
"GPT-4 32k",
3220
+
"GPT-4 32k (June 13)",
3221
+
"GPT-4 Turbo (Nov 6)"
3218
3222
],
3219
3223
"markdownDescription": "Specifies the OpenAI model to use for GitLens' experimental AI features",
3220
3224
"scope": "window",
@@ -3232,20 +3236,14 @@
3232
3236
},
3233
3237
"gitlens.ai.experimental.anthropic.model": {
3234
3238
"type": "string",
3235
-
"default": "claude-v1",
3239
+
"default": "claude-instant-1",
3236
3240
"enum": [
3237
-
"claude-v1",
3238
-
"claude-v1-100k",
3239
-
"claude-instant-v1",
3240
-
"claude-instant-v1-100k",
3241
+
"claude-instant-1",
3241
3242
"claude-2"
3242
3243
],
3243
3244
"enumDescriptions": [
3244
-
"Claude v1",
3245
-
"Claude v1 100k",
3246
-
"Claude Instant v1",
3247
-
"Claude Instant v1 100k",
3248
-
"Claude 2"
3245
+
"Claude Instant",
3246
+
"Claude"
3249
3247
],
3250
3248
"markdownDescription": "Specifies the Anthropic model to use for GitLens' experimental AI features",
@@ -38,15 +38,29 @@ export class AnthropicProvider implements AIProvider {
38
38
customPrompt+='.';
39
39
}
40
40
41
-
letprompt=
42
-
"\n\nHuman: You are an AI programming assistant tasked with writing a meaningful commit message by summarizing code changes.\n- Follow the user's instructions carefully & to the letter!\n- Don't repeat yourself or make anything up!\n- Minimize any other prose.";
43
-
prompt+=`\n${customPrompt}\n- Avoid phrases like "this commit", "this change", etc.`;
44
-
prompt+='\n\nAssistant: OK';
45
-
if(options?.context){
46
-
prompt+=`\n\nHuman: Use "${options.context}" to help craft the commit message.\n\nAssistant: OK`;
47
-
}
48
-
prompt+=`\n\nHuman: Write a meaningful commit message for the following code changes:\n\n${code}`;
49
-
prompt+='\n\nAssistant:';
41
+
constprompt=`\n\nHuman: You are an advanced AI programming assistant tasked with summarizing code changes into a concise and meaningful commit message. Compose a commit message that:
42
+
- Strictly synthesizes meaningful information from the provided code diff
43
+
- Utilizes any additional user-provided context to comprehend the rationale behind the code changes
44
+
- Is clear and brief, with an informal yet professional tone, and without superfluous descriptions
45
+
- Avoids unnecessary phrases such as "this commit", "this change", and the like
46
+
- Avoids direct mention of specific code identifiers, names, or file names, unless they are crucial for understanding the purpose of the changes
47
+
- Most importantly emphasizes the 'why' of the change, its benefits, or the problem it addresses rather than only the 'what' that changed
48
+
49
+
Follow the user's instructions carefully, don't repeat yourself, don't include the code in the output, or make anything up!
50
+
51
+
Human: Here is the code diff to use to generate the commit message:
52
+
53
+
${code}
54
+
55
+
${
56
+
options?.context
57
+
? `Human: Here is additional context which should be taken into account when generating the commit message:\n\n${options.context}`
58
+
: ''
59
+
}
60
+
61
+
Human: ${customPrompt}
62
+
63
+
Assistant:`;
50
64
51
65
constrequest: AnthropicCompletionRequest={
52
66
model: model,
@@ -80,7 +94,7 @@ export class AnthropicProvider implements AIProvider {
@@ -89,12 +103,24 @@ export class AnthropicProvider implements AIProvider {
89
103
);
90
104
}
91
105
92
-
letprompt=
93
-
"\n\nHuman: You are an AI programming assistant tasked with providing an easy to understand but detailed explanation of a commit by summarizing the code changes while also using the commit message as additional context and framing.\nDon't make anything up!";
94
-
prompt+=`\nUse the following user-provided commit message, which should provide some explanation to why these changes where made, when attempting to generate the rich explanation:\n\n${message}`;
95
-
prompt+='\n\nAssistant: OK';
96
-
prompt+=`\n\nHuman: Explain the following code changes:\n\n${code}`;
97
-
prompt+='\n\nAssistant:';
106
+
constprompt=`\n\nHuman: You are an advanced AI programming assistant tasked with summarizing code changes into an explanation that is both easy to understand and meaningful. Construct an explanation that:
107
+
- Concisely synthesizes meaningful information from the provided code diff
108
+
- Incorporates any additional context provided by the user to understand the rationale behind the code changes
109
+
- Places the emphasis on the 'why' of the change, clarifying its benefits or addressing the problem that necessitated the change, beyond just detailing the 'what' has changed
110
+
111
+
Do not make any assumptions or invent details that are not supported by the code diff or the user-provided context.
112
+
113
+
Human: Here is additional context provided by the author of the changes, which should provide some explanation to why these changes where made. Please strongly consider this information when generating your explanation:
114
+
115
+
${message}
116
+
117
+
Human: Now, kindly explain the following code diff in a way that would be clear to someone reviewing or trying to understand these changes:
118
+
119
+
${code}
120
+
121
+
Human: Remember to frame your explanation in a way that is suitable for a reviewer to quickly grasp the essence of the changes, the issues they resolve, and their implications on the codebase.
@@ -47,27 +47,35 @@ export class OpenAIProvider implements AIProvider {
47
47
messages: [
48
48
{
49
49
role: 'system',
50
-
content:
51
-
"You are an AI programming assistant tasked with writing a meaningful commit message by summarizing code changes.\n\n- Follow the user's instructions carefully & to the letter!\n- Don't repeat yourself or make anything up!\n- Minimize any other prose.",
50
+
content: `You are an advanced AI programming assistant tasked with summarizing code changes into a concise and meaningful commit message. Compose a commit message that:
51
+
- Strictly synthesizes meaningful information from the provided code diff
52
+
- Utilizes any additional user-provided context to comprehend the rationale behind the code changes
53
+
- Is clear and brief, with an informal yet professional tone, and without superfluous descriptions
54
+
- Avoids unnecessary phrases such as "this commit", "this change", and the like
55
+
- Avoids direct mention of specific code identifiers, names, or file names, unless they are crucial for understanding the purpose of the changes
56
+
- Most importantly emphasizes the 'why' of the change, its benefits, or the problem it addresses rather than only the 'what' that changed
57
+
58
+
Follow the user's instructions carefully, don't repeat yourself, don't include the code in the output, or make anything up!`,
59
+
},
60
+
{
61
+
role: 'user',
62
+
content: `Here is the code diff to use to generate the commit message:\n\n${code}`,
52
63
},
64
+
...(options?.context
65
+
? [
66
+
{
67
+
role: 'user'asconst,
68
+
content: `Here is additional context which should be taken into account when generating the commit message:\n\n${options.context}`,
69
+
},
70
+
]
71
+
: []),
53
72
{
54
73
role: 'user',
55
-
content: `${customPrompt}\n- Avoid phrases like "this commit", "this change", etc.`,
74
+
content: customPrompt,
56
75
},
57
76
],
58
77
};
59
78
60
-
if(options?.context){
61
-
request.messages.push({
62
-
role: 'user',
63
-
content: `Use "${options.context}" to help craft the commit message.`,
64
-
});
65
-
}
66
-
request.messages.push({
67
-
role: 'user',
68
-
content: `Write a meaningful commit message for the following code changes:\n\n${code}`,
69
-
});
70
-
71
79
constrsp=awaitthis.fetch(apiKey,request);
72
80
if(!rsp.ok){
73
81
debugger;
@@ -89,7 +97,7 @@ export class OpenAIProvider implements AIProvider {
@@ -103,20 +111,25 @@ export class OpenAIProvider implements AIProvider {
103
111
messages: [
104
112
{
105
113
role: 'system',
106
-
content:
107
-
"You are an AI programming assistant tasked with providing an easy to understand but detailed explanation of a commit by summarizing the code changes while also using the commit message as additional context and framing.\n\n- Don't make anything up!",
114
+
content: `You are an advanced AI programming assistant tasked with summarizing code changes into an explanation that is both easy to understand and meaningful. Construct an explanation that:
115
+
- Concisely synthesizes meaningful information from the provided code diff
116
+
- Incorporates any additional context provided by the user to understand the rationale behind the code changes
117
+
- Places the emphasis on the 'why' of the change, clarifying its benefits or addressing the problem that necessitated the change, beyond just detailing the 'what' has changed
118
+
119
+
Do not make any assumptions or invent details that are not supported by the code diff or the user-provided context.`,
108
120
},
109
121
{
110
122
role: 'user',
111
-
content: `Use the following user-provided commit message, which should provide some explanation to why these changes where made, when attempting to generate the rich explanation:\n\n${message}`,
123
+
content: `Here is additional context provided by the author of the changes, which should provide some explanation to why these changes where made. Please strongly consider this information when generating your explanation:\n\n${message}`,
112
124
},
113
125
{
114
-
role: 'assistant',
115
-
content: 'OK',
126
+
role: 'user',
127
+
content: `Now, kindly explain the following code diff in a way that would be clear to someone reviewing or trying to understand these changes:\n\n${code}`,
116
128
},
117
129
{
118
130
role: 'user',
119
-
content: `Explain the following code changes:\n\n${code}`,
131
+
content:
132
+
'Remember to frame your explanation in a way that is suitable for a reviewer to quickly grasp the essence of the changes, the issues they resolve, and their implications on the codebase.',
0 commit comments