fix: prompt caching for opus on bedrock (#11664)
This commit is contained in:
@@ -179,7 +179,7 @@ export namespace ProviderTransform {
|
|||||||
cacheControl: { type: "ephemeral" },
|
cacheControl: { type: "ephemeral" },
|
||||||
},
|
},
|
||||||
bedrock: {
|
bedrock: {
|
||||||
cachePoint: { type: "ephemeral" },
|
cachePoint: { type: "default" },
|
||||||
},
|
},
|
||||||
openaiCompatible: {
|
openaiCompatible: {
|
||||||
cache_control: { type: "ephemeral" },
|
cache_control: { type: "ephemeral" },
|
||||||
@@ -190,7 +190,8 @@ export namespace ProviderTransform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const msg of unique([...system, ...final])) {
|
for (const msg of unique([...system, ...final])) {
|
||||||
const shouldUseContentOptions = providerID !== "anthropic" && Array.isArray(msg.content) && msg.content.length > 0
|
const useMessageLevelOptions = providerID === "anthropic" || providerID.includes("bedrock")
|
||||||
|
const shouldUseContentOptions = !useMessageLevelOptions && Array.isArray(msg.content) && msg.content.length > 0
|
||||||
|
|
||||||
if (shouldUseContentOptions) {
|
if (shouldUseContentOptions) {
|
||||||
const lastContent = msg.content[msg.content.length - 1]
|
const lastContent = msg.content[msg.content.length - 1]
|
||||||
|
|||||||
@@ -1166,7 +1166,7 @@ describe("ProviderTransform.message - claude w/bedrock custom inference profile"
|
|||||||
expect(result[0].providerOptions?.bedrock).toEqual(
|
expect(result[0].providerOptions?.bedrock).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
cachePoint: {
|
cachePoint: {
|
||||||
type: "ephemeral",
|
type: "default",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user