From 32dc0a46b79ed539f8ba46124c5e295a63b6340d Mon Sep 17 00:00:00 2001 From: nang-dev Date: Sun, 23 Feb 2025 20:04:12 -0500 Subject: [PATCH 1/6] Added pricing --- src/api/providers/pearai.ts | 8 ++++++++ .../src/components/settings/ApiOptions.tsx | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/api/providers/pearai.ts b/src/api/providers/pearai.ts index ba79fb2149e..2c6c0a90805 100644 --- a/src/api/providers/pearai.ts +++ b/src/api/providers/pearai.ts @@ -5,6 +5,14 @@ import { AnthropicHandler } from "./anthropic" export class PearAiHandler extends AnthropicHandler { constructor(options: ApiHandlerOptions) { + if (options.pearaiModelInfo) { + options.pearaiModelInfo = { + ...options.pearaiModelInfo, + inputPrice: options.pearaiModelInfo.inputPrice ? options.pearaiModelInfo.inputPrice * 1.03 : 0, + outputPrice: options.pearaiModelInfo.outputPrice ? options.pearaiModelInfo.outputPrice * 1.03 : 0, + } + } + if (!options.pearaiApiKey) { vscode.window.showErrorMessage("PearAI API key not found.", "Login to PearAI").then(async (selection) => { if (selection === "Login to PearAI") { diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index da078530326..602304bf89a 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -1627,12 +1627,23 @@ export function normalizeApiConfiguration(apiConfiguration?: ApiConfiguration) { supportsImages: false, // VSCode LM API currently doesn't support images }, } - case "pearai": + case "pearai": { + // Get the base Anthropic model info + const baseModelInfo = anthropicModels[anthropicDefaultModelId] + // Create PearAI model info with 1.03x price multiplier + const pearaiModelInfo: ModelInfo = { + ...baseModelInfo, + inputPrice: baseModelInfo.inputPrice * 1.03, + outputPrice: baseModelInfo.outputPrice * 1.03, + cacheWritesPrice: baseModelInfo.cacheWritesPrice ? baseModelInfo.cacheWritesPrice * 1.03 : undefined, + cacheReadsPrice: baseModelInfo.cacheReadsPrice ? baseModelInfo.cacheReadsPrice * 1.03 : undefined, + } return { selectedProvider: provider, - selectedModelId: apiConfiguration?.pearaiModelId || "pearai_model", - selectedModelInfo: apiConfiguration?.pearaiModelInfo || openAiModelInfoSaneDefaults, + selectedModelId: apiConfiguration?.pearaiModelId || anthropicDefaultModelId, + selectedModelInfo: apiConfiguration?.pearaiModelInfo || pearaiModelInfo, } + } case "unbound": return getProviderData(unboundModels, unboundDefaultModelId) default: From c13269d76cc8ca9b8508c1bd4156ab4fd98c247c Mon Sep 17 00:00:00 2001 From: nang-dev Date: Sun, 23 Feb 2025 20:04:54 -0500 Subject: [PATCH 2/6] Added pricing --- src/api/providers/pearai.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/providers/pearai.ts b/src/api/providers/pearai.ts index 2c6c0a90805..ad6fc07774b 100644 --- a/src/api/providers/pearai.ts +++ b/src/api/providers/pearai.ts @@ -8,8 +8,8 @@ export class PearAiHandler extends AnthropicHandler { if (options.pearaiModelInfo) { options.pearaiModelInfo = { ...options.pearaiModelInfo, - inputPrice: options.pearaiModelInfo.inputPrice ? options.pearaiModelInfo.inputPrice * 1.03 : 0, - outputPrice: options.pearaiModelInfo.outputPrice ? options.pearaiModelInfo.outputPrice * 1.03 : 0, + inputPrice: options.pearaiModelInfo.inputPrice ? options.pearaiModelInfo.inputPrice * 1.025 : 0, + outputPrice: options.pearaiModelInfo.outputPrice ? options.pearaiModelInfo.outputPrice * 1.025 : 0, } } From 7ae537b53ffc4b1e7f7e7b9aa2640a694512c9a7 Mon Sep 17 00:00:00 2001 From: nang-dev Date: Sun, 23 Feb 2025 22:32:56 -0500 Subject: [PATCH 3/6] Added working --- src/api/providers/pearai.ts | 30 ++++++++++--------- .../src/components/settings/ApiOptions.tsx | 12 ++++---- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/api/providers/pearai.ts b/src/api/providers/pearai.ts index ad6fc07774b..256d1bb4a8f 100644 --- a/src/api/providers/pearai.ts +++ b/src/api/providers/pearai.ts @@ -1,29 +1,17 @@ -import { OpenAiHandler } from "./openai" import * as vscode from "vscode" -import { ApiHandlerOptions, PEARAI_URL } from "../../shared/api" +import { ApiHandlerOptions, PEARAI_URL, AnthropicModelId, ModelInfo } from "../../shared/api" import { AnthropicHandler } from "./anthropic" export class PearAiHandler extends AnthropicHandler { constructor(options: ApiHandlerOptions) { - if (options.pearaiModelInfo) { - options.pearaiModelInfo = { - ...options.pearaiModelInfo, - inputPrice: options.pearaiModelInfo.inputPrice ? options.pearaiModelInfo.inputPrice * 1.025 : 0, - outputPrice: options.pearaiModelInfo.outputPrice ? options.pearaiModelInfo.outputPrice * 1.025 : 0, - } - } - if (!options.pearaiApiKey) { vscode.window.showErrorMessage("PearAI API key not found.", "Login to PearAI").then(async (selection) => { if (selection === "Login to PearAI") { const extensionUrl = `${vscode.env.uriScheme}://pearai.pearai/auth` const callbackUri = await vscode.env.asExternalUri(vscode.Uri.parse(extensionUrl)) - vscode.env.openExternal( await vscode.env.asExternalUri( - vscode.Uri.parse( - `https://trypear.ai/signin?callback=${callbackUri.toString()}`, // Change to localhost if running locally - ), + vscode.Uri.parse(`https://trypear.ai/signin?callback=${callbackUri.toString()}`), ), ) } @@ -36,4 +24,18 @@ export class PearAiHandler extends AnthropicHandler { anthropicBaseUrl: PEARAI_URL, }) } + + override getModel(): { id: AnthropicModelId; info: ModelInfo } { + const baseModel = super.getModel() + return { + id: baseModel.id, + info: { + ...baseModel.info, + inputPrice: (baseModel.info.inputPrice || 0) * 1.025, + outputPrice: (baseModel.info.outputPrice || 0) * 1.025, + cacheWritesPrice: baseModel.info.cacheWritesPrice ? baseModel.info.cacheWritesPrice * 1.025 : undefined, + cacheReadsPrice: baseModel.info.cacheReadsPrice ? baseModel.info.cacheReadsPrice * 1.025 : undefined, + }, + } + } } diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index 602304bf89a..37bb0f72ee8 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -1633,15 +1633,15 @@ export function normalizeApiConfiguration(apiConfiguration?: ApiConfiguration) { // Create PearAI model info with 1.03x price multiplier const pearaiModelInfo: ModelInfo = { ...baseModelInfo, - inputPrice: baseModelInfo.inputPrice * 1.03, - outputPrice: baseModelInfo.outputPrice * 1.03, - cacheWritesPrice: baseModelInfo.cacheWritesPrice ? baseModelInfo.cacheWritesPrice * 1.03 : undefined, - cacheReadsPrice: baseModelInfo.cacheReadsPrice ? baseModelInfo.cacheReadsPrice * 1.03 : undefined, + inputPrice: baseModelInfo.inputPrice, + outputPrice: baseModelInfo.outputPrice, + cacheWritesPrice: baseModelInfo.cacheWritesPrice ? baseModelInfo.cacheWritesPrice : undefined, + cacheReadsPrice: baseModelInfo.cacheWritesPrice ? baseModelInfo.cacheReadsPrice : undefined, } return { selectedProvider: provider, - selectedModelId: apiConfiguration?.pearaiModelId || anthropicDefaultModelId, - selectedModelInfo: apiConfiguration?.pearaiModelInfo || pearaiModelInfo, + selectedModelId: anthropicDefaultModelId, + selectedModelInfo: pearaiModelInfo, } } case "unbound": From ffb8a286e59b8ca53c0b2385bf5751e8a763c4a8 Mon Sep 17 00:00:00 2001 From: nang-dev Date: Sun, 23 Feb 2025 22:34:59 -0500 Subject: [PATCH 4/6] Added working --- webview-ui/src/components/settings/ApiOptions.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index 37bb0f72ee8..99fbb8468c5 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -1630,7 +1630,6 @@ export function normalizeApiConfiguration(apiConfiguration?: ApiConfiguration) { case "pearai": { // Get the base Anthropic model info const baseModelInfo = anthropicModels[anthropicDefaultModelId] - // Create PearAI model info with 1.03x price multiplier const pearaiModelInfo: ModelInfo = { ...baseModelInfo, inputPrice: baseModelInfo.inputPrice, From 888fb89505b288e74c904ceaf49d2e0f10f93b26 Mon Sep 17 00:00:00 2001 From: nang-dev Date: Sun, 23 Feb 2025 22:42:31 -0500 Subject: [PATCH 5/6] Added working --- webview-ui/src/components/settings/ApiOptions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index 99fbb8468c5..1673986498b 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -1639,7 +1639,7 @@ export function normalizeApiConfiguration(apiConfiguration?: ApiConfiguration) { } return { selectedProvider: provider, - selectedModelId: anthropicDefaultModelId, + selectedModelId: apiConfiguration?.pearaiModelId || "pearai_model", selectedModelInfo: pearaiModelInfo, } } From 4d2d20af2447f9bf7ee287a9a22f9cfb47fdaf71 Mon Sep 17 00:00:00 2001 From: nang-dev Date: Sun, 23 Feb 2025 22:45:36 -0500 Subject: [PATCH 6/6] Added working --- src/api/providers/pearai.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/providers/pearai.ts b/src/api/providers/pearai.ts index 256d1bb4a8f..a197b96ac32 100644 --- a/src/api/providers/pearai.ts +++ b/src/api/providers/pearai.ts @@ -31,10 +31,10 @@ export class PearAiHandler extends AnthropicHandler { id: baseModel.id, info: { ...baseModel.info, - inputPrice: (baseModel.info.inputPrice || 0) * 1.025, - outputPrice: (baseModel.info.outputPrice || 0) * 1.025, - cacheWritesPrice: baseModel.info.cacheWritesPrice ? baseModel.info.cacheWritesPrice * 1.025 : undefined, - cacheReadsPrice: baseModel.info.cacheReadsPrice ? baseModel.info.cacheReadsPrice * 1.025 : undefined, + inputPrice: (baseModel.info.inputPrice || 0) * 1.03, + outputPrice: (baseModel.info.outputPrice || 0) * 1.03, + cacheWritesPrice: baseModel.info.cacheWritesPrice ? baseModel.info.cacheWritesPrice * 1.03 : undefined, + cacheReadsPrice: baseModel.info.cacheReadsPrice ? baseModel.info.cacheReadsPrice * 1.03 : undefined, }, } }