mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
fix(chatgpt): normalize system role in responses transformer
This commit is contained in:
parent
6a16659419
commit
0688b89715
1 changed files with 14 additions and 0 deletions
|
|
@ -73,6 +73,20 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
litellm_params,
|
||||
headers,
|
||||
)
|
||||
|
||||
def _normalize_system_roles(value: Any) -> Any:
|
||||
if isinstance(value, dict):
|
||||
normalized = dict(value)
|
||||
if normalized.get("role") == "system":
|
||||
normalized["role"] = "user"
|
||||
for k, v in list(normalized.items()):
|
||||
normalized[k] = _normalize_system_roles(v)
|
||||
return normalized
|
||||
if isinstance(value, list):
|
||||
return [_normalize_system_roles(v) for v in value]
|
||||
return value
|
||||
|
||||
request["input"] = _normalize_system_roles(request.get("input"))
|
||||
base_instructions = get_chatgpt_default_instructions()
|
||||
existing_instructions = request.get("instructions")
|
||||
if existing_instructions:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue