Complete o3 model support (#8183)

* fix(o_series_transformation.py): add 'reasoning_effort' as o series model param

Closes https://github.com/BerriAI/litellm/issues/8182

* fix(main.py): ensure `reasoning_effort` is a mapped openai param

* refactor(azure/): rename o1_[x] files to o_series_[x]

* refactor(base_llm_unit_tests.py): refactor testing for o series reasoning effort

* test(test_azure_o_series.py): have azure o series tests correctly inherit from base o series model tests

* feat(base_utils.py): support translating 'developer' role to 'system' role for non-openai providers

Makes it easy to switch from openai to anthropic

* fix: fix linting errors

* fix(base_llm_unit_tests.py): fix test

* fix(main.py): add missing param
This commit is contained in:
Krish Dholakia 2025-02-02 22:36:37 -08:00 committed by GitHub
parent e4566d7b1c
commit 1105e35538
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 230 additions and 11 deletions

View file

@ -1,3 +1,7 @@
"""
Utility functions for base LLM classes.
"""
import copy
from abc import ABC, abstractmethod
from typing import List, Optional, Type, Union
@ -5,6 +9,7 @@ from typing import List, Optional, Type, Union
from openai.lib import _parsing, _pydantic
from pydantic import BaseModel
from litellm.types.llms.openai import AllMessageValues
from litellm.types.utils import ProviderSpecificModelInfo
@ -105,3 +110,18 @@ def type_to_response_format_param(
"strict": True,
},
}
def map_developer_role_to_system_role(
messages: List[AllMessageValues],
) -> List[AllMessageValues]:
"""
Translate `developer` role to `system` role for non-OpenAI providers.
"""
new_messages: List[AllMessageValues] = []
for m in messages:
if m["role"] == "developer":
new_messages.append({"role": "system", "content": m["content"]})
else:
new_messages.append(m)
return new_messages