litellm/tests/integration/_support/responses_prompt.py
devin-ai-integration[bot] 897ebd3cc3
test(responses): centralize exact system prompt placement expectations (#53000)
Co-authored-by: mateo <277851410+mateo-berri@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-20 01:58:07 +00:00

20 lines
691 B
Python

from collections.abc import Mapping
from typing import Final, Literal
from pydantic import JsonValue
def with_leading_system_message(
request: Mapping[str, JsonValue], *, role: Literal["system", "developer"] = "system"
) -> dict[str, JsonValue]:
instructions: Final = request["instructions"]
items: Final = request["input"]
assert isinstance(instructions, str), request
assert isinstance(items, list), request
return {
**{key: value for key, value in request.items() if key != "instructions"},
"input": [
{"type": "message", "role": role, "content": [{"type": "input_text", "text": instructions}]},
*items,
],
}