mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 03:34:10 +00:00
* 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
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""
|
|
Handler file for calls to Azure OpenAI's o1/o3 family of models
|
|
|
|
Written separately to handle faking streaming for o1 and o3 models.
|
|
"""
|
|
|
|
from typing import Optional, Union
|
|
|
|
import httpx
|
|
from openai import AsyncAzureOpenAI, AsyncOpenAI, AzureOpenAI, OpenAI
|
|
|
|
from ...openai.openai import OpenAIChatCompletion
|
|
from ..common_utils import get_azure_openai_client
|
|
|
|
|
|
class AzureOpenAIO1ChatCompletion(OpenAIChatCompletion):
|
|
def _get_openai_client(
|
|
self,
|
|
is_async: bool,
|
|
api_key: Optional[str] = None,
|
|
api_base: Optional[str] = None,
|
|
api_version: Optional[str] = None,
|
|
timeout: Union[float, httpx.Timeout] = httpx.Timeout(None),
|
|
max_retries: Optional[int] = 2,
|
|
organization: Optional[str] = None,
|
|
client: Optional[
|
|
Union[OpenAI, AsyncOpenAI, AzureOpenAI, AsyncAzureOpenAI]
|
|
] = None,
|
|
) -> Optional[
|
|
Union[
|
|
OpenAI,
|
|
AsyncOpenAI,
|
|
AzureOpenAI,
|
|
AsyncAzureOpenAI,
|
|
]
|
|
]:
|
|
|
|
# Override to use Azure-specific client initialization
|
|
if not isinstance(client, AzureOpenAI) and not isinstance(
|
|
client, AsyncAzureOpenAI
|
|
):
|
|
client = None
|
|
|
|
return get_azure_openai_client(
|
|
api_key=api_key,
|
|
api_base=api_base,
|
|
timeout=timeout,
|
|
max_retries=max_retries,
|
|
organization=organization,
|
|
api_version=api_version,
|
|
client=client,
|
|
_is_async=is_async,
|
|
)
|