Add support for OpenRouter and AWS Bedrock

This commit is contained in:
Saoud Rizwan
2024-08-03 14:24:56 -04:00
parent d441950b7f
commit c09a8462d7
19 changed files with 4458 additions and 194 deletions

View File

@@ -1,5 +1,7 @@
// type that represents json data that is sent from extension to webview, called ExtensionMessage and has 'type' enum which can be 'plusButtonTapped' or 'settingsButtonTapped' or 'hello'
import { ApiConfiguration } from "./api"
// webview will hold state
export interface ExtensionMessage {
type: "action" | "state"
@@ -9,7 +11,7 @@ export interface ExtensionMessage {
}
export interface ExtensionState {
apiKey?: string
apiConfiguration?: ApiConfiguration
maxRequestsPerTask?: number
themeName?: string
claudeMessages: ClaudeMessage[]

View File

@@ -1,6 +1,8 @@
import { ApiConfiguration, ApiProvider } from "./api"
export interface WebviewMessage {
type:
| "apiKey"
| "apiConfiguration"
| "maxRequestsPerTask"
| "webviewDidLaunch"
| "newTask"
@@ -10,6 +12,7 @@ export interface WebviewMessage {
| "downloadTask"
text?: string
askResponse?: ClaudeAskResponse
apiConfiguration?: ApiConfiguration
}
export type ClaudeAskResponse = "yesButtonTapped" | "noButtonTapped" | "textResponse"

13
src/shared/api.ts Normal file
View File

@@ -0,0 +1,13 @@
export type ApiProvider = "anthropic" | "openrouter" | "bedrock"
export interface ApiHandlerOptions {
apiKey?: string // anthropic
openRouterApiKey?: string
awsAccessKey?: string
awsSecretKey?: string
awsRegion?: string
}
export type ApiConfiguration = ApiHandlerOptions & {
apiProvider?: ApiProvider
}