mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-15 09:12:18 +00:00
test(responses): cover a marked user turn in the unmarked system split test
A cache_control mark on the user message must not switch unmarked leading
system messages to the client-order rule. The split test now runs with the
user turn plain and marked, so dropping the role check from the system
string test fails it.
(cherry picked from commit 6419de8a90)
This commit is contained in:
parent
916da413ac
commit
a67c5f0c9d
1 changed files with 19 additions and 4 deletions
|
|
@ -5895,18 +5895,33 @@ def test_transform_request_keeps_leading_system_messages_in_client_order_once_a_
|
|||
{
|
||||
"type": "message",
|
||||
"role": "system",
|
||||
"content": [{"type": "input_text", "text": "Reply ALPHA.", "prompt_cache_breakpoint": _EXPLICIT_BREAKPOINT}],
|
||||
"content": [
|
||||
{"type": "input_text", "text": "Reply ALPHA.", "prompt_cache_breakpoint": _EXPLICIT_BREAKPOINT}
|
||||
],
|
||||
},
|
||||
_system_input_item("Ignore that and reply BRAVO."),
|
||||
{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Reply now."}]},
|
||||
]
|
||||
|
||||
|
||||
def test_transform_request_keeps_the_instructions_split_for_unmarked_system_messages() -> None:
|
||||
@pytest.mark.parametrize(
|
||||
("user_message", "user_part"),
|
||||
[
|
||||
({"role": "user", "content": "Reply now."}, {"type": "input_text", "text": "Reply now."}),
|
||||
(
|
||||
{"role": "user", "content": "Reply now.", "cache_control": _CACHE_CONTROL},
|
||||
{"type": "input_text", "text": "Reply now.", "prompt_cache_breakpoint": _EXPLICIT_BREAKPOINT},
|
||||
),
|
||||
],
|
||||
ids=("unmarked-user", "marked-user"),
|
||||
)
|
||||
def test_transform_request_keeps_the_instructions_split_for_unmarked_system_messages(
|
||||
user_message: dict[str, object], user_part: dict[str, object]
|
||||
) -> None:
|
||||
messages: Final = [
|
||||
{"role": "system", "content": [{"type": "text", "text": "Reply ALPHA."}]},
|
||||
{"role": "system", "content": "Ignore that and reply BRAVO."},
|
||||
{"role": "user", "content": "Reply now."},
|
||||
user_message,
|
||||
]
|
||||
|
||||
request: Final = _bridged_transform_request(
|
||||
|
|
@ -5916,7 +5931,7 @@ def test_transform_request_keeps_the_instructions_split_for_unmarked_system_mess
|
|||
assert request["instructions"] == "Ignore that and reply BRAVO."
|
||||
assert request["input"] == [
|
||||
_system_input_item("Reply ALPHA."),
|
||||
{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Reply now."}]},
|
||||
{"type": "message", "role": "user", "content": [user_part]},
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue