-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from docker/cm/anthropic-provider
Model Provider Secrets
- Loading branch information
Showing
9 changed files
with
125 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { SecretStorage, ThemeIcon, window } from "vscode"; | ||
|
||
export const showSetSecretDialog = async (secrets: SecretStorage) => { | ||
const modelProviders = require('../modelproviders.json') as { label: string, id: string, patterns: string[] }[]; | ||
|
||
type QuickPickItem = { | ||
label: string; | ||
id: string; | ||
buttons: { | ||
iconPath: ThemeIcon; | ||
tooltip: string; | ||
onClick: () => void; | ||
}[]; | ||
}; | ||
|
||
const quickPick = window.createQuickPick<QuickPickItem>(); | ||
|
||
|
||
quickPick.items = modelProviders.map(provider => ({ | ||
label: provider.label, | ||
id: provider.id, | ||
buttons: [{ | ||
iconPath: new ThemeIcon('trashcan'), | ||
tooltip: 'Clear', onClick: () => { | ||
secrets.delete(provider.id); | ||
void window.showInformationMessage(`${provider.label} key cleared.`); | ||
} | ||
}] | ||
})); | ||
|
||
const modelProvider = await new Promise<QuickPickItem | undefined>((resolve) => { | ||
quickPick.onDidAccept(() => { | ||
resolve(quickPick.selectedItems[0]); | ||
quickPick.hide(); | ||
}); | ||
quickPick.onDidHide(() => { | ||
resolve(undefined); | ||
}); | ||
quickPick.onDidTriggerItemButton((event) => { | ||
secrets.delete(event.item.id); | ||
void window.showInformationMessage(`${event.item.label} key cleared.`); | ||
resolve(undefined); | ||
quickPick.hide(); | ||
}); | ||
quickPick.show(); | ||
}); | ||
|
||
if (!modelProvider) { | ||
return; | ||
} | ||
|
||
const secret = await window.showInputBox({ | ||
title: `Enter your ${modelProvider.label} API key`, | ||
password: true, | ||
prompt: `Enter your ${modelProvider.label} API key`, | ||
ignoreFocusOut: true, | ||
}); | ||
|
||
if (!secret) { | ||
return void window.showInformationMessage(`${modelProvider.label} key not set.`); | ||
} | ||
|
||
|
||
await secrets.store(modelProvider.id, secret); | ||
void window.showInformationMessage(`${modelProvider.label} key set.`); | ||
|
||
return modelProvider.id; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[ | ||
{ | ||
"label": "Anthropic Claude", | ||
"id": "anthropic", | ||
"file": ".claude-api-key", | ||
"patterns": [ | ||
"claude-*" | ||
] | ||
}, | ||
{ | ||
"label": "Open AI", | ||
"id": "openai", | ||
"file": ".openai-api-key", | ||
"patterns": [ | ||
"gpt-*" | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters