From 57f47357d82b3c5c5f584395d24a922a9a136edf Mon Sep 17 00:00:00 2001 From: Aomi Date: Mon, 16 Dec 2024 10:53:20 -0800 Subject: [PATCH] fix: BatchJob is updated to work with current OpenAi batch request format (#1240) --- instructor/batch.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/instructor/batch.py b/instructor/batch.py index 45887257b..ee37a9ca5 100644 --- a/instructor/batch.py +++ b/instructor/batch.py @@ -31,7 +31,9 @@ class RequestBody(BaseModel): class BatchModel(BaseModel): custom_id: str - params: RequestBody + body: RequestBody + url: str + method: str class BatchJob: @@ -149,12 +151,14 @@ def create_from_messages( for messages in messages_batch: batch_model = BatchModel( custom_id=str(uuid.uuid4()), - params=RequestBody( + body=RequestBody( model=model, messages=messages, max_tokens=max_tokens, temperature=temperature, **kwargs, ), + method="POST", + url="/v1/chat/completions" ) file.write(batch_model.model_dump_json() + "\n")