mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-03 01:38:46 +00:00
* fix(security): hash the publicly known master key Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: replace weak master key examples and regenerate artifacts Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test: replace weak key fixtures with generated test keys Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * ci: generate master keys for proxy startup Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: preserve lens dev key entropy Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: restore proxy key compatibility in scrub examples Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: scrub merged SSO fixture and refresh dashboard bundle Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(ci): stabilize test keys and metadata collection Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * chore: drop the rebuilt dashboard bundle Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: mateo <mateo@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
from openai import AsyncOpenAI
|
|
import os
|
|
import pytest
|
|
import asyncio
|
|
import openai
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_openai_fine_tuning():
|
|
"""
|
|
[PROD Test] e2e tests for /fine_tuning/jobs endpoints
|
|
"""
|
|
try:
|
|
client = AsyncOpenAI(api_key=os.environ["LITELLM_MASTER_KEY"], base_url="http://0.0.0.0:4000")
|
|
|
|
file_name = "openai_fine_tuning.jsonl"
|
|
_current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
file_path = os.path.join(_current_dir, file_name)
|
|
|
|
response = await client.files.create(
|
|
extra_headers={"custom-llm-provider": "openai"},
|
|
file=open(file_path, "rb"),
|
|
purpose="fine-tune",
|
|
)
|
|
|
|
print("response from files.create: {}".format(response))
|
|
|
|
await asyncio.sleep(5)
|
|
|
|
# create fine tuning job
|
|
|
|
ft_job = await client.fine_tuning.jobs.create(
|
|
model="gpt-4.1-mini-2025-04-14",
|
|
training_file=response.id,
|
|
extra_headers={"custom-llm-provider": "openai"},
|
|
)
|
|
|
|
print("response from ft job={}".format(ft_job))
|
|
|
|
# response from example endpoint
|
|
assert ft_job.id is not None
|
|
|
|
# list all fine tuning jobs
|
|
list_ft_jobs = await client.fine_tuning.jobs.list(
|
|
extra_headers={"custom-llm-provider": "openai"}
|
|
)
|
|
|
|
print("list of ft jobs={}".format(list_ft_jobs))
|
|
|
|
# cancel specific fine tuning job
|
|
cancel_ft_job = await client.fine_tuning.jobs.cancel(
|
|
fine_tuning_job_id=ft_job.id,
|
|
extra_headers={"custom-llm-provider": "openai"},
|
|
)
|
|
|
|
print("response from cancel ft job={}".format(cancel_ft_job))
|
|
|
|
assert cancel_ft_job.id is not None
|
|
|
|
# delete OG file
|
|
await client.files.delete(
|
|
file_id=response.id,
|
|
extra_headers={"custom-llm-provider": "openai"},
|
|
)
|
|
except openai.InternalServerError:
|
|
pass
|