Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/api/providers/pearai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DeepSeekHandler } from "./deepseek"
import Anthropic from "@anthropic-ai/sdk"
import { BaseProvider } from "./base-provider"
import { SingleCompletionHandler } from "../"
import { OpenRouterHandler } from "./openrouter"

interface PearAiModelsResponse {
models: {
Expand All @@ -17,7 +18,7 @@ interface PearAiModelsResponse {
}

export class PearAiHandler extends BaseProvider implements SingleCompletionHandler {
private handler!: AnthropicHandler | DeepSeekHandler
private handler!: AnthropicHandler | DeepSeekHandler | OpenRouterHandler

constructor(options: ApiHandlerOptions) {
super()
Expand All @@ -36,12 +37,11 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
throw new Error("PearAI API key not found. Please login to PearAI.")
}

// Initialize with a default handler synchronously
this.handler = new AnthropicHandler({
this.handler = new OpenRouterHandler({
...options,
apiKey: options.pearaiApiKey,
anthropicBaseUrl: PEARAI_URL,
apiModelId: "claude-3-5-sonnet-20241022",
openRouterBaseUrl: PEARAI_URL,
openRouterApiKey: options.pearaiApiKey,
openRouterModelId: "deepseek/deepseek-chat-v3-0324",
})

// Then try to initialize the correct handler asynchronously
Expand All @@ -63,11 +63,11 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
const underlyingModel = data.models[modelId]?.underlyingModel || "claude-3-5-sonnet-20241022"
console.dir(underlyingModel)
if (underlyingModel.startsWith("deepseek")) {
this.handler = new DeepSeekHandler({
this.handler = new OpenRouterHandler({
...options,
deepSeekApiKey: options.pearaiApiKey,
deepSeekBaseUrl: PEARAI_URL,
apiModelId: underlyingModel,
openRouterBaseUrl: PEARAI_URL,
openRouterApiKey: options.pearaiApiKey,
openRouterModelId: underlyingModel,
})
} else {
// Default to Claude
Expand Down Expand Up @@ -95,10 +95,11 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
anthropicBaseUrl: PEARAI_URL,
})
} else if (modelId.startsWith("deepseek")) {
this.handler = new DeepSeekHandler({
this.handler = new OpenRouterHandler({
...options,
deepSeekApiKey: options.pearaiApiKey,
deepSeekBaseUrl: PEARAI_URL,
openRouterBaseUrl: PEARAI_URL,
openRouterApiKey: options.pearaiApiKey,
openRouterModelId: modelId,
})
} else {
throw new Error(`Unsupported model: ${modelId}`)
Expand Down
4 changes: 2 additions & 2 deletions src/core/Cline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ export class Cline extends EventEmitter<ClineEvents> {
async sayAndCreateMissingParamError(toolName: ToolUseName, paramName: string, relPath?: string) {
await this.say(
"error",
`Roo tried to use ${toolName}${
`Agent tried to use ${toolName}${
relPath ? ` for '${relPath.toPosix()}'` : ""
} without value for required parameter '${paramName}'. Retrying...`,
)
Expand Down Expand Up @@ -2750,7 +2750,7 @@ export class Cline extends EventEmitter<ClineEvents> {
this.consecutiveMistakeCount++
await this.say(
"error",
`Roo tried to use ${tool_name} with an invalid JSON argument. Retrying...`,
`Agent tried to use ${tool_name} with an invalid JSON argument. Retrying...`,
)
pushToolResult(
formatResponse.toolError(
Expand Down
Loading