Skip to content

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]

test - async ft jobs

Ishaan Jaffc9bea3a87991
diff --git a/litellm/fine_tuning/main.py b/litellm/fine_tuning/main.py
index 8bb9bf1a533..b41ced1b906 100644
--- a/litellm/fine_tuning/main.py
+++ b/litellm/fine_tuning/main.py
@@ -319,7 +319,7 @@ async def alist_fine_tuning_jobs(
# Use a partial function to pass your keyword arguments
func = partial(
- cancel_fine_tuning_job,
+ list_fine_tuning_jobs,
after,
limit,
custom_llm_provider,
diff --git a/litellm/llms/openai_fine_tuning/openai.py b/litellm/llms/openai_fine_tuning/openai.py
index ee79483b796..b955b9ce8d3 100644
--- a/litellm/llms/openai_fine_tuning/openai.py
+++ b/litellm/llms/openai_fine_tuning/openai.py
@@ -53,7 +53,9 @@ class OpenAIFineTuningAPI(BaseLLM):
create_fine_tuning_job_data: FineTuningJobCreate,
openai_client: AsyncOpenAI,
) -> FineTuningJob:
- response = await openai_client.batches.create(**create_fine_tuning_job_data)
+ response = await openai_client.fine_tuning.jobs.create(
+ **create_fine_tuning_job_data
+ )
return response
def create_fine_tuning_job(
diff --git a/litellm/tests/test_fine_tuning_api.py b/litellm/tests/test_fine_tuning_api.py
index 4a3922697fd..b7e3c957cce 100644
--- a/litellm/tests/test_fine_tuning_api.py
+++ b/litellm/tests/test_fine_tuning_api.py
@@ -45,7 +45,8 @@ def test_create_fine_tune_job():
print("listing ft jobs")
ft_jobs = litellm.list_fine_tuning_jobs(limit=2)
print("response from litellm.list_fine_tuning_jobs=", ft_jobs)
- assert len(ft_jobs) > 0
+
+ assert len(list(ft_jobs)) > 0
# delete file
@@ -63,3 +64,51 @@ def test_create_fine_tune_job():
assert response.status == "cancelled"
assert response.id == create_fine_tuning_response.id
pass
+
+
+async 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
+ pass