Skip to content

Commit b68a005

Browse files
minor tweaks for simplicity
1 parent bbd5b6b commit b68a005

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/api/providers/bedrock.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,8 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
497497
previousCachePointPlacements: previousPlacements,
498498
}
499499

500-
// Inline the logic from convertWithOptimalCaching and CacheStrategyFactory.createStrategy
501-
let strategy = new MultiPointStrategy(config)
502-
503500
// Determine optimal cache points
501+
let strategy = new MultiPointStrategy(config)
504502
const result = strategy.determineOptimalCachePoints()
505503

506504
// Store cache point placements for future use if conversation ID is provided
@@ -626,18 +624,24 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
626624
//Prompt Router responses come back in a different sequence and the model used is in the response and must be fetched by name
627625
getModelById(modelId: string, modelType?: string): { id: BedrockModelId | string; info: SharedModelInfo } {
628626
// Try to find the model in bedrockModels
629-
let baseModelId = this.parseBaseModelId(modelId)
630-
const id = baseModelId as BedrockModelId
627+
const baseModelId = this.parseBaseModelId(modelId) as BedrockModelId
628+
631629
let model
632630
if (baseModelId in bedrockModels) {
633631
//Do a deep copy of the model info so that later in the code the model id and maxTokens can be set.
634632
// The bedrockModels array is a constant and updating the model ID from the returned invokedModelID value
635633
// in a prompt router response isn't possible on the constant.
636-
model = { id: id, info: JSON.parse(JSON.stringify(bedrockModels[id])) }
634+
model = { id: baseModelId, info: JSON.parse(JSON.stringify(bedrockModels[baseModelId])) }
637635
} else if (modelType && modelType.includes("router")) {
638-
model = this.getModelById(bedrockDefaultPromptRouterModelId as string)
636+
model = {
637+
id: bedrockDefaultPromptRouterModelId,
638+
info: JSON.parse(JSON.stringify(bedrockModels[bedrockDefaultPromptRouterModelId])),
639+
}
639640
} else {
640-
model = this.getModelById(bedrockDefaultModelId as string)
641+
model = {
642+
id: bedrockDefaultModelId,
643+
info: JSON.parse(JSON.stringify(bedrockModels[bedrockDefaultModelId])),
644+
}
641645
}
642646

643647
// If modelMaxTokens is explicitly set in options, override the default

0 commit comments

Comments
 (0)