95 lines
7.5 KiB
JSON
95 lines
7.5 KiB
JSON
[
|
|
{ "name": "legacy keys are set as they are",
|
|
"options": { "temperature": 0.2, "max_tokens": 8000 },
|
|
"request": { "model": "m", "max_tokens": 64000, "messages": [] },
|
|
"expect_request": { "model": "m", "max_tokens": 8000, "messages": [], "temperature": 0.2 } },
|
|
{ "name": "nothing to do leaves the body",
|
|
"options": { "operations": [{ "path": "temperature", "mode": "delete" }] },
|
|
"request": { "model": "m", "messages": [] } },
|
|
{ "name": "a cap: set only when over",
|
|
"options": { "operations": [{ "path": "max_tokens", "mode": "set", "value": 32000, "conditions": [{ "path": "max_tokens", "mode": "gt", "value": 32000 }] }] },
|
|
"request": { "model": "m", "max_tokens": 64000 },
|
|
"expect_request": { "model": "m", "max_tokens": 32000 } },
|
|
{ "name": "a cap under the limit stays",
|
|
"options": { "operations": [{ "path": "max_tokens", "mode": "set", "value": 32000, "conditions": [{ "path": "max_tokens", "mode": "gt", "value": 32000 }] }] },
|
|
"request": { "model": "m", "max_tokens": 4000 } },
|
|
{ "name": "keep_origin fills only what is missing",
|
|
"options": { "operations": [{ "path": "metadata.user_id", "mode": "set", "value": "me", "keep_origin": true }, { "path": "top_p", "mode": "set", "value": 0.9, "keep_origin": true }] },
|
|
"request": { "model": "m", "top_p": 0.5 },
|
|
"expect_request": { "model": "m", "top_p": 0.5, "metadata": { "user_id": "me" } } },
|
|
{ "name": "conditions on the request: model prefix, protocol, AND",
|
|
"ctx": { "protocol": "chat", "model": "deepseek-reasoner" },
|
|
"options": { "operations": [{ "path": "temperature", "mode": "delete", "logic": "AND", "conditions": [{ "path": "model", "mode": "prefix", "value": "deepseek-r" }, { "path": "protocol", "mode": "full", "value": "chat" }] }] },
|
|
"request": { "model": "deepseek-reasoner", "temperature": 1, "messages": [] },
|
|
"expect_request": { "model": "deepseek-reasoner", "messages": [] } },
|
|
{ "name": "AND with one false does nothing; invert",
|
|
"ctx": { "protocol": "anthropic" },
|
|
"options": { "operations": [
|
|
{ "path": "temperature", "mode": "delete", "logic": "AND", "conditions": [{ "path": "model", "mode": "prefix", "value": "m" }, { "path": "protocol", "mode": "full", "value": "chat" }] },
|
|
{ "path": "x", "mode": "set", "value": 1, "conditions": [{ "path": "protocol", "mode": "full", "value": "chat", "invert": true }] }] },
|
|
"request": { "model": "m", "temperature": 1 },
|
|
"expect_request": { "model": "m", "temperature": 1, "x": 1 } },
|
|
{ "name": "a missing key fails a condition unless pass_missing_key",
|
|
"options": { "operations": [
|
|
{ "path": "a", "mode": "set", "value": 1, "conditions": [{ "path": "nope", "mode": "full", "value": 1 }] },
|
|
{ "path": "b", "mode": "set", "value": 2, "conditions": [{ "path": "nope", "mode": "full", "value": 1, "pass_missing_key": true }] }] },
|
|
"request": { "model": "m" },
|
|
"expect_request": { "model": "m", "b": 2 } },
|
|
{ "name": "return_error turns the request away",
|
|
"options": { "operations": [{ "mode": "return_error", "value": { "message": "opus is not allowed here", "status_code": 403 }, "conditions": [{ "path": "model", "mode": "contains", "value": "opus" }] }] },
|
|
"request": { "model": "claude-opus-4-5" },
|
|
"reject": { "status": 403, "message": "opus is not allowed" } },
|
|
{ "name": "return_error as a string is a 400",
|
|
"options": { "operations": [{ "mode": "return_error", "value": "no" }] },
|
|
"request": { "model": "m" },
|
|
"reject": { "status": 400, "message": "no" } },
|
|
{ "name": "move and copy",
|
|
"options": { "operations": [{ "mode": "move", "from": "max_completion_tokens", "to": "max_tokens" }, { "mode": "copy", "from": "metadata.user_id", "to": "user" }] },
|
|
"request": { "model": "m", "max_completion_tokens": 100, "metadata": { "user_id": "u1" } },
|
|
"expect_request": { "model": "m", "max_tokens": 100, "metadata": { "user_id": "u1" }, "user": "u1" } },
|
|
{ "name": "prepend to a string system, append to an array, merge an object",
|
|
"options": { "operations": [
|
|
{ "path": "system", "mode": "prepend", "value": "Be brief.\n" },
|
|
{ "path": "stop", "mode": "append", "value": ["END"] },
|
|
{ "path": "metadata", "mode": "append", "value": { "a": 1, "b": 2 }, "keep_origin": true }] },
|
|
"request": { "model": "m", "system": "You code.", "stop": ["\n\n"], "metadata": { "a": 0 } },
|
|
"expect_request": { "model": "m", "system": "Be brief.\nYou code.", "stop": ["\n\n", "END"], "metadata": { "a": 0, "b": 2 } } },
|
|
{ "name": "prepend a block to an array system",
|
|
"options": { "operations": [{ "path": "system", "mode": "prepend", "value": { "type": "text", "text": "Be brief." } }] },
|
|
"request": { "model": "m", "system": [{ "type": "text", "text": "You code." }] },
|
|
"expect_request": { "model": "m", "system": [{ "type": "text", "text": "Be brief." }, { "type": "text", "text": "You code." }] } },
|
|
{ "name": "string modes",
|
|
"options": { "operations": [
|
|
{ "path": "model", "mode": "trim_prefix", "value": "openai/" },
|
|
{ "path": "a", "mode": "ensure_suffix", "value": "!" },
|
|
{ "path": "b", "mode": "trim_space" },
|
|
{ "path": "c", "mode": "to_upper" },
|
|
{ "path": "d", "mode": "replace", "from": "x", "to": "y" },
|
|
{ "path": "e", "mode": "regex_replace", "from": "(?i)^CLAUDE-(\\d)", "to": "c${1}" }] },
|
|
"request": { "model": "openai/gpt-5", "a": "hi", "b": " sp ", "c": "up", "d": "xax", "e": "claude-4-sonnet" },
|
|
"expect_request": { "model": "gpt-5", "a": "hi!", "b": "sp", "c": "UP", "d": "yay", "e": "c4-sonnet" } },
|
|
{ "name": "wildcards and negative indexes",
|
|
"options": { "operations": [
|
|
{ "path": "tools.*.input_examples", "mode": "delete" },
|
|
{ "path": "messages.-1.content", "mode": "append", "value": " (be brief)" }] },
|
|
"request": { "model": "m", "tools": [{ "name": "a", "input_examples": [1] }, { "name": "b" }, { "name": "c", "input_examples": [] }], "messages": [{ "role": "user", "content": "one" }, { "role": "user", "content": "two" }] },
|
|
"expect_request": { "model": "m", "tools": [{ "name": "a" }, { "name": "b" }, { "name": "c" }], "messages": [{ "role": "user", "content": "one" }, { "role": "user", "content": "two (be brief)" }] } },
|
|
{ "name": "delete over a wildcard of array items",
|
|
"options": { "operations": [{ "path": "messages.*", "mode": "delete", "conditions": [{ "path": "model", "mode": "full", "value": "m" }] }] },
|
|
"request": { "model": "m", "messages": [1, 2, 3] },
|
|
"expect_request": { "model": "m", "messages": [] } },
|
|
{ "name": "prune_objects by type, and with where",
|
|
"options": { "operations": [
|
|
{ "path": "messages", "mode": "prune_objects", "value": "thinking" },
|
|
{ "path": "tools", "mode": "prune_objects", "value": { "where": { "name": "WebSearch" } } }] },
|
|
"request": { "model": "m", "messages": [{ "role": "assistant", "content": [{ "type": "thinking", "thinking": "x" }, { "type": "text", "text": "hi" }] }], "tools": [{ "name": "WebSearch" }, { "name": "Read" }] },
|
|
"expect_request": { "model": "m", "messages": [{ "role": "assistant", "content": [{ "type": "text", "text": "hi" }] }], "tools": [{ "name": "Read" }] } },
|
|
{ "name": "header modes have nothing to act on",
|
|
"options": { "operations": [{ "mode": "set_header", "path": "X-A", "value": "1" }] },
|
|
"request": { "model": "m" } },
|
|
{ "name": "replies pass untouched",
|
|
"options": { "temperature": 0 },
|
|
"events": [{ "event": "message_start", "data": { "type": "message_start", "message": { "model": "m" } } }, { "data": "[DONE]" }],
|
|
"response": { "id": "x", "model": "m" } }
|
|
]
|