Procházet zdrojové kódy

Adds support for Anthropic's Claude 2 AI model

main
Eric Amodio před 1 rokem
rodič
revize
45630196d3
4 změnil soubory, kde provedl 32 přidání a 6 odebrání
  1. +1
    -0
      CHANGELOG.md
  2. +4
    -2
      package.json
  3. +26
    -4
      src/ai/anthropicProvider.ts
  4. +1
    -0
      src/quickpicks/aiModelPicker.ts

+ 1
- 0
CHANGELOG.md Zobrazit soubor

@ -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

+ 4
- 2
package.json Zobrazit soubor

@ -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",

+ 26
- 4
src/ai/anthropicProvider.ts Zobrazit soubor

@ -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;

+ 1
- 0
src/quickpicks/aiModelPicker.ts Zobrazit soubor

@ -35,6 +35,7 @@ export async function showAIModelPicker(): Promise
provider: 'anthropic',
model: 'claude-instant-v1-100k',
},
{ label: 'Anthropic', description: 'Claude 2', provider: 'anthropic', model: 'claude-2' },
];
for (const item of items) {

Načítá se…
Zrušit
Uložit