The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Merge pull request #4987 from BerriAI/litellm_add_ft_endpoints
Ishaan Jaffd833c69acbc0
diff --cc litellm/tests/test_fine_tuning_api.pyindex 26f39e84535,f2bb73efde1..5346bab35b5--- a/litellm/tests/test_fine_tuning_api.py+++ b/litellm/tests/test_fine_tuning_api.py@@@ -12,10 -12,9 +12,11 @@@ from openai import APITimeoutError as Timport litellmlitellm.num_retries = 0+ import asyncioimport logging+import openai+from litellm import create_fine_tuning_jobfrom litellm._logging import verbose_logger@@@ -77,54 -69,93 +78,100 @@@ def test_create_fine_tune_job()@pytest.mark.asyncioasync def test_create_fine_tune_jobs_async():- verbose_logger.setLevel(logging.DEBUG)- file_name = "openai_batch_completions.jsonl"- _current_dir = os.path.dirname(os.path.abspath(__file__))- file_path = os.path.join(_current_dir, file_name)-- file_obj = await litellm.acreate_file(- file=open(file_path, "rb"),- purpose="fine-tune",- custom_llm_provider="openai",- )- print("Response from creating file=", file_obj)-- create_fine_tuning_response = await litellm.acreate_fine_tuning_job(- model="gpt-3.5-turbo-0125",- training_file=file_obj.id,- )-- print("response from litellm.create_fine_tuning_job=", create_fine_tuning_response)-- assert create_fine_tuning_response.id is not None- assert create_fine_tuning_response.model == "gpt-3.5-turbo-0125"-- # list fine tuning jobs- print("listing ft jobs")- ft_jobs = await litellm.alist_fine_tuning_jobs(limit=2)- print("response from litellm.list_fine_tuning_jobs=", ft_jobs)- assert len(list(ft_jobs)) > 0-- # delete file-- await litellm.afile_delete(- file_id=file_obj.id,- )-- # cancel ft job- response = await litellm.acancel_fine_tuning_job(- fine_tuning_job_id=create_fine_tuning_response.id,- )-- print("response from litellm.cancel_fine_tuning_job=", response)-- assert response.status == "cancelled"- assert response.id == create_fine_tuning_response.id+ try:+ verbose_logger.setLevel(logging.DEBUG)+ file_name = "openai_batch_completions.jsonl"+ _current_dir = os.path.dirname(os.path.abspath(__file__))+ file_path = os.path.join(_current_dir, file_name)++ file_obj = await litellm.acreate_file(+ file=open(file_path, "rb"),+ purpose="fine-tune",+ custom_llm_provider="openai",+ )+ print("Response from creating file=", file_obj)++ create_fine_tuning_response = await litellm.acreate_fine_tuning_job(+ model="gpt-3.5-turbo-0125",+ training_file=file_obj.id,+ )++ print(+ "response from litellm.create_fine_tuning_job=", create_fine_tuning_response+ )++ assert create_fine_tuning_response.id is not None+ assert create_fine_tuning_response.model == "gpt-3.5-turbo-0125"++ # list fine tuning jobs+ print("listing ft jobs")+ ft_jobs = await litellm.alist_fine_tuning_jobs(limit=2)+ print("response from litellm.list_fine_tuning_jobs=", ft_jobs)+ assert len(list(ft_jobs)) > 0++ # delete file++ await litellm.afile_delete(+ file_id=file_obj.id,+ )++ # cancel ft job+ response = await litellm.acancel_fine_tuning_job(+ fine_tuning_job_id=create_fine_tuning_response.id,+ )++ print("response from litellm.cancel_fine_tuning_job=", response)++ assert response.status == "cancelled"+ assert response.id == create_fine_tuning_response.id+ except openai.RateLimitError:+ pass+ except Exception as e:+ pytest.fail(f"Error occurred: {e}")pass+++ @pytest.mark.asyncio+ async def test_azure_create_fine_tune_jobs_async():+ verbose_logger.setLevel(logging.DEBUG)+ file_name = "azure_fine_tune.jsonl"+ _current_dir = os.path.dirname(os.path.abspath(__file__))+ file_path = os.path.join(_current_dir, file_name)++ file_id = "file-5e4b20ecbd724182b9964f3cd2ab7212"++ create_fine_tuning_response = await litellm.acreate_fine_tuning_job(+ model="gpt-35-turbo-1106",+ training_file=file_id,+ custom_llm_provider="azure",+ api_key=os.getenv("AZURE_SWEDEN_API_KEY"),+ api_base="https://my-endpoint-sweden-berri992.openai.azure.com/",+ )++ print("response from litellm.create_fine_tuning_job=", create_fine_tuning_response)++ assert create_fine_tuning_response.id is not None+ assert create_fine_tuning_response.model == "gpt-35-turbo-1106"++ # list fine tuning jobs+ print("listing ft jobs")+ ft_jobs = await litellm.alist_fine_tuning_jobs(+ limit=2,+ custom_llm_provider="azure",+ api_key=os.getenv("AZURE_SWEDEN_API_KEY"),+ api_base="https://my-endpoint-sweden-berri992.openai.azure.com/",+ )+ print("response from litellm.list_fine_tuning_jobs=", ft_jobs)++ # cancel ft job+ response = await litellm.acancel_fine_tuning_job(+ fine_tuning_job_id=create_fine_tuning_response.id,+ custom_llm_provider="azure",+ api_key=os.getenv("AZURE_SWEDEN_API_KEY"),+ api_base="https://my-endpoint-sweden-berri992.openai.azure.com/",+ )++ print("response from litellm.cancel_fine_tuning_job=", response)++ assert response.status == "cancelled"+ assert response.id == create_fine_tuning_response.id