Skip to content

Commit 4d8dc14

Browse files
committed
revise caching duration and maxTokens
1 parent 3e12dd3 commit 4d8dc14

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/types/src/providers/io-intelligence.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export const ioIntelligenceDefaultModelId: IOIntelligenceModelId = "meta-llama/L
1010

1111
export const ioIntelligenceDefaultBaseUrl = "https://api.intelligence.io.solutions/api/v1"
1212

13+
export const IO_INTELLIGENCE_CACHE_DURATION = 1000 * 60 * 60 // 1 hour
14+
1315
export const ioIntelligenceModels = {
1416
"deepseek-ai/DeepSeek-R1-0528": {
1517
maxTokens: 8192,

src/api/providers/fetchers/io-intelligence.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import axios from "axios"
22
import { z } from "zod"
33
import type { ModelInfo } from "@roo-code/types"
4+
import { IO_INTELLIGENCE_CACHE_DURATION } from "@roo-code/types"
45
import type { ModelRecord } from "../../../shared/api"
56

67
/**
@@ -53,7 +54,6 @@ interface CacheEntry {
5354
}
5455

5556
let cache: CacheEntry | null = null
56-
const CACHE_DURATION = 5 * 60 * 1000 // 5 minutes
5757

5858
/**
5959
* Model context length mapping based on the documentation
@@ -80,7 +80,8 @@ const VISION_MODELS = new Set([
8080
*/
8181
function parseIOIntelligenceModel(model: IOIntelligenceModel): ModelInfo {
8282
const contextLength = MODEL_CONTEXT_LENGTHS[model.id] || 8192
83-
const maxTokens = Math.min(contextLength, Math.ceil(contextLength * 0.2))
83+
// Cap maxTokens at 32k for very large context windows, or 20% of context length, whichever is smaller
84+
const maxTokens = Math.min(contextLength, Math.ceil(contextLength * 0.2), 32768)
8485
const supportsImages = VISION_MODELS.has(model.id)
8586

8687
return {
@@ -101,7 +102,7 @@ export async function getIOIntelligenceModels(apiKey?: string): Promise<ModelRec
101102
const now = Date.now()
102103

103104
// Check cache
104-
if (cache && now - cache.timestamp < CACHE_DURATION) {
105+
if (cache && now - cache.timestamp < IO_INTELLIGENCE_CACHE_DURATION) {
105106
return cache.data
106107
}
107108

0 commit comments

Comments
 (0)