Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit d8bf3fc

Browse files
committed
refactor: remove unnecessary as-any casts for cachableFields (already in ModelInfo type)
1 parent 64055fc commit d8bf3fc

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

src/api/providers/__tests__/bedrock.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,10 +1416,10 @@ describe("AwsBedrockHandler", () => {
14161416

14171417
const modelConfig = customArnHandler.getModel()
14181418
expect(modelConfig.info.supportsPromptCache).toBe(true)
1419-
expect((modelConfig.info as any).cachableFields).toBeDefined()
1420-
expect((modelConfig.info as any).cachableFields).toContain("system")
1421-
expect((modelConfig.info as any).cachableFields).toContain("messages")
1422-
expect((modelConfig.info as any).cachableFields).toContain("tools")
1419+
expect(modelConfig.info.cachableFields).toBeDefined()
1420+
expect(modelConfig.info.cachableFields).toContain("system")
1421+
expect(modelConfig.info.cachableFields).toContain("messages")
1422+
expect(modelConfig.info.cachableFields).toContain("tools")
14231423
})
14241424
})
14251425
})

src/api/providers/bedrock.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,10 +1176,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
11761176

11771177
private supportsAwsPromptCache(modelConfig: { id: BedrockModelId | string; info: ModelInfo }): boolean | undefined {
11781178
// Check if the model supports prompt cache
1179-
// The cachableFields property is not part of the ModelInfo type in schemas
1180-
// but it's used in the bedrockModels object in shared/api.ts
1181-
const hasCachableFields =
1182-
(modelConfig?.info as any)?.cachableFields && (modelConfig?.info as any)?.cachableFields?.length > 0
1179+
const hasCachableFields = modelConfig?.info?.cachableFields && modelConfig.info.cachableFields.length > 0
11831180

11841181
if (modelConfig?.info?.supportsPromptCache && hasCachableFields) {
11851182
return true
@@ -1194,7 +1191,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
11941191
// simply ignores cache points without erroring.
11951192
if (this.options.awsCustomArn && this.options.awsUsePromptCache !== false) {
11961193
if (!hasCachableFields) {
1197-
;(modelConfig.info as any).cachableFields = ["system", "messages", "tools"]
1194+
modelConfig.info.cachableFields = ["system", "messages", "tools"]
11981195
}
11991196
modelConfig.info.supportsPromptCache = true
12001197
return true

0 commit comments

Comments
 (0)