mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
* init commit ft jobs logging * add ft logging * add logging for FineTuningJob * simple FT Job create test * simplify Azure fine tuning to use all methods in OAI ft * update doc string * add aretrieve_fine_tuning_job * re use from litellm.proxy.utils import handle_exception_on_proxy * fix naming * add /fine_tuning/jobs/{fine_tuning_job_id:path} * remove unused imports * update func signature * run ci/cd again * ci/cd run again * fix code qulity * ci/cd run again
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
from typing import Optional, Union
|
|
|
|
import httpx
|
|
from openai import AsyncAzureOpenAI, AsyncOpenAI, AzureOpenAI, OpenAI
|
|
|
|
from litellm.llms.azure.files.handler import get_azure_openai_client
|
|
from litellm.llms.openai.fine_tuning.handler import OpenAIFineTuningAPI
|
|
|
|
|
|
class AzureOpenAIFineTuningAPI(OpenAIFineTuningAPI):
|
|
"""
|
|
AzureOpenAI methods to support fine tuning, inherits from OpenAIFineTuningAPI.
|
|
"""
|
|
|
|
def get_openai_client(
|
|
self,
|
|
api_key: Optional[str],
|
|
api_base: Optional[str],
|
|
timeout: Union[float, httpx.Timeout],
|
|
max_retries: Optional[int],
|
|
organization: Optional[str],
|
|
client: Optional[
|
|
Union[OpenAI, AsyncOpenAI, AzureOpenAI, AsyncAzureOpenAI]
|
|
] = None,
|
|
_is_async: bool = False,
|
|
api_version: Optional[str] = None,
|
|
) -> Optional[
|
|
Union[
|
|
OpenAI,
|
|
AsyncOpenAI,
|
|
AzureOpenAI,
|
|
AsyncAzureOpenAI,
|
|
]
|
|
]:
|
|
# Override to use Azure-specific client initialization
|
|
if isinstance(client, OpenAI) or isinstance(client, AsyncOpenAI):
|
|
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,
|
|
)
|