litellm/litellm/files/utils.py
Ishaan Jaff 075a089d82
[Feat] Bedrock Batches - Ensure correct transformation applied to incoming requests (#14522)
* use is_batch_jsonl_file

* fix valid_content_type

* fix transform_create_file_request

* fix _transform_openai_jsonl_content_to_bedrock_jsonl_content

* test_transform_openai_jsonl_content_to_bedrock_jsonl_content

* fix mypy linting errors

* fix BEDROCK_BATCH_MODEL

* fix working sample

* fix comment

* fix model list

* fix: use with managed batches

* refactor
2025-09-12 18:32:57 -07:00

27 lines
899 B
Python

from typing import Optional
from litellm.types.llms.openai import CreateFileRequest
from litellm.types.utils import ExtractedFileData
class FilesAPIUtils:
"""
Utils for files API interface on litellm
"""
@staticmethod
def is_batch_jsonl_file(create_file_data: CreateFileRequest, extracted_file_data: ExtractedFileData) -> bool:
"""
Check if the file is a batch jsonl file
"""
return (
create_file_data.get("purpose") == "batch"
and FilesAPIUtils.valid_content_type(extracted_file_data.get("content_type"))
and extracted_file_data.get("content") is not None
)
@staticmethod
def valid_content_type(content_type: Optional[str]) -> bool:
"""
Check if the content type is valid
"""
return content_type in set(["application/jsonl", "application/octet-stream"])