mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
feat(vscode-lm): implement VS Code Language Models provider
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export type ApiProvider =
|
||||
| "anthropic"
|
||||
| "openrouter"
|
||||
@@ -9,11 +11,13 @@ export type ApiProvider =
|
||||
| "gemini"
|
||||
| "openai-native"
|
||||
| "deepseek"
|
||||
| "vscode-lm"
|
||||
|
||||
export interface ApiHandlerOptions {
|
||||
apiModelId?: string
|
||||
apiKey?: string // anthropic
|
||||
anthropicBaseUrl?: string
|
||||
vsCodeLmModelSelector?: vscode.LanguageModelChatSelector
|
||||
openRouterApiKey?: string
|
||||
openRouterModelId?: string
|
||||
openRouterModelInfo?: ModelInfo
|
||||
@@ -47,16 +51,17 @@ export interface ApiHandlerOptions {
|
||||
|
||||
export type ApiConfiguration = ApiHandlerOptions & {
|
||||
apiProvider?: ApiProvider
|
||||
vsCodeLmModelSelector?: vscode.LanguageModelChatSelector;
|
||||
}
|
||||
|
||||
// Models
|
||||
|
||||
export interface ModelInfo {
|
||||
maxTokens?: number
|
||||
contextWindow?: number
|
||||
contextWindow: number
|
||||
supportsImages?: boolean
|
||||
supportsComputerUse?: boolean
|
||||
supportsPromptCache: boolean // this value is hardcoded for now
|
||||
supportsPromptCache: boolean
|
||||
inputPrice?: number
|
||||
outputPrice?: number
|
||||
cacheWritesPrice?: number
|
||||
@@ -115,24 +120,24 @@ export const anthropicModels = {
|
||||
// AWS Bedrock
|
||||
// https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html
|
||||
export interface MessageContent {
|
||||
type: 'text' | 'image' | 'video' | 'tool_use' | 'tool_result';
|
||||
text?: string;
|
||||
source?: {
|
||||
type: 'base64';
|
||||
data: string | Uint8Array; // string for Anthropic, Uint8Array for Bedrock
|
||||
media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
||||
};
|
||||
// Video specific fields
|
||||
format?: string;
|
||||
s3Location?: {
|
||||
uri: string;
|
||||
bucketOwner?: string;
|
||||
};
|
||||
// Tool use and result fields
|
||||
toolUseId?: string;
|
||||
name?: string;
|
||||
input?: any;
|
||||
output?: any; // Used for tool_result type
|
||||
type: 'text' | 'image' | 'video' | 'tool_use' | 'tool_result';
|
||||
text?: string;
|
||||
source?: {
|
||||
type: 'base64';
|
||||
data: string | Uint8Array; // string for Anthropic, Uint8Array for Bedrock
|
||||
media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
||||
};
|
||||
// Video specific fields
|
||||
format?: string;
|
||||
s3Location?: {
|
||||
uri: string;
|
||||
bucketOwner?: string;
|
||||
};
|
||||
// Tool use and result fields
|
||||
toolUseId?: string;
|
||||
name?: string;
|
||||
input?: any;
|
||||
output?: any; // Used for tool_result type
|
||||
}
|
||||
|
||||
export type BedrockModelId = keyof typeof bedrockModels
|
||||
@@ -226,7 +231,7 @@ export const bedrockModels = {
|
||||
inputPrice: 0.25,
|
||||
outputPrice: 1.25,
|
||||
},
|
||||
"meta.llama3-2-90b-instruct-v1:0" : {
|
||||
"meta.llama3-2-90b-instruct-v1:0": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 128_000,
|
||||
supportsImages: true,
|
||||
@@ -235,7 +240,7 @@ export const bedrockModels = {
|
||||
inputPrice: 0.72,
|
||||
outputPrice: 0.72,
|
||||
},
|
||||
"meta.llama3-2-11b-instruct-v1:0" : {
|
||||
"meta.llama3-2-11b-instruct-v1:0": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 128_000,
|
||||
supportsImages: true,
|
||||
@@ -244,7 +249,7 @@ export const bedrockModels = {
|
||||
inputPrice: 0.16,
|
||||
outputPrice: 0.16,
|
||||
},
|
||||
"meta.llama3-2-3b-instruct-v1:0" : {
|
||||
"meta.llama3-2-3b-instruct-v1:0": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 128_000,
|
||||
supportsImages: false,
|
||||
@@ -253,7 +258,7 @@ export const bedrockModels = {
|
||||
inputPrice: 0.15,
|
||||
outputPrice: 0.15,
|
||||
},
|
||||
"meta.llama3-2-1b-instruct-v1:0" : {
|
||||
"meta.llama3-2-1b-instruct-v1:0": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 128_000,
|
||||
supportsImages: false,
|
||||
@@ -262,7 +267,7 @@ export const bedrockModels = {
|
||||
inputPrice: 0.1,
|
||||
outputPrice: 0.1,
|
||||
},
|
||||
"meta.llama3-1-405b-instruct-v1:0" : {
|
||||
"meta.llama3-1-405b-instruct-v1:0": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 128_000,
|
||||
supportsImages: false,
|
||||
@@ -271,7 +276,7 @@ export const bedrockModels = {
|
||||
inputPrice: 2.4,
|
||||
outputPrice: 2.4,
|
||||
},
|
||||
"meta.llama3-1-70b-instruct-v1:0" : {
|
||||
"meta.llama3-1-70b-instruct-v1:0": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 128_000,
|
||||
supportsImages: false,
|
||||
@@ -280,7 +285,7 @@ export const bedrockModels = {
|
||||
inputPrice: 0.72,
|
||||
outputPrice: 0.72,
|
||||
},
|
||||
"meta.llama3-1-8b-instruct-v1:0" : {
|
||||
"meta.llama3-1-8b-instruct-v1:0": {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 8_000,
|
||||
supportsImages: false,
|
||||
@@ -289,8 +294,8 @@ export const bedrockModels = {
|
||||
inputPrice: 0.22,
|
||||
outputPrice: 0.22,
|
||||
},
|
||||
"meta.llama3-70b-instruct-v1:0" : {
|
||||
maxTokens: 2048 ,
|
||||
"meta.llama3-70b-instruct-v1:0": {
|
||||
maxTokens: 2048,
|
||||
contextWindow: 8_000,
|
||||
supportsImages: false,
|
||||
supportsComputerUse: false,
|
||||
@@ -298,8 +303,8 @@ export const bedrockModels = {
|
||||
inputPrice: 2.65,
|
||||
outputPrice: 3.5,
|
||||
},
|
||||
"meta.llama3-8b-instruct-v1:0" : {
|
||||
maxTokens: 2048 ,
|
||||
"meta.llama3-8b-instruct-v1:0": {
|
||||
maxTokens: 2048,
|
||||
contextWindow: 4_000,
|
||||
supportsImages: false,
|
||||
supportsComputerUse: false,
|
||||
@@ -514,4 +519,3 @@ export const deepSeekModels = {
|
||||
// https://learn.microsoft.com/en-us/azure/ai-services/openai/api-version-deprecation
|
||||
// https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
|
||||
export const azureOpenAiDefaultApiVersion = "2024-08-01-preview"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user