1
- import { OpenAiHandler } from "./openai"
2
1
import * as vscode from "vscode"
3
- import { ApiHandlerOptions , PEARAI_URL } from "../../shared/api"
2
+ import { ApiHandlerOptions , PEARAI_URL , AnthropicModelId , ModelInfo } from "../../shared/api"
4
3
import { AnthropicHandler } from "./anthropic"
5
4
6
5
export class PearAiHandler extends AnthropicHandler {
7
6
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
-
16
7
if ( ! options . pearaiApiKey ) {
17
8
vscode . window . showErrorMessage ( "PearAI API key not found." , "Login to PearAI" ) . then ( async ( selection ) => {
18
9
if ( selection === "Login to PearAI" ) {
19
10
const extensionUrl = `${ vscode . env . uriScheme } ://pearai.pearai/auth`
20
11
const callbackUri = await vscode . env . asExternalUri ( vscode . Uri . parse ( extensionUrl ) )
21
-
22
12
vscode . env . openExternal (
23
13
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 ( ) } ` ) ,
27
15
) ,
28
16
)
29
17
}
@@ -36,4 +24,18 @@ export class PearAiHandler extends AnthropicHandler {
36
24
anthropicBaseUrl : PEARAI_URL ,
37
25
} )
38
26
}
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
+ }
39
41
}
0 commit comments