Skip to content

Commit 9695627

Browse files
feat(api): update via SDK Studio
1 parent f5f67b8 commit 9695627

19 files changed

+451
-394
lines changed

api.md

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

1717
```python
1818
from zeroentropy.types import (
19-
CollectionAddCollectionResponse,
20-
CollectionDeleteCollectionResponse,
19+
CollectionDeleteResponse,
20+
CollectionAddResponse,
2121
CollectionGetListResponse,
2222
)
2323
```
2424

2525
Methods:
2626

27-
- <code title="post /collections/add-collection">client.collections.<a href="./src/zeroentropy/resources/collections.py">add_collection</a>(\*\*<a href="src/zeroentropy/types/collection_add_collection_params.py">params</a>) -> <a href="./src/zeroentropy/types/collection_add_collection_response.py">CollectionAddCollectionResponse</a></code>
28-
- <code title="post /collections/delete-collection">client.collections.<a href="./src/zeroentropy/resources/collections.py">delete_collection</a>(\*\*<a href="src/zeroentropy/types/collection_delete_collection_params.py">params</a>) -> <a href="./src/zeroentropy/types/collection_delete_collection_response.py">CollectionDeleteCollectionResponse</a></code>
27+
- <code title="post /collections/delete-collection">client.collections.<a href="./src/zeroentropy/resources/collections.py">delete</a>(\*\*<a href="src/zeroentropy/types/collection_delete_params.py">params</a>) -> <a href="./src/zeroentropy/types/collection_delete_response.py">CollectionDeleteResponse</a></code>
28+
- <code title="post /collections/add-collection">client.collections.<a href="./src/zeroentropy/resources/collections.py">add</a>(\*\*<a href="src/zeroentropy/types/collection_add_params.py">params</a>) -> <a href="./src/zeroentropy/types/collection_add_response.py">CollectionAddResponse</a></code>
2929
- <code title="post /collections/get-collection-list">client.collections.<a href="./src/zeroentropy/resources/collections.py">get_list</a>() -> <a href="./src/zeroentropy/types/collection_get_list_response.py">CollectionGetListResponse</a></code>
3030

3131
# Documents
@@ -34,8 +34,8 @@ Types:
3434

3535
```python
3636
from zeroentropy.types import (
37-
DocumentAddDocumentResponse,
38-
DocumentDeleteDocumentResponse,
37+
DocumentDeleteResponse,
38+
DocumentAddResponse,
3939
DocumentGetInfoResponse,
4040
DocumentGetInfoListResponse,
4141
DocumentGetPageInfoResponse,
@@ -44,8 +44,8 @@ from zeroentropy.types import (
4444

4545
Methods:
4646

47-
- <code title="post /documents/add-document">client.documents.<a href="./src/zeroentropy/resources/documents.py">add_document</a>(\*\*<a href="src/zeroentropy/types/document_add_document_params.py">params</a>) -> <a href="./src/zeroentropy/types/document_add_document_response.py">DocumentAddDocumentResponse</a></code>
48-
- <code title="post /documents/delete-document">client.documents.<a href="./src/zeroentropy/resources/documents.py">delete_document</a>(\*\*<a href="src/zeroentropy/types/document_delete_document_params.py">params</a>) -> <a href="./src/zeroentropy/types/document_delete_document_response.py">DocumentDeleteDocumentResponse</a></code>
47+
- <code title="post /documents/delete-document">client.documents.<a href="./src/zeroentropy/resources/documents.py">delete</a>(\*\*<a href="src/zeroentropy/types/document_delete_params.py">params</a>) -> <a href="./src/zeroentropy/types/document_delete_response.py">DocumentDeleteResponse</a></code>
48+
- <code title="post /documents/add-document">client.documents.<a href="./src/zeroentropy/resources/documents.py">add</a>(\*\*<a href="src/zeroentropy/types/document_add_params.py">params</a>) -> <a href="./src/zeroentropy/types/document_add_response.py">DocumentAddResponse</a></code>
4949
- <code title="post /documents/get-document-info">client.documents.<a href="./src/zeroentropy/resources/documents.py">get_info</a>(\*\*<a href="src/zeroentropy/types/document_get_info_params.py">params</a>) -> <a href="./src/zeroentropy/types/document_get_info_response.py">DocumentGetInfoResponse</a></code>
5050
- <code title="post /documents/get-document-info-list">client.documents.<a href="./src/zeroentropy/resources/documents.py">get_info_list</a>(\*\*<a href="src/zeroentropy/types/document_get_info_list_params.py">params</a>) -> <a href="./src/zeroentropy/types/document_get_info_list_response.py">DocumentGetInfoListResponse</a></code>
5151
- <code title="post /documents/get-page-info">client.documents.<a href="./src/zeroentropy/resources/documents.py">get_page_info</a>(\*\*<a href="src/zeroentropy/types/document_get_page_info_params.py">params</a>) -> <a href="./src/zeroentropy/types/document_get_page_info_response.py">DocumentGetPageInfoResponse</a></code>
@@ -73,12 +73,12 @@ Methods:
7373
Types:
7474

7575
```python
76-
from zeroentropy.types import ParserParseResponse
76+
from zeroentropy.types import ParserParseDocumentResponse
7777
```
7878

7979
Methods:
8080

81-
- <code title="post /parsers/parse-document">client.parsers.<a href="./src/zeroentropy/resources/parsers.py">parse</a>(\*\*<a href="src/zeroentropy/types/parser_parse_params.py">params</a>) -> <a href="./src/zeroentropy/types/parser_parse_response.py">ParserParseResponse</a></code>
81+
- <code title="post /parsers/parse-document">client.parsers.<a href="./src/zeroentropy/resources/parsers.py">parse_document</a>(\*\*<a href="src/zeroentropy/types/parser_parse_document_params.py">params</a>) -> <a href="./src/zeroentropy/types/parser_parse_document_response.py">ParserParseDocumentResponse</a></code>
8282

8383
# Models
8484

src/zeroentropy/pagination.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import Any, List, Generic, TypeVar, Optional, cast
4+
from typing_extensions import Protocol, override, runtime_checkable
5+
6+
from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage
7+
8+
__all__ = ["SyncGetDocumentInfoListCursor", "AsyncGetDocumentInfoListCursor"]
9+
10+
_T = TypeVar("_T")
11+
12+
13+
@runtime_checkable
14+
class GetDocumentInfoListCursorItem(Protocol):
15+
id: str
16+
17+
18+
class SyncGetDocumentInfoListCursor(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
19+
documents: List[_T]
20+
21+
@override
22+
def _get_page_items(self) -> List[_T]:
23+
documents = self.documents
24+
if not documents:
25+
return []
26+
return documents
27+
28+
@override
29+
def next_page_info(self) -> Optional[PageInfo]:
30+
documents = self.documents
31+
if not documents:
32+
return None
33+
34+
item = cast(Any, documents[-1])
35+
if not isinstance(item, GetDocumentInfoListCursorItem) or item.id is None: # pyright: ignore[reportUnnecessaryComparison]
36+
# TODO emit warning log
37+
return None
38+
39+
return PageInfo(params={"id_gt": item.id})
40+
41+
42+
class AsyncGetDocumentInfoListCursor(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
43+
documents: List[_T]
44+
45+
@override
46+
def _get_page_items(self) -> List[_T]:
47+
documents = self.documents
48+
if not documents:
49+
return []
50+
return documents
51+
52+
@override
53+
def next_page_info(self) -> Optional[PageInfo]:
54+
documents = self.documents
55+
if not documents:
56+
return None
57+
58+
item = cast(Any, documents[-1])
59+
if not isinstance(item, GetDocumentInfoListCursorItem) or item.id is None: # pyright: ignore[reportUnnecessaryComparison]
60+
# TODO emit warning log
61+
return None
62+
63+
return PageInfo(params={"id_gt": item.id})

src/zeroentropy/resources/collections.py

Lines changed: 57 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import httpx
66

7-
from ..types import collection_add_collection_params, collection_delete_collection_params
7+
from ..types import collection_add_params, collection_delete_params
88
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
99
from .._utils import (
1010
maybe_transform,
@@ -19,9 +19,9 @@
1919
async_to_streamed_response_wrapper,
2020
)
2121
from .._base_client import make_request_options
22+
from ..types.collection_add_response import CollectionAddResponse
23+
from ..types.collection_delete_response import CollectionDeleteResponse
2224
from ..types.collection_get_list_response import CollectionGetListResponse
23-
from ..types.collection_add_collection_response import CollectionAddCollectionResponse
24-
from ..types.collection_delete_collection_response import CollectionDeleteCollectionResponse
2525

2626
__all__ = ["CollectionsResource", "AsyncCollectionsResource"]
2727

@@ -46,7 +46,7 @@ def with_streaming_response(self) -> CollectionsResourceWithStreamingResponse:
4646
"""
4747
return CollectionsResourceWithStreamingResponse(self)
4848

49-
def add_collection(
49+
def delete(
5050
self,
5151
*,
5252
collection_name: str,
@@ -56,16 +56,15 @@ def add_collection(
5656
extra_query: Query | None = None,
5757
extra_body: Body | None = None,
5858
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
59-
) -> CollectionAddCollectionResponse:
59+
) -> CollectionDeleteResponse:
6060
"""
61-
Adds a collection.
61+
Deletes a collection.
6262
63-
If the collection already exists, a `409 Conflict` status code will be returned.
63+
A `404 Not Found` status code will be returned, if the provided collection name
64+
does not exist.
6465
6566
Args:
66-
collection_name: The name of the collection to add. The maximum length of this string is 1024
67-
characters. If special characters are used, then the UTF-8 encoded string cannot
68-
exceed 1024 bytes.
67+
collection_name: The name of the collection to delete.
6968
7069
extra_headers: Send extra headers
7170
@@ -76,17 +75,15 @@ def add_collection(
7675
timeout: Override the client-level default timeout for this request, in seconds
7776
"""
7877
return self._post(
79-
"/collections/add-collection",
80-
body=maybe_transform(
81-
{"collection_name": collection_name}, collection_add_collection_params.CollectionAddCollectionParams
82-
),
78+
"/collections/delete-collection",
79+
body=maybe_transform({"collection_name": collection_name}, collection_delete_params.CollectionDeleteParams),
8380
options=make_request_options(
8481
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
8582
),
86-
cast_to=CollectionAddCollectionResponse,
83+
cast_to=CollectionDeleteResponse,
8784
)
8885

89-
def delete_collection(
86+
def add(
9087
self,
9188
*,
9289
collection_name: str,
@@ -96,15 +93,16 @@ def delete_collection(
9693
extra_query: Query | None = None,
9794
extra_body: Body | None = None,
9895
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
99-
) -> CollectionDeleteCollectionResponse:
96+
) -> CollectionAddResponse:
10097
"""
101-
Deletes a collection.
98+
Adds a collection.
10299
103-
A `404 Not Found` status code will be returned, if the provided collection name
104-
does not exist.
100+
If the collection already exists, a `409 Conflict` status code will be returned.
105101
106102
Args:
107-
collection_name: The name of the collection to delete.
103+
collection_name: The name of the collection to add. The maximum length of this string is 1024
104+
characters. If special characters are used, then the UTF-8 encoded string cannot
105+
exceed 1024 bytes.
108106
109107
extra_headers: Send extra headers
110108
@@ -115,15 +113,12 @@ def delete_collection(
115113
timeout: Override the client-level default timeout for this request, in seconds
116114
"""
117115
return self._post(
118-
"/collections/delete-collection",
119-
body=maybe_transform(
120-
{"collection_name": collection_name},
121-
collection_delete_collection_params.CollectionDeleteCollectionParams,
122-
),
116+
"/collections/add-collection",
117+
body=maybe_transform({"collection_name": collection_name}, collection_add_params.CollectionAddParams),
123118
options=make_request_options(
124119
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
125120
),
126-
cast_to=CollectionDeleteCollectionResponse,
121+
cast_to=CollectionAddResponse,
127122
)
128123

129124
def get_list(
@@ -166,7 +161,7 @@ def with_streaming_response(self) -> AsyncCollectionsResourceWithStreamingRespon
166161
"""
167162
return AsyncCollectionsResourceWithStreamingResponse(self)
168163

169-
async def add_collection(
164+
async def delete(
170165
self,
171166
*,
172167
collection_name: str,
@@ -176,16 +171,15 @@ async def add_collection(
176171
extra_query: Query | None = None,
177172
extra_body: Body | None = None,
178173
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
179-
) -> CollectionAddCollectionResponse:
174+
) -> CollectionDeleteResponse:
180175
"""
181-
Adds a collection.
176+
Deletes a collection.
182177
183-
If the collection already exists, a `409 Conflict` status code will be returned.
178+
A `404 Not Found` status code will be returned, if the provided collection name
179+
does not exist.
184180
185181
Args:
186-
collection_name: The name of the collection to add. The maximum length of this string is 1024
187-
characters. If special characters are used, then the UTF-8 encoded string cannot
188-
exceed 1024 bytes.
182+
collection_name: The name of the collection to delete.
189183
190184
extra_headers: Send extra headers
191185
@@ -196,17 +190,17 @@ async def add_collection(
196190
timeout: Override the client-level default timeout for this request, in seconds
197191
"""
198192
return await self._post(
199-
"/collections/add-collection",
193+
"/collections/delete-collection",
200194
body=await async_maybe_transform(
201-
{"collection_name": collection_name}, collection_add_collection_params.CollectionAddCollectionParams
195+
{"collection_name": collection_name}, collection_delete_params.CollectionDeleteParams
202196
),
203197
options=make_request_options(
204198
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
205199
),
206-
cast_to=CollectionAddCollectionResponse,
200+
cast_to=CollectionDeleteResponse,
207201
)
208202

209-
async def delete_collection(
203+
async def add(
210204
self,
211205
*,
212206
collection_name: str,
@@ -216,15 +210,16 @@ async def delete_collection(
216210
extra_query: Query | None = None,
217211
extra_body: Body | None = None,
218212
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
219-
) -> CollectionDeleteCollectionResponse:
213+
) -> CollectionAddResponse:
220214
"""
221-
Deletes a collection.
215+
Adds a collection.
222216
223-
A `404 Not Found` status code will be returned, if the provided collection name
224-
does not exist.
217+
If the collection already exists, a `409 Conflict` status code will be returned.
225218
226219
Args:
227-
collection_name: The name of the collection to delete.
220+
collection_name: The name of the collection to add. The maximum length of this string is 1024
221+
characters. If special characters are used, then the UTF-8 encoded string cannot
222+
exceed 1024 bytes.
228223
229224
extra_headers: Send extra headers
230225
@@ -235,15 +230,14 @@ async def delete_collection(
235230
timeout: Override the client-level default timeout for this request, in seconds
236231
"""
237232
return await self._post(
238-
"/collections/delete-collection",
233+
"/collections/add-collection",
239234
body=await async_maybe_transform(
240-
{"collection_name": collection_name},
241-
collection_delete_collection_params.CollectionDeleteCollectionParams,
235+
{"collection_name": collection_name}, collection_add_params.CollectionAddParams
242236
),
243237
options=make_request_options(
244238
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
245239
),
246-
cast_to=CollectionDeleteCollectionResponse,
240+
cast_to=CollectionAddResponse,
247241
)
248242

249243
async def get_list(
@@ -270,11 +264,11 @@ class CollectionsResourceWithRawResponse:
270264
def __init__(self, collections: CollectionsResource) -> None:
271265
self._collections = collections
272266

273-
self.add_collection = to_raw_response_wrapper(
274-
collections.add_collection,
267+
self.delete = to_raw_response_wrapper(
268+
collections.delete,
275269
)
276-
self.delete_collection = to_raw_response_wrapper(
277-
collections.delete_collection,
270+
self.add = to_raw_response_wrapper(
271+
collections.add,
278272
)
279273
self.get_list = to_raw_response_wrapper(
280274
collections.get_list,
@@ -285,11 +279,11 @@ class AsyncCollectionsResourceWithRawResponse:
285279
def __init__(self, collections: AsyncCollectionsResource) -> None:
286280
self._collections = collections
287281

288-
self.add_collection = async_to_raw_response_wrapper(
289-
collections.add_collection,
282+
self.delete = async_to_raw_response_wrapper(
283+
collections.delete,
290284
)
291-
self.delete_collection = async_to_raw_response_wrapper(
292-
collections.delete_collection,
285+
self.add = async_to_raw_response_wrapper(
286+
collections.add,
293287
)
294288
self.get_list = async_to_raw_response_wrapper(
295289
collections.get_list,
@@ -300,11 +294,11 @@ class CollectionsResourceWithStreamingResponse:
300294
def __init__(self, collections: CollectionsResource) -> None:
301295
self._collections = collections
302296

303-
self.add_collection = to_streamed_response_wrapper(
304-
collections.add_collection,
297+
self.delete = to_streamed_response_wrapper(
298+
collections.delete,
305299
)
306-
self.delete_collection = to_streamed_response_wrapper(
307-
collections.delete_collection,
300+
self.add = to_streamed_response_wrapper(
301+
collections.add,
308302
)
309303
self.get_list = to_streamed_response_wrapper(
310304
collections.get_list,
@@ -315,11 +309,11 @@ class AsyncCollectionsResourceWithStreamingResponse:
315309
def __init__(self, collections: AsyncCollectionsResource) -> None:
316310
self._collections = collections
317311

318-
self.add_collection = async_to_streamed_response_wrapper(
319-
collections.add_collection,
312+
self.delete = async_to_streamed_response_wrapper(
313+
collections.delete,
320314
)
321-
self.delete_collection = async_to_streamed_response_wrapper(
322-
collections.delete_collection,
315+
self.add = async_to_streamed_response_wrapper(
316+
collections.add,
323317
)
324318
self.get_list = async_to_streamed_response_wrapper(
325319
collections.get_list,

0 commit comments

Comments
 (0)