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:
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:
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:
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:
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:
constrequest: OpenAIChatCompletionRequest={
model: model,
messages:[
{
role:'system',
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:
content:`Here is the code diff to use to generate the commit message:\n\n${code}`,
},
...(options?.context
?[
{
role:'user'asconst,
content:`Here is additional context which should be taken into account when generating the commit message:\n\n${options.context}`,
},
]
:[]),
{
role:'user',
content: customPrompt,
},
],
};
},
{
role:'user',
content:`Here is the code diff to use to generate the commit message:\n\n${code}`,
},
...(options?.context
?[
{
role:'user'asconst,
content:`Here is additional context which should be taken into account when generating the commit message:\n\n${options.context}`,
},
]
:[]),
{
role:'user',
content: customPrompt,
},
],
};
constrsp=awaitthis.fetch(apiKey,request);
if(!rsp.ok){
if(rsp.status===404){
thrownewError(
`Unable to generate commit message: Your API key doesn't seem to have access to the selected '${model}' model`,
);
}
if(rsp.status===429){
thrownewError(
`Unable to generate commit message: (${this.name}:${rsp.status}) Too many requests (rate limit exceeded) or your API key is associated with an expired trial`,
`Unable to generate commit message: (${this.name}:${rsp.status}) Too many requests (rate limit exceeded) or your API key is associated with an expired trial`,
`Unable to generate commit message: (${this.name}:${rsp.status}) ${
json?.error?.message||rsp.statusText
}`,
);
}
if(diff.length>maxCodeCharacters){
voidwindow.showWarningMessage(
`The diff of the staged changes had to be truncated to ${maxCodeCharacters} characters to fit within the OpenAI's limits.`,
);
}
thrownewError(`Unable to generate commit message: (${this.name}:${rsp.status}) ${rsp.statusText}`);
`The diff of the commit changes had to be truncated to ${maxCodeCharacters} characters to fit within the OpenAI's limits.`,
);
}
constrequest: OpenAIChatCompletionRequest={
model: model,
messages:[
{
role:'system',
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:`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:`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:'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:
'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.',
},
],
};
},
{
role:'user',
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:'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:
'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.',
},
],
};
constrsp=awaitthis.fetch(apiKey,request);
if(!rsp.ok){
if(rsp.status===404){
thrownewError(
`Unable to explain commit: Your API key doesn't seem to have access to the selected '${model}' model`,
);
}
if(rsp.status===429){
thrownewError(
`Unable to explain commit: (${this.name}:${rsp.status}) Too many requests (rate limit exceeded) or your API key is associated with an expired trial`,