Skip to content

Commit

Permalink
fix: BatchJob is updated to work with current OpenAi batch request fo…
Browse files Browse the repository at this point in the history
…rmat (#1240)
  • Loading branch information
aomi authored Dec 16, 2024
1 parent bce6e69 commit 57f4735
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions instructor/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class RequestBody(BaseModel):

class BatchModel(BaseModel):
custom_id: str
params: RequestBody
body: RequestBody
url: str
method: str


class BatchJob:
Expand Down Expand Up @@ -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")

0 comments on commit 57f4735

Please sign in to comment.