11from __future__ import annotations
22
3+ import uuid
34from os import PathLike
45from typing import List , Optional
56
910)
1011from ai21 .http_client .async_http_client import AsyncAI21HTTPClient
1112from ai21 .http_client .http_client import AI21HTTPClient
12- from ai21 .models import FileResponse
13+ from ai21 .models import FileResponse , UploadMode , BatchStatusResponse
1314from ai21 .types import NOT_GIVEN , NotGiven
1415from ai21 .utils .typing import remove_not_given
1516
@@ -32,10 +33,21 @@ def create(
3233 path : Optional [str ] | NotGiven = NOT_GIVEN ,
3334 labels : Optional [List [str ]] | NotGiven = NOT_GIVEN ,
3435 public_url : Optional [str ] | NotGiven = NOT_GIVEN ,
36+ upload_mode : Optional [UploadMode ] | NotGiven = NOT_GIVEN ,
37+ batch_id : Optional [uuid .UUID ] | NotGiven = NOT_GIVEN ,
3538 ** kwargs ,
3639 ) -> str :
3740 files = {"file" : open (file_path , "rb" )}
38- body = remove_not_given ({"path" : path , "labels" : labels , "publicUrl" : public_url , ** kwargs })
41+ body = remove_not_given (
42+ {
43+ "path" : path ,
44+ "labels" : labels ,
45+ "publicUrl" : public_url ,
46+ "upload_mode" : upload_mode ,
47+ "batch_id" : batch_id ,
48+ ** kwargs ,
49+ }
50+ )
3951
4052 raw_response = self ._post (path = f"/{ self ._module_name } " , files = files , body = body , response_cls = dict )
4153
@@ -44,6 +56,9 @@ def create(
4456 def get (self , file_id : str ) -> FileResponse :
4557 return self ._get (path = f"/{ self ._module_name } /{ file_id } " , response_cls = FileResponse )
4658
59+ def get_batch_status (self , batch_id : uuid .UUID ) -> BatchStatusResponse :
60+ return self ._get (path = f"/library/batches/{ batch_id } /status" , response_cls = BatchStatusResponse )
61+
4762 def list (
4863 self ,
4964 * ,
@@ -94,10 +109,21 @@ async def create(
94109 path : Optional [str ] | NotGiven = NOT_GIVEN ,
95110 labels : Optional [List [str ]] | NotGiven = NOT_GIVEN ,
96111 public_url : Optional [str ] | NotGiven = NOT_GIVEN ,
112+ upload_mode : Optional [UploadMode ] | NotGiven = NOT_GIVEN ,
113+ batch_id : Optional [uuid .UUID ] | NotGiven = NOT_GIVEN ,
97114 ** kwargs ,
98115 ) -> str :
99116 files = {"file" : open (file_path , "rb" )}
100- body = remove_not_given ({"path" : path , "labels" : labels , "publicUrl" : public_url , ** kwargs })
117+ body = remove_not_given (
118+ {
119+ "path" : path ,
120+ "labels" : labels ,
121+ "publicUrl" : public_url ,
122+ "upload_mode" : upload_mode ,
123+ "batch_id" : batch_id ,
124+ ** kwargs ,
125+ }
126+ )
101127
102128 raw_response = await self ._post (path = f"/{ self ._module_name } " , files = files , body = body , response_cls = dict )
103129
@@ -106,6 +132,9 @@ async def create(
106132 async def get (self , file_id : str ) -> FileResponse :
107133 return await self ._get (path = f"/{ self ._module_name } /{ file_id } " , response_cls = FileResponse )
108134
135+ async def get_batch_status (self , batch_id : uuid .UUID ) -> BatchStatusResponse :
136+ return await self ._get (path = f"/library/batches/{ batch_id } /status" , response_cls = BatchStatusResponse )
137+
109138 async def list (
110139 self ,
111140 * ,
0 commit comments