Skip to content

Commit 59fb604

Browse files
committed
Working
1 parent 654b62d commit 59fb604

File tree

3 files changed

+38
-21
lines changed

3 files changed

+38
-21
lines changed

src/api/providers/anthropic.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,28 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
227227
id = "claude-3-7-sonnet-20250219"
228228
}
229229

230+
// Prioritize serverside model info
231+
if (this.options.apiModelId && this.options.pearaiAgentModels) {
232+
let modelInfo = null
233+
if (this.options.apiModelId.startsWith("pearai")) {
234+
modelInfo = this.options.pearaiAgentModels.models[this.options.apiModelId].underlyingModelUpdated
235+
} else {
236+
modelInfo = this.options.pearaiAgentModels.models[this.options.apiModelId || "pearai-model"]
237+
}
238+
if (modelInfo) {
239+
return {
240+
id: this.options.apiModelId,
241+
info: modelInfo,
242+
virtualId,
243+
...getModelParams({
244+
options: this.options,
245+
model: info,
246+
defaultMaxTokens: ANTHROPIC_DEFAULT_MAX_TOKENS,
247+
}),
248+
}
249+
}
250+
}
251+
230252
return {
231253
id,
232254
info,

src/api/providers/pearai/pearai.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
7171
console.log("AMAZING")
7272
}
7373
const pearaiAgentModels = options.pearaiAgentModels
74-
this.pearAIAgentModels = pearaiAgentModels
7574
const underlyingModel =
7675
pearaiAgentModels.models[modelId]?.underlyingModelUpdated?.underlyingModel ||
7776
pearaiAgentModels.models[modelId]?.underlyingModel ||
@@ -118,26 +117,7 @@ export class PearAiHandler extends BaseProvider implements SingleCompletionHandl
118117
}
119118
}
120119

121-
getModel(): { id: string; info: ModelInfo } {
122-
if (this.options.apiModelId) {
123-
let modelInfo = null
124-
if (this.options.apiModelId.startsWith("pearai")) {
125-
modelInfo = this.pearAIAgentModels?.models[this.options.apiModelId].underlyingModelUpdated
126-
} else if (this.pearAIAgentModels) {
127-
modelInfo = this.pearAIAgentModels.models[this.options.apiModelId || "pearai-model"]
128-
}
129-
if (modelInfo) {
130-
return {
131-
id: this.options.apiModelId,
132-
info: {
133-
contextWindow: modelInfo.contextWindow || 4096, // provide default or actual value
134-
supportsPromptCache: modelInfo.supportsPromptCaching || false, // provide default or actual value
135-
...modelInfo,
136-
},
137-
}
138-
}
139-
}
140-
120+
public getModel(): { id: string; info: ModelInfo } {
141121
// Fallback to using what's available on client side
142122
const baseModel = this.handler.getModel()
143123
return baseModel

src/api/providers/pearai/pearaiGeneric.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,21 @@ export class PearAIGenericHandler extends BaseProvider implements SingleCompleti
222222

223223
override getModel(): { id: string; info: ModelInfo } {
224224
const modelId = this.options.openAiModelId ?? "none"
225+
// Prioritize serverside model info
226+
if (this.options.apiModelId && this.options.pearaiAgentModels) {
227+
let modelInfo = null
228+
if (this.options.apiModelId.startsWith("pearai")) {
229+
modelInfo = this.options.pearaiAgentModels.models[this.options.apiModelId].underlyingModelUpdated
230+
} else {
231+
modelInfo = this.options.pearaiAgentModels.models[this.options.apiModelId || "pearai-model"]
232+
}
233+
if (modelInfo) {
234+
return {
235+
id: this.options.apiModelId,
236+
info: modelInfo,
237+
}
238+
}
239+
}
225240
return {
226241
id: modelId,
227242
info: allModels[modelId],

0 commit comments

Comments
 (0)