aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/anthropic/pagination.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/anthropic/pagination.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are hereHEADmaster
Diffstat (limited to '.venv/lib/python3.12/site-packages/anthropic/pagination.py')
-rw-r--r--.venv/lib/python3.12/site-packages/anthropic/pagination.py84
1 files changed, 84 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/anthropic/pagination.py b/.venv/lib/python3.12/site-packages/anthropic/pagination.py
new file mode 100644
index 00000000..c4553fba
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/anthropic/pagination.py
@@ -0,0 +1,84 @@
+# 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__ = ["SyncPage", "AsyncPage"]
+
+_T = TypeVar("_T")
+
+
+class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
+ data: List[_T]
+ has_more: Optional[bool] = None
+ first_id: Optional[str] = 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]:
+ if self._options.params.get("before_id"):
+ first_id = self.first_id
+ if not first_id:
+ return None
+
+ return PageInfo(params={"before_id": first_id})
+
+ last_id = self.last_id
+ if not last_id:
+ return None
+
+ return PageInfo(params={"after_id": last_id})
+
+
+class AsyncPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
+ data: List[_T]
+ has_more: Optional[bool] = None
+ first_id: Optional[str] = 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]:
+ if self._options.params.get("before_id"):
+ first_id = self.first_id
+ if not first_id:
+ return None
+
+ return PageInfo(params={"before_id": first_id})
+
+ last_id = self.last_id
+ if not last_id:
+ return None
+
+ return PageInfo(params={"after_id": last_id})