Skip to content

Commit a493be1

Browse files
committed
fix: changed module_name to /library instead of /library/files
1 parent 2015733 commit a493be1

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

ai21/clients/studio/resources/studio_library.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717

1818
class StudioLibrary(StudioResource):
19-
_module_name = "library/files"
19+
_module_name = "library"
2020

2121
def __init__(self, client: AI21HTTPClient):
2222
super().__init__(client)
2323
self.files = LibraryFiles(client)
2424

2525

2626
class LibraryFiles(StudioResource):
27-
_module_name = "library/files"
27+
_module_name = "library"
2828

2929
def create(
3030
self,
@@ -50,15 +50,15 @@ def create(
5050
if body.get("batch_id"):
5151
body["upload_mode"] = UploadMode.BATCH
5252

53-
raw_response = self._post(path=f"/{self._module_name}", files=files, body=body, response_cls=dict)
53+
raw_response = self._post(path=f"/{self._module_name}/files", files=files, body=body, response_cls=dict)
5454

5555
return raw_response["fileId"]
5656

5757
def get(self, file_id: str) -> FileResponse:
58-
return self._get(path=f"/{self._module_name}/{file_id}", response_cls=FileResponse)
58+
return self._get(path=f"/{self._module_name}/files/{file_id}", response_cls=FileResponse)
5959

6060
def get_batch_status(self, batch_id: str) -> BatchStatusResponse:
61-
return self._get(path=f"/library/batches/{batch_id}/status", response_cls=BatchStatusResponse)
61+
return self._get(path=f"/{self._module_name}/batches/{batch_id}/status", response_cls=BatchStatusResponse)
6262

6363
def list(
6464
self,
@@ -69,7 +69,7 @@ def list(
6969
) -> List[FileResponse]:
7070
params = remove_not_given({"offset": offset, "limit": limit})
7171

72-
return self._get(path=f"/{self._module_name}", params=params, response_cls=List[FileResponse])
72+
return self._get(path=f"/{self._module_name}/files", params=params, response_cls=List[FileResponse])
7373

7474
def update(
7575
self,
@@ -86,22 +86,22 @@ def update(
8686
**kwargs,
8787
}
8888
)
89-
self._put(path=f"/{self._module_name}/{file_id}", body=body)
89+
self._put(path=f"/{self._module_name}/files/{file_id}", body=body)
9090

9191
def delete(self, file_id: str) -> None:
92-
self._delete(path=f"/{self._module_name}/{file_id}")
92+
self._delete(path=f"/{self._module_name}/files/{file_id}")
9393

9494

9595
class AsyncStudioLibrary(AsyncStudioResource):
96-
_module_name = "library/files"
96+
_module_name = "library"
9797

9898
def __init__(self, client: AsyncAI21HTTPClient):
9999
super().__init__(client)
100100
self.files = AsyncLibraryFiles(client)
101101

102102

103103
class AsyncLibraryFiles(AsyncStudioResource):
104-
_module_name = "library/files"
104+
_module_name = "library"
105105

106106
async def create(
107107
self,
@@ -127,15 +127,15 @@ async def create(
127127
if body.get("batch_id"):
128128
body["upload_mode"] = UploadMode.BATCH
129129

130-
raw_response = await self._post(path=f"/{self._module_name}", files=files, body=body, response_cls=dict)
130+
raw_response = await self._post(path=f"/{self._module_name}/files", files=files, body=body, response_cls=dict)
131131

132132
return raw_response["fileId"]
133133

134134
async def get(self, file_id: str) -> FileResponse:
135-
return await self._get(path=f"/{self._module_name}/{file_id}", response_cls=FileResponse)
135+
return await self._get(path=f"/{self._module_name}/files/{file_id}", response_cls=FileResponse)
136136

137137
async def get_batch_status(self, batch_id: str) -> BatchStatusResponse:
138-
return await self._get(path=f"/library/batches/{batch_id}/status", response_cls=BatchStatusResponse)
138+
return await self._get(path=f"/{self._module_name}/batches/{batch_id}/status", response_cls=BatchStatusResponse)
139139

140140
async def list(
141141
self,
@@ -146,7 +146,7 @@ async def list(
146146
) -> List[FileResponse]:
147147
params = remove_not_given({"offset": offset, "limit": limit})
148148

149-
return await self._get(path=f"/{self._module_name}", params=params, response_cls=List[FileResponse])
149+
return await self._get(path=f"/{self._module_name}/files", params=params, response_cls=List[FileResponse])
150150

151151
async def update(
152152
self,
@@ -163,7 +163,7 @@ async def update(
163163
**kwargs,
164164
}
165165
)
166-
await self._put(path=f"/{self._module_name}/{file_id}", body=body)
166+
await self._put(path=f"/{self._module_name}/files/{file_id}", body=body)
167167

168168
async def delete(self, file_id: str) -> None:
169-
await self._delete(path=f"/{self._module_name}/{file_id}")
169+
await self._delete(path=f"/{self._module_name}/files/{file_id}")

0 commit comments

Comments
 (0)