mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-30 01:08:33 +00:00
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>
20 lines
691 B
Python
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,
|
|
],
|
|
}
|