Skip to content

Commit ccc1770

Browse files
authored
Merge pull request #44 from trypear/openrouter
Switch Deepseek Provider to OpenRouter
2 parents bd713ba + 7ad9e19 commit ccc1770

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

src/api/providers/pearai.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { DeepSeekHandler } from "./deepseek"
55
import Anthropic from "@anthropic-ai/sdk"
66
import { BaseProvider } from "./base-provider"
77
import { SingleCompletionHandler } from "../"
8+
import { OpenRouterHandler } from "./openrouter"
89

910
interface PearAiModelsResponse {
1011
models: {
@@ -17,7 +18,7 @@ interface PearAiModelsResponse {
1718
}
1819

1920
export 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}`)

src/core/Cline.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ export class Cline extends EventEmitter<ClineEvents> {
582582
async sayAndCreateMissingParamError(toolName: ToolUseName, paramName: string, relPath?: string) {
583583
await this.say(
584584
"error",
585-
`Roo tried to use ${toolName}${
585+
`Agent tried to use ${toolName}${
586586
relPath ? ` for '${relPath.toPosix()}'` : ""
587587
} without value for required parameter '${paramName}'. Retrying...`,
588588
)
@@ -2750,7 +2750,7 @@ export class Cline extends EventEmitter<ClineEvents> {
27502750
this.consecutiveMistakeCount++
27512751
await this.say(
27522752
"error",
2753-
`Roo tried to use ${tool_name} with an invalid JSON argument. Retrying...`,
2753+
`Agent tried to use ${tool_name} with an invalid JSON argument. Retrying...`,
27542754
)
27552755
pushToolResult(
27562756
formatResponse.toolError(

0 commit comments

Comments
 (0)