This repository was archived by the owner on Aug 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathpagination.py
More file actions
108 lines (80 loc) · 2.73 KB
/
Copy pathpagination.py
File metadata and controls
108 lines (80 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import List, Generic, TypeVar, Optional
from typing_extensions import override
from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage
__all__ = ["SyncDatasetsIterrows", "AsyncDatasetsIterrows", "SyncOpenAICursorPage", "AsyncOpenAICursorPage"]
_T = TypeVar("_T")
class SyncDatasetsIterrows(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
data: List[_T]
next_index: Optional[int] = None
@override
def _get_page_items(self) -> List[_T]:
data = self.data
if not data:
return []
return data
@override
def next_page_info(self) -> Optional[PageInfo]:
next_index = self.next_index
if not next_index:
return None
return PageInfo(params={"start_index": next_index})
class AsyncDatasetsIterrows(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
data: List[_T]
next_index: Optional[int] = None
@override
def _get_page_items(self) -> List[_T]:
data = self.data
if not data:
return []
return data
@override
def next_page_info(self) -> Optional[PageInfo]:
next_index = self.next_index
if not next_index:
return None
return PageInfo(params={"start_index": next_index})
class SyncOpenAICursorPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
data: List[_T]
has_more: Optional[bool] = None
last_id: Optional[str] = None
@override
def _get_page_items(self) -> List[_T]:
data = self.data
if not data:
return []
return data
@override
def has_next_page(self) -> bool:
has_more = self.has_more
if has_more is not None and has_more is False:
return False
return super().has_next_page()
@override
def next_page_info(self) -> Optional[PageInfo]:
last_id = self.last_id
if not last_id:
return None
return PageInfo(params={"after": last_id})
class AsyncOpenAICursorPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
data: List[_T]
has_more: Optional[bool] = None
last_id: Optional[str] = None
@override
def _get_page_items(self) -> List[_T]:
data = self.data
if not data:
return []
return data
@override
def has_next_page(self) -> bool:
has_more = self.has_more
if has_more is not None and has_more is False:
return False
return super().has_next_page()
@override
def next_page_info(self) -> Optional[PageInfo]:
last_id = self.last_id
if not last_id:
return None
return PageInfo(params={"after": last_id})