Skip to content

Commit 56164b1

Browse files
authored
Merge pull request #15 from trypear/fee
Update pricing
2 parents 20078ed + 4d2d20a commit 56164b1

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

src/api/providers/pearai.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { OpenAiHandler } from "./openai"
21
import * as vscode from "vscode"
3-
import { ApiHandlerOptions, PEARAI_URL } from "../../shared/api"
2+
import { ApiHandlerOptions, PEARAI_URL, AnthropicModelId, ModelInfo } from "../../shared/api"
43
import { AnthropicHandler } from "./anthropic"
54

65
export class PearAiHandler extends AnthropicHandler {
@@ -10,12 +9,9 @@ export class PearAiHandler extends AnthropicHandler {
109
if (selection === "Login to PearAI") {
1110
const extensionUrl = `${vscode.env.uriScheme}://pearai.pearai/auth`
1211
const callbackUri = await vscode.env.asExternalUri(vscode.Uri.parse(extensionUrl))
13-
1412
vscode.env.openExternal(
1513
await vscode.env.asExternalUri(
16-
vscode.Uri.parse(
17-
`https://trypear.ai/signin?callback=${callbackUri.toString()}`, // Change to localhost if running locally
18-
),
14+
vscode.Uri.parse(`https://trypear.ai/signin?callback=${callbackUri.toString()}`),
1915
),
2016
)
2117
}
@@ -28,4 +24,18 @@ export class PearAiHandler extends AnthropicHandler {
2824
anthropicBaseUrl: PEARAI_URL,
2925
})
3026
}
27+
28+
override getModel(): { id: AnthropicModelId; info: ModelInfo } {
29+
const baseModel = super.getModel()
30+
return {
31+
id: baseModel.id,
32+
info: {
33+
...baseModel.info,
34+
inputPrice: (baseModel.info.inputPrice || 0) * 1.03,
35+
outputPrice: (baseModel.info.outputPrice || 0) * 1.03,
36+
cacheWritesPrice: baseModel.info.cacheWritesPrice ? baseModel.info.cacheWritesPrice * 1.03 : undefined,
37+
cacheReadsPrice: baseModel.info.cacheReadsPrice ? baseModel.info.cacheReadsPrice * 1.03 : undefined,
38+
},
39+
}
40+
}
3141
}

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,12 +1627,22 @@ export function normalizeApiConfiguration(apiConfiguration?: ApiConfiguration) {
16271627
supportsImages: false, // VSCode LM API currently doesn't support images
16281628
},
16291629
}
1630-
case "pearai":
1630+
case "pearai": {
1631+
// Get the base Anthropic model info
1632+
const baseModelInfo = anthropicModels[anthropicDefaultModelId]
1633+
const pearaiModelInfo: ModelInfo = {
1634+
...baseModelInfo,
1635+
inputPrice: baseModelInfo.inputPrice,
1636+
outputPrice: baseModelInfo.outputPrice,
1637+
cacheWritesPrice: baseModelInfo.cacheWritesPrice ? baseModelInfo.cacheWritesPrice : undefined,
1638+
cacheReadsPrice: baseModelInfo.cacheWritesPrice ? baseModelInfo.cacheReadsPrice : undefined,
1639+
}
16311640
return {
16321641
selectedProvider: provider,
16331642
selectedModelId: apiConfiguration?.pearaiModelId || "pearai_model",
1634-
selectedModelInfo: apiConfiguration?.pearaiModelInfo || openAiModelInfoSaneDefaults,
1643+
selectedModelInfo: pearaiModelInfo,
16351644
}
1645+
}
16361646
case "unbound":
16371647
return getProviderData(unboundModels, unboundDefaultModelId)
16381648
default:

0 commit comments

Comments
 (0)