Reject model IDs unsafe for headers and clarify supported capabilities
This commit is contained in:
parent
ec9a2b173a
commit
7754377b3e
1 changed files with 22 additions and 5 deletions
|
|
@ -58,6 +58,20 @@ test("skips unusable entries but rejects malformed or entirely unusable catalogs
|
|||
}
|
||||
});
|
||||
|
||||
test("catalog IDs must fit Fetch's Latin-1 header values", () => {
|
||||
const valid = ["gpt-4o", "model-\u00ff"];
|
||||
const invalid = ["model-\u0100", "model-\u{1f600}", "model-\ud800"];
|
||||
const parsed = parseCatalog({ data: [...valid, ...invalid].map((id) => ({ id })) });
|
||||
assert.deepEqual(parsed, { ids: valid, skipped: invalid.length });
|
||||
for (const id of parsed.ids) {
|
||||
const headers = new Headers(makeModel(id, BASE_URL).headers);
|
||||
assert.equal(headers.get("deployment-id"), id);
|
||||
}
|
||||
for (const id of invalid) {
|
||||
assert.throws(() => parseCatalog({ data: [{ id }] }), /without any valid model IDs/);
|
||||
}
|
||||
});
|
||||
|
||||
const known: Record<string, ModelMetadata> = {
|
||||
"model-a": { name: "Model A", input: ["text", "image"], contextWindow: 272_000, maxTokens: 128_000 },
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue