1- import { OpenAiHandler } from "./openai"
21import * as vscode from "vscode"
3- import { ApiHandlerOptions , PEARAI_URL } from "../../shared/api"
2+ import { ApiHandlerOptions , PEARAI_URL , AnthropicModelId , ModelInfo } from "../../shared/api"
43import { AnthropicHandler } from "./anthropic"
54
65export class PearAiHandler extends AnthropicHandler {
76 constructor ( options : ApiHandlerOptions ) {
8- if ( options . pearaiModelInfo ) {
9- options . pearaiModelInfo = {
10- ...options . pearaiModelInfo ,
11- inputPrice : options . pearaiModelInfo . inputPrice ? options . pearaiModelInfo . inputPrice * 1.025 : 0 ,
12- outputPrice : options . pearaiModelInfo . outputPrice ? options . pearaiModelInfo . outputPrice * 1.025 : 0 ,
13- }
14- }
15-
167 if ( ! options . pearaiApiKey ) {
178 vscode . window . showErrorMessage ( "PearAI API key not found." , "Login to PearAI" ) . then ( async ( selection ) => {
189 if ( selection === "Login to PearAI" ) {
1910 const extensionUrl = `${ vscode . env . uriScheme } ://pearai.pearai/auth`
2011 const callbackUri = await vscode . env . asExternalUri ( vscode . Uri . parse ( extensionUrl ) )
21-
2212 vscode . env . openExternal (
2313 await vscode . env . asExternalUri (
24- vscode . Uri . parse (
25- `https://trypear.ai/signin?callback=${ callbackUri . toString ( ) } ` , // Change to localhost if running locally
26- ) ,
14+ vscode . Uri . parse ( `https://trypear.ai/signin?callback=${ callbackUri . toString ( ) } ` ) ,
2715 ) ,
2816 )
2917 }
@@ -36,4 +24,18 @@ export class PearAiHandler extends AnthropicHandler {
3624 anthropicBaseUrl : PEARAI_URL ,
3725 } )
3826 }
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.025 ,
35+ outputPrice : ( baseModel . info . outputPrice || 0 ) * 1.025 ,
36+ cacheWritesPrice : baseModel . info . cacheWritesPrice ? baseModel . info . cacheWritesPrice * 1.025 : undefined ,
37+ cacheReadsPrice : baseModel . info . cacheReadsPrice ? baseModel . info . cacheReadsPrice * 1.025 : undefined ,
38+ } ,
39+ }
40+ }
3941}
0 commit comments