@@ -5,6 +5,7 @@ import { DeepSeekHandler } from "./deepseek"
55import Anthropic from "@anthropic-ai/sdk"
66import { BaseProvider } from "./base-provider"
77import { SingleCompletionHandler } from "../"
8+ import { OpenRouterHandler } from "./openrouter"
89
910interface PearAiModelsResponse {
1011 models : {
@@ -17,7 +18,7 @@ interface PearAiModelsResponse {
1718}
1819
1920export class PearAiHandler extends BaseProvider implements SingleCompletionHandler {
20- private handler ! : AnthropicHandler | DeepSeekHandler
21+ private handler ! : AnthropicHandler | DeepSeekHandler | OpenRouterHandler
2122
2223 constructor ( options : ApiHandlerOptions ) {
2324 super ( )
@@ -36,12 +37,19 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
3637 throw new Error ( "PearAI API key not found. Please login to PearAI." )
3738 }
3839
39- // Initialize with a default handler synchronously
40- this . handler = new AnthropicHandler ( {
40+ // // Initialize with a default handler synchronously
41+ // this.handler = new AnthropicHandler({
42+ // ...options,
43+ // apiKey: options.pearaiApiKey,
44+ // anthropicBaseUrl: PEARAI_URL,
45+ // apiModelId: "claude-3-5-sonnet-20241022",
46+ // })
47+
48+ this . handler = new OpenRouterHandler ( {
4149 ...options ,
42- apiKey : options . pearaiApiKey ,
43- anthropicBaseUrl : PEARAI_URL ,
44- apiModelId : "claude-3-5-sonnet-20241022 " ,
50+ openRouterBaseUrl : PEARAI_URL ,
51+ openRouterApiKey : options . pearaiApiKey ,
52+ openRouterModelId : "deepseek/deepseek-chat-v3-0324 " ,
4553 } )
4654
4755 // Then try to initialize the correct handler asynchronously
@@ -95,10 +103,16 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
95103 anthropicBaseUrl : PEARAI_URL ,
96104 } )
97105 } else if ( modelId . startsWith ( "deepseek" ) ) {
98- this . handler = new DeepSeekHandler ( {
106+ // this.handler = new DeepSeekHandler({
107+ // ...options,
108+ // deepSeekApiKey: options.pearaiApiKey,
109+ // deepSeekBaseUrl: PEARAI_URL,
110+ // })
111+ this . handler = new OpenRouterHandler ( {
99112 ...options ,
100- deepSeekApiKey : options . pearaiApiKey ,
101- deepSeekBaseUrl : PEARAI_URL ,
113+ openRouterBaseUrl : PEARAI_URL ,
114+ openRouterApiKey : options . pearaiApiKey ,
115+ openRouterModelId : modelId ,
102116 } )
103117 } else {
104118 throw new Error ( `Unsupported model: ${ modelId } ` )
0 commit comments