fix: adjust azure defaults to closer match openai to prevent Item .. of type 'reasoning' was provided without its required following item (#25007)
This commit is contained in:
@@ -1466,10 +1466,13 @@ const layer: Layer.Layer<
|
|||||||
if (combined) opts.signal = combined
|
if (combined) opts.signal = combined
|
||||||
|
|
||||||
// Strip openai itemId metadata following what codex does
|
// Strip openai itemId metadata following what codex does
|
||||||
if (model.api.npm === "@ai-sdk/openai" && opts.body && opts.method === "POST") {
|
if (
|
||||||
|
(model.api.npm === "@ai-sdk/openai" || model.api.npm === "@ai-sdk/azure") &&
|
||||||
|
opts.body &&
|
||||||
|
opts.method === "POST"
|
||||||
|
) {
|
||||||
const body = JSON.parse(opts.body as string)
|
const body = JSON.parse(opts.body as string)
|
||||||
const isAzure = model.providerID.includes("azure")
|
const keepIds = body.store === true
|
||||||
const keepIds = isAzure && body.store === true
|
|
||||||
if (!keepIds && Array.isArray(body.input)) {
|
if (!keepIds && Array.isArray(body.input)) {
|
||||||
for (const item of body.input) {
|
for (const item of body.input) {
|
||||||
if ("id" in item) {
|
if ("id" in item) {
|
||||||
|
|||||||
@@ -866,7 +866,7 @@ export function options(input: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (input.model.api.npm === "@ai-sdk/azure") {
|
if (input.model.api.npm === "@ai-sdk/azure") {
|
||||||
result["store"] = true
|
result["store"] = false
|
||||||
result["promptCacheKey"] = input.sessionID
|
result["promptCacheKey"] = input.sessionID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ describe("ProviderTransform.options - setCacheKey", () => {
|
|||||||
expect(result.store).toBe(false)
|
expect(result.store).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("should set store=true for azure provider by default", () => {
|
test("should set store=false for azure provider by default", () => {
|
||||||
const azureModel = {
|
const azureModel = {
|
||||||
...mockModel,
|
...mockModel,
|
||||||
providerID: "azure",
|
providerID: "azure",
|
||||||
@@ -116,7 +116,7 @@ describe("ProviderTransform.options - setCacheKey", () => {
|
|||||||
sessionID,
|
sessionID,
|
||||||
providerOptions: {},
|
providerOptions: {},
|
||||||
})
|
})
|
||||||
expect(result.store).toBe(true)
|
expect(result.store).toBe(false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user