From 1a3c1b7f8c4b88568053d27e230af578db3a0717 Mon Sep 17 00:00:00 2001 From: nang-dev Date: Mon, 21 Apr 2025 14:57:12 -0400 Subject: [PATCH 1/5] Added server down --- src/core/webview/ClineProvider.ts | 29 ++++++++++++++++----- src/integrations/editor/DiffViewProvider.ts | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index a113472d734..7c19c7e2028 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -462,12 +462,19 @@ export class ClineProvider extends EventEmitter implements } public async getPearAIAgentModels() { - const response = await fetch(`${PEARAI_URL}/getPearAIAgentModels`) - if (!response.ok) { - throw new Error(`Failed to fetch models: ${response.statusText}`) + try { + const response = await fetch(`${PEARAI_URL}/getPearAIAgentModels`) + if (!response.ok) { + throw new Error(`Failed to fetch models: ${response.statusText}`) + } + const data = (await response.json()) as PearAIAgentModelsConfig + return data + } catch (error) { + vscode.window.showErrorMessage( + "Failed to fetch PearAI Agent Models. PearAI services may be down, please contact PearAI Support.", + ) + return undefined } - const data = (await response.json()) as PearAIAgentModelsConfig - return data } public async initClineWithSubTask(parent: Cline, task?: string, images?: string[]) { @@ -493,7 +500,15 @@ export class ClineProvider extends EventEmitter implements const modePrompt = customModePrompts?.[mode] as PromptComponent const effectiveInstructions = [globalInstructions, modePrompt?.customInstructions].filter(Boolean).join("\n\n") - const pearaiAgentModels = await this.getPearAIAgentModels() + let pearaiAgentModels + + try { + pearaiAgentModels = await this.getPearAIAgentModels() + } catch (error) { + vscode.window.showErrorMessage( + "Failed to fetch PearAI Agent Models. PearAI services may be down, please contact PearAI Support.", + ) + } const cline = new Cline({ provider: this, @@ -655,7 +670,7 @@ export class ClineProvider extends EventEmitter implements - Roo Code + Agent
diff --git a/src/integrations/editor/DiffViewProvider.ts b/src/integrations/editor/DiffViewProvider.ts index 0bf494854a4..86eddf115e1 100644 --- a/src/integrations/editor/DiffViewProvider.ts +++ b/src/integrations/editor/DiffViewProvider.ts @@ -299,7 +299,7 @@ export class DiffViewProvider { query: Buffer.from(this.originalContent ?? "").toString("base64"), }), uri, - `${fileName}: ${fileExists ? "Original ↔ Roo's Changes" : "New File"} (Editable)`, + `${fileName}: ${fileExists ? "Original ↔ Agent's Changes" : "New File"} (Editable)`, ) // This may happen on very slow machines ie project idx setTimeout(() => { From fc228d0d299b2a217f43ce5b5bd931e251bef7a3 Mon Sep 17 00:00:00 2001 From: nang-dev Date: Mon, 21 Apr 2025 14:30:10 -0400 Subject: [PATCH 2/5] Progress --- src/api/providers/anthropic.ts | 38 ++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/api/providers/anthropic.ts b/src/api/providers/anthropic.ts index a1773d8c52b..e1a6925ab22 100644 --- a/src/api/providers/anthropic.ts +++ b/src/api/providers/anthropic.ts @@ -227,6 +227,19 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa id = "claude-3-7-sonnet-20250219" } + // PATCH for issue with update + const fallbackModelInfo: ModelInfo = { + maxTokens: 8192, + contextWindow: 200_000, + supportsImages: true, + supportsComputerUse: true, + supportsPromptCache: true, + inputPrice: 3.0, + outputPrice: 15.0, + cacheWritesPrice: 3.75, + cacheReadsPrice: 0.3, + } + // Prioritize serverside model info if (this.options.apiModelId && this.options.pearaiAgentModels) { let modelInfo = null @@ -236,7 +249,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa modelInfo = this.options.pearaiAgentModels.models[this.options.apiModelId || "pearai-model"] } if (modelInfo) { - return { + let result = { id: this.options.apiModelId, info: modelInfo, virtualId, @@ -246,15 +259,36 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa defaultMaxTokens: ANTHROPIC_DEFAULT_MAX_TOKENS, }), } + if (result.info.contextWindow === undefined) { + result.info = { + maxTokens: 8192, + contextWindow: 200_000, + supportsImages: true, + supportsComputerUse: true, + supportsPromptCache: true, + inputPrice: 3.0, + outputPrice: 15.0, + cacheWritesPrice: 3.75, + cacheReadsPrice: 0.3, + } + } + if (result.info.contextWindow === undefined) { + result.info = fallbackModelInfo + } + return result } } - return { + const result = { id, info, virtualId, // Include the original ID to use for header selection ...getModelParams({ options: this.options, model: info, defaultMaxTokens: ANTHROPIC_DEFAULT_MAX_TOKENS }), } + if (result.info.contextWindow === undefined) { + result.info = fallbackModelInfo + } + return result } async completePrompt(prompt: string) { From bfb8d46fd1bf0503840752af1d06d1133610f211 Mon Sep 17 00:00:00 2001 From: nang-dev Date: Mon, 21 Apr 2025 15:48:51 -0400 Subject: [PATCH 3/5] Reset anthropic --- src/api/providers/anthropic.ts | 38 ++-------------------------------- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/src/api/providers/anthropic.ts b/src/api/providers/anthropic.ts index e1a6925ab22..a1773d8c52b 100644 --- a/src/api/providers/anthropic.ts +++ b/src/api/providers/anthropic.ts @@ -227,19 +227,6 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa id = "claude-3-7-sonnet-20250219" } - // PATCH for issue with update - const fallbackModelInfo: ModelInfo = { - maxTokens: 8192, - contextWindow: 200_000, - supportsImages: true, - supportsComputerUse: true, - supportsPromptCache: true, - inputPrice: 3.0, - outputPrice: 15.0, - cacheWritesPrice: 3.75, - cacheReadsPrice: 0.3, - } - // Prioritize serverside model info if (this.options.apiModelId && this.options.pearaiAgentModels) { let modelInfo = null @@ -249,7 +236,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa modelInfo = this.options.pearaiAgentModels.models[this.options.apiModelId || "pearai-model"] } if (modelInfo) { - let result = { + return { id: this.options.apiModelId, info: modelInfo, virtualId, @@ -259,36 +246,15 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa defaultMaxTokens: ANTHROPIC_DEFAULT_MAX_TOKENS, }), } - if (result.info.contextWindow === undefined) { - result.info = { - maxTokens: 8192, - contextWindow: 200_000, - supportsImages: true, - supportsComputerUse: true, - supportsPromptCache: true, - inputPrice: 3.0, - outputPrice: 15.0, - cacheWritesPrice: 3.75, - cacheReadsPrice: 0.3, - } - } - if (result.info.contextWindow === undefined) { - result.info = fallbackModelInfo - } - return result } } - const result = { + return { id, info, virtualId, // Include the original ID to use for header selection ...getModelParams({ options: this.options, model: info, defaultMaxTokens: ANTHROPIC_DEFAULT_MAX_TOKENS }), } - if (result.info.contextWindow === undefined) { - result.info = fallbackModelInfo - } - return result } async completePrompt(prompt: string) { From 6876f5980adf76891780993a023b1c413bfa2f33 Mon Sep 17 00:00:00 2001 From: nang-dev Date: Mon, 21 Apr 2025 15:57:01 -0400 Subject: [PATCH 4/5] Fixed bug --- src/api/providers/pearai/pearai.ts | 1 + src/api/providers/pearai/pearaiGeneric.ts | 24 ++++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/api/providers/pearai/pearai.ts b/src/api/providers/pearai/pearai.ts index d180ac175f8..5ed332436e6 100644 --- a/src/api/providers/pearai/pearai.ts +++ b/src/api/providers/pearai/pearai.ts @@ -82,6 +82,7 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl apiModelId: underlyingModel, }) } else { + // Use OpenAI fields here as we are using the same handler structure as OpenAI Hander lin PearAIGenericHandler this.handler = new PearAIGenericHandler({ ...options, openAiBaseUrl: PEARAI_URL, diff --git a/src/api/providers/pearai/pearaiGeneric.ts b/src/api/providers/pearai/pearaiGeneric.ts index 96c401f9b71..15509de95b3 100644 --- a/src/api/providers/pearai/pearaiGeneric.ts +++ b/src/api/providers/pearai/pearaiGeneric.ts @@ -221,28 +221,30 @@ export class PearAIGenericHandler extends BaseProvider implements SingleCompleti } override getModel(): { id: string; info: ModelInfo } { - const modelId = this.options.openAiModelId ?? "none" + const modelId = this.options.openAiModelId // Prioritize serverside model info - if (this.options.apiModelId && this.options.pearaiAgentModels) { + if (modelId && this.options.pearaiAgentModels) { let modelInfo = null - if (this.options.apiModelId.startsWith("pearai")) { - modelInfo = this.options.pearaiAgentModels.models[this.options.apiModelId].underlyingModelUpdated + if (modelId.startsWith("pearai")) { + modelInfo = this.options.pearaiAgentModels.models[modelId].underlyingModelUpdated } else { - modelInfo = this.options.pearaiAgentModels.models[this.options.apiModelId || "pearai-model"] + modelInfo = this.options.pearaiAgentModels.models[modelId || "pearai-model"] } if (modelInfo) { - return { - id: this.options.apiModelId, + const result = { + id: modelId, info: modelInfo, } + return result } } - return { - id: modelId, - info: allModels[modelId], + + const result = { + id: modelId ?? pearAiDefaultModelId, + info: allModels[modelId ?? pearAiDefaultModelId], } + return result } - async completePrompt(prompt: string): Promise { try { const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming = { From 5829e96a62e4ed3ff5141cf4ed44ae44ccc9a66a Mon Sep 17 00:00:00 2001 From: nang-dev Date: Mon, 21 Apr 2025 15:58:34 -0400 Subject: [PATCH 5/5] Removed dupes --- src/core/webview/ClineProvider.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 7c19c7e2028..5ed045aaa47 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -500,15 +500,7 @@ export class ClineProvider extends EventEmitter implements const modePrompt = customModePrompts?.[mode] as PromptComponent const effectiveInstructions = [globalInstructions, modePrompt?.customInstructions].filter(Boolean).join("\n\n") - let pearaiAgentModels - - try { - pearaiAgentModels = await this.getPearAIAgentModels() - } catch (error) { - vscode.window.showErrorMessage( - "Failed to fetch PearAI Agent Models. PearAI services may be down, please contact PearAI Support.", - ) - } + const pearaiAgentModels = await this.getPearAIAgentModels() const cline = new Cline({ provider: this,