Skip to content

Commit 82409e2

Browse files
committed
Add API to cancel a batch
1 parent 6e92279 commit 82409e2

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/together/resources/batch.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ def list_batches(self) -> List[BatchJob]:
7272
jobs = response.data or []
7373
return [BatchJob(**job) for job in jobs]
7474

75+
def cancel_batch(self, batch_job_id: str) -> BatchJob:
76+
requestor = api_requestor.APIRequestor(
77+
client=self._client,
78+
)
79+
80+
response, _, _ = requestor.request(
81+
options=TogetherRequest(
82+
method="POST",
83+
url=f"batches/{batch_job_id}/cancel",
84+
),
85+
stream=False,
86+
)
87+
88+
assert isinstance(response, TogetherResponse)
89+
return BatchJob(**response.data)
90+
7591

7692
class AsyncBatches:
7793
def __init__(self, client: TogetherClient) -> None:

src/together/types/batch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class BatchJobStatus(str, Enum):
2020
FAILED = "FAILED"
2121
EXPIRED = "EXPIRED"
2222
CANCELLED = "CANCELLED"
23+
CANCELING = "CANCELING"
2324

2425

2526
class BatchEndpoint(str, Enum):

0 commit comments

Comments
 (0)