diff --git a/CHANGELOG.md b/CHANGELOG.md index e5e1b2f..bdb67d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Adds support for deep links to comparisons. Deep links of this format take the form `vscode://eamodio.gitlens/r/{repoId}/compare/{ref1}[..|...]{ref2}?[url={remoteUrl}|path={repoPath}]` and open the comparison in the _Search & Compare_ view - Adds the `Share` submenu to the context menu for Comparison items in the _Search & Compare_ view with a new command `Copy Link to Comparison` to copy the deep link to that comparison to the clipboard - Adds experimental native fetch support (enabled by setting `gitlens.experimental.nativeGit` to `true` in settings) as a potential fix to some auth issues with GitLens git operations +- Adds support for Anthropic's Claude 2 AI model ### Changed diff --git a/package.json b/package.json index f73416f..5275d81 100644 --- a/package.json +++ b/package.json @@ -2885,13 +2885,15 @@ "claude-v1", "claude-v1-100k", "claude-instant-v1", - "claude-instant-v1-100k" + "claude-instant-v1-100k", + "claude-2" ], "enumDescriptions": [ "Claude v1", "Claude v1 100k", "Claude Instant v1", - "Claude Instant v1 100k" + "Claude Instant v1 100k", + "Claude 2" ], "markdownDescription": "Specifies the Anthropic model to use for GitLens' experimental AI features", "scope": "window", diff --git a/src/ai/anthropicProvider.ts b/src/ai/anthropicProvider.ts index 7e0def8..1b4efe6 100644 --- a/src/ai/anthropicProvider.ts +++ b/src/ai/anthropicProvider.ts @@ -69,8 +69,17 @@ export class AnthropicProvider implements AIProvider { }); if (!rsp.ok) { + let json; + try { + json = (await rsp.json()) as { error: { type: string; message: string } } | undefined; + } catch {} + debugger; - throw new Error(`Unable to generate commit message: ${rsp.status}: ${rsp.statusText}`); + throw new Error( + `Unable to generate commit message: (${this.name}:${rsp.status}) ${ + json?.error.message || rsp.statusText + })`, + ); } const data: AnthropicCompletionResponse = await rsp.json(); @@ -114,14 +123,22 @@ export class AnthropicProvider implements AIProvider { 'Content-Type': 'application/json', Client: 'anthropic-typescript/0.4.3', 'X-API-Key': apiKey, + 'anthropic-version': '2023-06-01', }, method: 'POST', body: JSON.stringify(request), }); if (!rsp.ok) { + let json; + try { + json = (await rsp.json()) as { error: { type: string; message: string } } | undefined; + } catch {} + debugger; - throw new Error(`Unable to explain commit: ${rsp.status}: ${rsp.statusText}`); + throw new Error( + `Unable to explain commit: (${this.name}:${rsp.status}) ${json?.error.message || rsp.statusText})`, + ); } const data: AnthropicCompletionResponse = await rsp.json(); @@ -194,12 +211,17 @@ async function getApiKey(storage: Storage): Promise { } function getMaxCharacters(model: AnthropicModels): number { - if (model === 'claude-v1-100k' || model === 'claude-instant-v1-100k') { + if (model === 'claude-2' || model === 'claude-v1-100k' || model === 'claude-instant-v1-100k') { return 135000; } return 12000; } -export type AnthropicModels = 'claude-v1' | 'claude-v1-100k' | 'claude-instant-v1' | 'claude-instant-v1-100k'; +export type AnthropicModels = + | 'claude-v1' + | 'claude-v1-100k' + | 'claude-instant-v1' + | 'claude-instant-v1-100k' + | 'claude-2'; interface AnthropicCompletionRequest { model: string; diff --git a/src/quickpicks/aiModelPicker.ts b/src/quickpicks/aiModelPicker.ts index 78a6565..f82e487 100644 --- a/src/quickpicks/aiModelPicker.ts +++ b/src/quickpicks/aiModelPicker.ts @@ -35,6 +35,7 @@ export async function showAIModelPicker(): Promise