@@ -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,11 @@ 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+ this . handler = new OpenRouterHandler ( {
4141 ...options ,
42- apiKey : options . pearaiApiKey ,
43- anthropicBaseUrl : PEARAI_URL ,
44- apiModelId : "claude-3-5-sonnet-20241022 " ,
42+ openRouterBaseUrl : PEARAI_URL ,
43+ openRouterApiKey : options . pearaiApiKey ,
44+ openRouterModelId : "deepseek/deepseek-chat-v3-0324 " ,
4545 } )
4646
4747 // Then try to initialize the correct handler asynchronously
@@ -63,11 +63,11 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
6363 const underlyingModel = data . models [ modelId ] ?. underlyingModel || "claude-3-5-sonnet-20241022"
6464 console . dir ( underlyingModel )
6565 if ( underlyingModel . startsWith ( "deepseek" ) ) {
66- this . handler = new DeepSeekHandler ( {
66+ this . handler = new OpenRouterHandler ( {
6767 ...options ,
68- deepSeekApiKey : options . pearaiApiKey ,
69- deepSeekBaseUrl : PEARAI_URL ,
70- apiModelId : underlyingModel ,
68+ openRouterBaseUrl : PEARAI_URL ,
69+ openRouterApiKey : options . pearaiApiKey ,
70+ openRouterModelId : underlyingModel ,
7171 } )
7272 } else {
7373 // Default to Claude
@@ -95,10 +95,11 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
9595 anthropicBaseUrl : PEARAI_URL ,
9696 } )
9797 } else if ( modelId . startsWith ( "deepseek" ) ) {
98- this . handler = new DeepSeekHandler ( {
98+ this . handler = new OpenRouterHandler ( {
9999 ...options ,
100- deepSeekApiKey : options . pearaiApiKey ,
101- deepSeekBaseUrl : PEARAI_URL ,
100+ openRouterBaseUrl : PEARAI_URL ,
101+ openRouterApiKey : options . pearaiApiKey ,
102+ openRouterModelId : modelId ,
102103 } )
103104 } else {
104105 throw new Error ( `Unsupported model: ${ modelId } ` )
0 commit comments