feat - add afile_content, file_content

This commit is contained in:
Ishaan Jaff 2024-05-28 20:58:22 -07:00
parent 18830e58e9
commit cd4a3627e8
4 changed files with 222 additions and 2 deletions

View file

@ -60,8 +60,6 @@ def test_create_batch():
create_batch_response.input_file_id == batch_input_file_id
), f"Failed to create batch, expected input_file_id to be {batch_input_file_id} but got {create_batch_response.input_file_id}"
time.sleep(30)
retrieved_batch = litellm.retrieve_batch(
batch_id=create_batch_response.id, custom_llm_provider="openai"
)
@ -70,6 +68,17 @@ def test_create_batch():
assert retrieved_batch.id == create_batch_response.id
file_content = litellm.file_content(
file_id=batch_input_file_id, custom_llm_provider="openai"
)
result = file_content.content
result_file_name = "batch_job_results_furniture.jsonl"
with open(result_file_name, "wb") as file:
file.write(result)
pass
@ -127,6 +136,18 @@ async def test_async_create_batch():
assert retrieved_batch.id == create_batch_response.id
# try to get file content for our original file
file_content = await litellm.afile_content(
file_id=batch_input_file_id, custom_llm_provider="openai"
)
print("file content = ", file_content)
# # write this file content to a file
# with open("file_content.json", "w") as f:
# json.dump(file_content, f)
def test_retrieve_batch():
pass