mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
fix(param-support): handle strip rules without match/drop
Cloudflare AI rule only sets flattenContent. Treat missing match as provider-wide and missing drop as empty list to avoid crash. Fixes #1960. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Cursor
parent
639f1204d0
commit
4a54824f7f
@@ -0,0 +1,31 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
|
||||
import { stripUnsupportedParams } from "../../open-sse/translator/concerns/paramSupport.js";
|
||||
|
||||
describe("stripUnsupportedParams", () => {
|
||||
it("flattens Cloudflare AI OpenAI content-part arrays", () => {
|
||||
const body = {
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: [
|
||||
{ type: "text", text: "hello " },
|
||||
{ type: "image_url", image_url: { url: "data:image/png;base64,xx" } },
|
||||
{ type: "text", text: "world" },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(() => stripUnsupportedParams("cloudflare-ai", "@cf/meta/llama-3.1-8b-instruct", body)).not.toThrow();
|
||||
expect(body.messages[0].content).toBe("hello world");
|
||||
});
|
||||
|
||||
it("still drops unsupported GitHub model params", () => {
|
||||
const body = { temperature: 0.7, top_p: 1 };
|
||||
|
||||
stripUnsupportedParams("github", "gpt-5.4", body);
|
||||
|
||||
expect(body).toEqual({ top_p: 1 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user