feat(openai): add custom model info configuration

Adds support for configuring custom OpenAI-compatible model capabilities and pricing, including:

Max output tokens
Context window size
Image/computer use support
Input/output token pricing
Cache read/write pricing
This commit is contained in:
sam hoang
2025-01-12 19:28:25 +07:00
parent 9a2bfcce64
commit d50e075c75
5 changed files with 188 additions and 2 deletions

View File

@@ -68,6 +68,7 @@ type GlobalStateKey =
| "taskHistory"
| "openAiBaseUrl"
| "openAiModelId"
| "openAiCusModelInfo"
| "ollamaModelId"
| "ollamaBaseUrl"
| "lmStudioModelId"
@@ -1198,6 +1199,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
openAiBaseUrl,
openAiApiKey,
openAiModelId,
openAiCusModelInfo,
ollamaModelId,
ollamaBaseUrl,
lmStudioModelId,
@@ -1231,6 +1233,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
await this.updateGlobalState("openAiBaseUrl", openAiBaseUrl)
await this.storeSecret("openAiApiKey", openAiApiKey)
await this.updateGlobalState("openAiModelId", openAiModelId)
await this.updateGlobalState("openAiCusModelInfo", openAiCusModelInfo)
await this.updateGlobalState("ollamaModelId", ollamaModelId)
await this.updateGlobalState("ollamaBaseUrl", ollamaBaseUrl)
await this.updateGlobalState("lmStudioModelId", lmStudioModelId)
@@ -1847,6 +1850,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
openAiBaseUrl,
openAiApiKey,
openAiModelId,
openAiCusModelInfo,
ollamaModelId,
ollamaBaseUrl,
lmStudioModelId,
@@ -1910,6 +1914,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
this.getGlobalState("openAiBaseUrl") as Promise<string | undefined>,
this.getSecret("openAiApiKey") as Promise<string | undefined>,
this.getGlobalState("openAiModelId") as Promise<string | undefined>,
this.getGlobalState("openAiCusModelInfo") as Promise<ModelInfo | undefined>,
this.getGlobalState("ollamaModelId") as Promise<string | undefined>,
this.getGlobalState("ollamaBaseUrl") as Promise<string | undefined>,
this.getGlobalState("lmStudioModelId") as Promise<string | undefined>,
@@ -1990,6 +1995,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
openAiBaseUrl,
openAiApiKey,
openAiModelId,
openAiCusModelInfo,
ollamaModelId,
ollamaBaseUrl,
lmStudioModelId,