@@ -72,6 +72,21 @@ 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+ return BatchJob (** response .data )
89+
7590
7691class AsyncBatches :
7792 def __init__ (self , client : TogetherClient ) -> None :
@@ -133,3 +148,18 @@ async def list_batches(self) -> List[BatchJob]:
133148 assert isinstance (response , TogetherResponse )
134149 jobs = response .data or []
135150 return [BatchJob (** job ) for job in jobs ]
151+
152+ async def cancel_batch (self , batch_job_id : str ) -> BatchJob :
153+ requestor = api_requestor .APIRequestor (
154+ client = self ._client ,
155+ )
156+
157+ response , _ , _ = await requestor .arequest (
158+ options = TogetherRequest (
159+ method = "POST" ,
160+ url = f"batches/{ batch_job_id } /cancel" ,
161+ ),
162+ stream = False ,
163+ )
164+
165+ return BatchJob (** response .data )
0 commit comments