Skip to content

Commit 447f6cb

Browse files
authored
fix: adding default modelId and setting cache ttl to 30 minutes (#2161)
* fix: adding defaultmodelId and setting cache ttl to 30 minutes * fix: fixing tests * fix: updating comments
1 parent 18111b0 commit 447f6cb

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3196,7 +3196,7 @@ ${' '.repeat(8)}}
31963196
const result = await chatController.onListAvailableModels({ tabId: 'invalid-tab' })
31973197

31983198
assert.strictEqual(result.tabId, 'invalid-tab')
3199-
assert.strictEqual(result.selectedModelId, DEFAULT_MODEL_ID)
3199+
assert.strictEqual(result.selectedModelId, 'model1')
32003200

32013201
getSessionStub.restore()
32023202
})

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ export class AgenticChatController implements ChatHandlers {
714714
})
715715

716716
// Wait for the response to be completed before proceeding
717-
this.#log('Model Response', responseResult.toString())
717+
this.#log('Model Response: ', JSON.stringify(responseResult, null, 2))
718718
models = Object.values(responseResult.models).map(({ modelId, modelName }) => ({
719719
id: modelId,
720720
name: modelName ?? modelId,
@@ -755,7 +755,7 @@ export class AgenticChatController implements ChatHandlers {
755755

756756
// Get the first fallback model option as default
757757
const defaultModelOption = FALLBACK_MODEL_OPTIONS[1]
758-
const DEFAULT_MODEL_ID = defaultModelOption?.id || Object.keys(FALLBACK_MODEL_RECORD)[1]
758+
const DEFAULT_MODEL_ID = defaultModelId || defaultModelOption?.id
759759

760760
const sessionResult = this.#chatSessionManagementService.getSession(params.tabId)
761761
const { data: session, success } = sessionResult
@@ -769,7 +769,7 @@ export class AgenticChatController implements ChatHandlers {
769769
}
770770
}
771771

772-
// Determine which model ID to select based on priority.
772+
// Determine selected model ID based on priority
773773
let selectedModelId: string
774774
let modelId = this.#chatHistoryDb.getModelId()
775775

server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/chatDb/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export type MessagesWithCharacterCount = {
138138
export function isCachedValid(timestamp: number): boolean {
139139
const currentTime = Date.now()
140140
const cacheAge = currentTime - timestamp
141-
const CACHE_TTL = 5 * 60 * 1000 // 5 minutes in milliseconds
141+
const CACHE_TTL = 30 * 60 * 1000 // 30 minutes in milliseconds
142142

143143
return cacheAge < CACHE_TTL
144144
}

0 commit comments

Comments
 (0)