@@ -222,6 +222,20 @@ export class PearAIGenericHandler extends BaseProvider implements SingleCompleti
222222
223223 override getModel ( ) : { id : string ; info : ModelInfo } {
224224 const modelId = this . options . openAiModelId ?? "none"
225+
226+ // PATCH for issue with update
227+ const fallbackModelInfo : ModelInfo = {
228+ maxTokens : 8192 ,
229+ contextWindow : 200_000 ,
230+ supportsImages : true ,
231+ supportsComputerUse : true ,
232+ supportsPromptCache : true ,
233+ inputPrice : 3.0 ,
234+ outputPrice : 15.0 ,
235+ cacheWritesPrice : 3.75 ,
236+ cacheReadsPrice : 0.3 ,
237+ }
238+
225239 // Prioritize serverside model info
226240 if ( this . options . apiModelId && this . options . pearaiAgentModels ) {
227241 let modelInfo = null
@@ -231,16 +245,27 @@ export class PearAIGenericHandler extends BaseProvider implements SingleCompleti
231245 modelInfo = this . options . pearaiAgentModels . models [ this . options . apiModelId || "pearai-model" ]
232246 }
233247 if ( modelInfo ) {
234- return {
248+ const result = {
235249 id : this . options . apiModelId ,
236250 info : modelInfo ,
237251 }
252+ // If model info is missing or has undefined context window, use fallback
253+ if ( ! result . info || ! result . info . contextWindow ) {
254+ result . info = fallbackModelInfo
255+ }
256+ return result
238257 }
239258 }
240- return {
259+
260+ const result = {
241261 id : modelId ,
242262 info : allModels [ modelId ] ,
243263 }
264+ // If model info is missing or has undefined context window, use fallback
265+ if ( ! result . info || ! result . info . contextWindow ) {
266+ result . info = fallbackModelInfo
267+ }
268+ return result
244269 }
245270
246271 async completePrompt ( prompt : string ) : Promise < string > {
0 commit comments