@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- 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)
### Changed
- 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",
"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.",
"markdownDescription":"Specifies the prompt to use to tell OpenAI how to structure or format the generated commit message",
"scope":"window",
"order":2
@ -3202,19 +3202,23 @@
"gpt-3.5-turbo",
"gpt-3.5-turbo-16k",
"gpt-3.5-turbo-0613",
"gpt-3.5-turbo-1106",
"gpt-4",
"gpt-4-0613",
"gpt-4-32k",
"gpt-4-32k-0613"
"gpt-4-32k-0613",
"gpt-4-1106-preview"
],
"enumDescriptions":[
"GPT 3.5 Turbo",
"GPT 3.5 Turbo 16k",
"GPT 3.5 Turbo (June 13)",
"GPT 4",
"GPT 4 (June 13)",
"GPT 4 32k",
"GPT 4 32k (June 13)"
"GPT-3.5 Turbo",
"GPT-3.5 Turbo 16k",
"GPT-3.5 Turbo (June 13)",
"GPT-3.5 Turbo (Nov 6)",
"GPT-4",
"GPT-4 (June 13)",
"GPT-4 32k",
"GPT-4 32k (June 13)",
"GPT-4 Turbo (Nov 6)"
],
"markdownDescription":"Specifies the OpenAI model to use for GitLens' experimental AI features",
"scope":"window",
@ -3232,20 +3236,14 @@
},
"gitlens.ai.experimental.anthropic.model":{
"type":"string",
"default":"claude-v1",
"default":"claude-instant-1",
"enum":[
"claude-v1",
"claude-v1-100k",
"claude-instant-v1",
"claude-instant-v1-100k",
"claude-instant-1",
"claude-2"
],
"enumDescriptions":[
"Claude v1",
"Claude v1 100k",
"Claude Instant v1",
"Claude Instant v1 100k",
"Claude 2"
"Claude Instant",
"Claude"
],
"markdownDescription":"Specifies the Anthropic model to use for GitLens' experimental AI features",
@ -38,15 +38,29 @@ export class AnthropicProvider implements AIProvider {
customPrompt+='.';
}
letprompt=
"\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.";
prompt+=`\n${customPrompt}\n- Avoid phrases like "this commit", "this change", etc.`;
prompt+='\n\nAssistant: OK';
if(options?.context){
prompt+=`\n\nHuman: Use "${options.context}" to help craft the commit message.\n\nAssistant: OK`;
}
prompt+=`\n\nHuman: Write a meaningful commit message for the following code changes:\n\n${code}`;
prompt+='\n\nAssistant:';
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:
@ -89,12 +103,24 @@ export class AnthropicProvider implements AIProvider {
);
}
letprompt=
"\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!";
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}`;
prompt+='\n\nAssistant: OK';
prompt+=`\n\nHuman: Explain the following code changes:\n\n${code}`;
prompt+='\n\nAssistant:';
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:
@ -47,27 +47,35 @@ export class OpenAIProvider implements AIProvider {
messages:[
{
role:'system',
content:
"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.",
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:
@ -103,20 +111,25 @@ export class OpenAIProvider implements AIProvider {
messages:[
{
role:'system',
content:
"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!",
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:
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}`,
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}`,
},
{
role:'assistant',
content:'OK',
role:'user',
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}`,
},
{
role:'user',
content:`Explain the following code changes:\n\n${code}`,
content:
'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.',
},
],
};
@ -220,26 +233,45 @@ async function getApiKey(storage: Storage): Promise {