mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-10 19:04:29 +00:00
075a089d82
* 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
25 lines
620 B
Python
25 lines
620 B
Python
from openai import OpenAI
|
|
|
|
client = OpenAI(
|
|
base_url="http://0.0.0.0:4000",
|
|
api_key="sk-1234",
|
|
)
|
|
|
|
BEDROCK_BATCH_MODEL = "bedrock/batch-anthropic.claude-3-5-sonnet-20240620-v1:0"
|
|
|
|
# Upload file
|
|
batch_input_file = client.files.create(
|
|
file=open("./bedrock_batch_completions.jsonl", "rb"),
|
|
purpose="batch",
|
|
extra_body={"target_model_names": BEDROCK_BATCH_MODEL}
|
|
)
|
|
print(batch_input_file)
|
|
|
|
# Create batch
|
|
batch = client.batches.create(
|
|
input_file_id=batch_input_file.id,
|
|
endpoint="/v1/chat/completions",
|
|
completion_window="24h",
|
|
metadata={"description": "Test batch job"},
|
|
)
|
|
print(batch) |