Skip to content
Closed
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
26 changes: 24 additions & 2 deletions src/api/providers/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -246,15 +259,24 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
defaultMaxTokens: ANTHROPIC_DEFAULT_MAX_TOKENS,
}),
}
// If model info is missing or has undefined context window, use fallback
if (!result.info || !result.info.contextWindow) {
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 || !result.info.contextWindow) {
result.info = fallbackModelInfo
}
return result
}

async completePrompt(prompt: string) {
Expand Down
29 changes: 27 additions & 2 deletions src/api/providers/pearai/pearaiGeneric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ export class PearAIGenericHandler extends BaseProvider implements SingleCompleti

override getModel(): { id: string; info: ModelInfo } {
const modelId = this.options.openAiModelId ?? "none"

// 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
Expand All @@ -231,16 +245,27 @@ export class PearAIGenericHandler extends BaseProvider implements SingleCompleti
modelInfo = this.options.pearaiAgentModels.models[this.options.apiModelId || "pearai-model"]
}
if (modelInfo) {
return {
const result = {
id: this.options.apiModelId,
info: modelInfo,
}
// If model info is missing or has undefined context window, use fallback
if (!result.info || !result.info.contextWindow) {
result.info = fallbackModelInfo
}
return result
}
}
return {

const result = {
id: modelId,
info: allModels[modelId],
}
// If model info is missing or has undefined context window, use fallback
if (!result.info || !result.info.contextWindow) {
result.info = fallbackModelInfo
}
return result
}

async completePrompt(prompt: string): Promise<string> {
Expand Down
29 changes: 22 additions & 7 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,19 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> 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[]) {
Expand All @@ -493,7 +500,15 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> 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,
Expand Down Expand Up @@ -655,7 +670,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
<script nonce="${nonce}">
window.IMAGES_BASE_URI = "${imagesUri}"
</script>
<title>Roo Code</title>
<title>Agent</title>
</head>
<body>
<div id="root"></div>
Expand Down
2 changes: 1 addition & 1 deletion src/integrations/editor/DiffViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
Loading