From a6dd8b2449e5f204d198f657bacf4113af1474ff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 10:17:54 +0000 Subject: [PATCH 1/3] feat(api): api update --- .stats.yml | 4 +- README.md | 63 ----------------- api.md | 23 ++++--- .../resources/data_sources/connectors.py | 54 +++++++++------ .../resources/data_sources/data_sources.py | 54 +++++++++------ src/mixedbread/resources/files.py | 62 +++++++++++------ src/mixedbread/resources/parsing/jobs.py | 62 +++++++++++------ .../resources/vector_stores/files.py | 54 +++++++++------ .../resources/vector_stores/vector_stores.py | 54 +++++++++------ src/mixedbread/types/__init__.py | 3 + .../types/data_source_list_params.py | 17 +++-- .../types/data_source_list_response.py | 69 +++++++++++++++++++ src/mixedbread/types/data_sources/__init__.py | 1 + .../data_sources/connector_list_params.py | 17 +++-- .../data_sources/connector_list_response.py | 69 +++++++++++++++++++ src/mixedbread/types/file_list_params.py | 20 ++++-- src/mixedbread/types/file_list_response.py | 69 +++++++++++++++++++ .../types/parsing/job_list_params.py | 24 +++++-- .../types/parsing/job_list_response.py | 66 +++++++++++++++++- .../types/vector_store_list_params.py | 17 +++-- .../types/vector_store_list_response.py | 69 +++++++++++++++++++ .../types/vector_stores/__init__.py | 1 + .../types/vector_stores/file_list_params.py | 17 +++-- .../types/vector_stores/file_list_response.py | 69 +++++++++++++++++++ .../data_sources/test_connectors.py | 32 +++++---- tests/api_resources/parsing/test_jobs.py | 33 +++++---- tests/api_resources/test_data_sources.py | 32 +++++---- tests/api_resources/test_files.py | 39 ++++++----- tests/api_resources/test_vector_stores.py | 32 +++++---- .../api_resources/vector_stores/test_files.py | 32 +++++---- 30 files changed, 834 insertions(+), 324 deletions(-) create mode 100644 src/mixedbread/types/data_source_list_response.py create mode 100644 src/mixedbread/types/data_sources/connector_list_response.py create mode 100644 src/mixedbread/types/file_list_response.py create mode 100644 src/mixedbread/types/vector_store_list_response.py create mode 100644 src/mixedbread/types/vector_stores/file_list_response.py diff --git a/.stats.yml b/.stats.yml index 26f6a536..f49ee495 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 49 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-7361ed078e7c394c7cb1da4a3e2f3417d4498de5eea648cf9d3caaa0ddf85f78.yml -openapi_spec_hash: 4ae67ffa9040c2d5a87026df79c1feaf +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-fe968780e87b8a5ff65ea009ade00fb0e27e951f7ce16d39a2ae0957740add45.yml +openapi_spec_hash: 9a29ae1bb05df2061e321b0d1adef675 config_hash: 95ffbc5d87b528d727a944596d7cf051 diff --git a/README.md b/README.md index d4ec35ba..8bfd5cf1 100644 --- a/README.md +++ b/README.md @@ -109,69 +109,6 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`. -## Pagination - -List methods in the Mixedbread API are paginated. - -This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually: - -```python -from mixedbread import Mixedbread - -client = Mixedbread() - -all_vector_stores = [] -# Automatically fetches more pages as needed. -for vector_store in client.vector_stores.list(): - # Do something with vector_store here - all_vector_stores.append(vector_store) -print(all_vector_stores) -``` - -Or, asynchronously: - -```python -import asyncio -from mixedbread import AsyncMixedbread - -client = AsyncMixedbread() - - -async def main() -> None: - all_vector_stores = [] - # Iterate through items across all pages, issuing requests as needed. - async for vector_store in client.vector_stores.list(): - all_vector_stores.append(vector_store) - print(all_vector_stores) - - -asyncio.run(main()) -``` - -Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages: - -```python -first_page = await client.vector_stores.list() -if first_page.has_next_page(): - print(f"will fetch next page using these details: {first_page.next_page_info()}") - next_page = await first_page.get_next_page() - print(f"number of items we just fetched: {len(next_page.data)}") - -# Remove `await` for non-async usage. -``` - -Or just work directly with the returned data: - -```python -first_page = await client.vector_stores.list() - -print(f"next page cursor: {first_page.pagination.next_cursor}") # => "next page cursor: ..." -for vector_store in first_page.data: - print(vector_store.id) - -# Remove `await` for non-async usage. -``` - ## Nested params Nested parameters are dictionaries, typed using `TypedDict`, for example: diff --git a/api.md b/api.md index a9f5376f..71c47d0b 100644 --- a/api.md +++ b/api.md @@ -37,6 +37,7 @@ from mixedbread.types import ( ScoredVideoURLInputChunk, VectorStore, VectorStoreChunkSearchOptions, + VectorStoreListResponse, VectorStoreDeleteResponse, VectorStoreQuestionAnsweringResponse, VectorStoreSearchResponse, @@ -48,7 +49,7 @@ Methods: - client.vector_stores.create(\*\*params) -> VectorStore - client.vector_stores.retrieve(vector_store_identifier) -> VectorStore - client.vector_stores.update(vector_store_identifier, \*\*params) -> VectorStore -- client.vector_stores.list(\*\*params) -> SyncCursor[VectorStore] +- client.vector_stores.list(\*\*params) -> VectorStoreListResponse - client.vector_stores.delete(vector_store_identifier) -> VectorStoreDeleteResponse - client.vector_stores.question_answering(\*\*params) -> VectorStoreQuestionAnsweringResponse - client.vector_stores.search(\*\*params) -> VectorStoreSearchResponse @@ -63,6 +64,7 @@ from mixedbread.types.vector_stores import ( ScoredVectorStoreFile, VectorStoreFileStatus, VectorStoreFile, + FileListResponse, FileDeleteResponse, FileSearchResponse, ) @@ -72,7 +74,7 @@ Methods: - client.vector_stores.files.create(vector_store_identifier, \*\*params) -> VectorStoreFile - client.vector_stores.files.retrieve(file_id, \*, vector_store_identifier) -> VectorStoreFile -- client.vector_stores.files.list(vector_store_identifier, \*\*params) -> SyncCursor[VectorStoreFile] +- client.vector_stores.files.list(vector_store_identifier, \*\*params) -> FileListResponse - client.vector_stores.files.delete(file_id, \*, vector_store_identifier) -> FileDeleteResponse - client.vector_stores.files.search(\*\*params) -> FileSearchResponse @@ -98,7 +100,7 @@ Methods: - client.parsing.jobs.create(\*\*params) -> ParsingJob - client.parsing.jobs.retrieve(job_id) -> ParsingJob -- client.parsing.jobs.list(\*\*params) -> SyncCursor[JobListResponse] +- client.parsing.jobs.list(\*\*params) -> JobListResponse - client.parsing.jobs.delete(job_id) -> JobDeleteResponse - client.parsing.jobs.cancel(job_id) -> ParsingJob @@ -107,7 +109,7 @@ Methods: Types: ```python -from mixedbread.types import FileObject, PaginationWithTotal, FileDeleteResponse +from mixedbread.types import FileObject, PaginationWithTotal, FileListResponse, FileDeleteResponse ``` Methods: @@ -115,7 +117,7 @@ Methods: - client.files.create(\*\*params) -> FileObject - client.files.retrieve(file_id) -> FileObject - client.files.update(file_id, \*\*params) -> FileObject -- client.files.list(\*\*params) -> SyncCursor[FileObject] +- client.files.list(\*\*params) -> FileListResponse - client.files.delete(file_id) -> FileDeleteResponse - client.files.content(file_id) -> BinaryAPIResponse @@ -184,6 +186,7 @@ from mixedbread.types import ( LinearDataSource, NotionDataSource, Oauth2Params, + DataSourceListResponse, DataSourceDeleteResponse, ) ``` @@ -193,7 +196,7 @@ Methods: - client.data_sources.create(\*\*params) -> DataSource - client.data_sources.retrieve(data_source_id) -> DataSource - client.data_sources.update(data_source_id, \*\*params) -> DataSource -- client.data_sources.list(\*\*params) -> SyncCursor[DataSource] +- client.data_sources.list(\*\*params) -> DataSourceListResponse - client.data_sources.delete(data_source_id) -> DataSourceDeleteResponse ## Connectors @@ -201,7 +204,11 @@ Methods: Types: ```python -from mixedbread.types.data_sources import DataSourceConnector, ConnectorDeleteResponse +from mixedbread.types.data_sources import ( + DataSourceConnector, + ConnectorListResponse, + ConnectorDeleteResponse, +) ``` Methods: @@ -209,7 +216,7 @@ Methods: - client.data_sources.connectors.create(data_source_id, \*\*params) -> DataSourceConnector - client.data_sources.connectors.retrieve(connector_id, \*, data_source_id) -> DataSourceConnector - client.data_sources.connectors.update(connector_id, \*, data_source_id, \*\*params) -> DataSourceConnector -- client.data_sources.connectors.list(data_source_id, \*\*params) -> SyncCursor[DataSourceConnector] +- client.data_sources.connectors.list(data_source_id, \*\*params) -> ConnectorListResponse - client.data_sources.connectors.delete(connector_id, \*, data_source_id) -> ConnectorDeleteResponse # APIKeys diff --git a/src/mixedbread/resources/data_sources/connectors.py b/src/mixedbread/resources/data_sources/connectors.py index dbc11701..f333b4e9 100644 --- a/src/mixedbread/resources/data_sources/connectors.py +++ b/src/mixedbread/resources/data_sources/connectors.py @@ -16,10 +16,10 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ...pagination import SyncCursor, AsyncCursor -from ..._base_client import AsyncPaginator, make_request_options +from ..._base_client import make_request_options from ...types.data_sources import connector_list_params, connector_create_params, connector_update_params from ...types.data_sources.data_source_connector import DataSourceConnector +from ...types.data_sources.connector_list_response import ConnectorListResponse from ...types.data_sources.connector_delete_response import ConnectorDeleteResponse __all__ = ["ConnectorsResource", "AsyncConnectorsResource"] @@ -237,7 +237,8 @@ def list( data_source_id: str, *, limit: int | NotGiven = NOT_GIVEN, - cursor: Optional[str] | NotGiven = NOT_GIVEN, + after: Optional[str] | NotGiven = NOT_GIVEN, + before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -245,7 +246,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncCursor[DataSourceConnector]: + ) -> ConnectorListResponse: """ Get all connectors for a data source. @@ -257,11 +258,15 @@ def list( Args: data_source_id: The ID of the data source to get connectors for - limit: Maximum number of items to return per page + limit: Maximum number of items to return per page (1-100) - cursor: Cursor for pagination (base64 encoded cursor) + after: Cursor for forward pagination - get items after this position. Use last_cursor + from previous response. - include_total: Whether to include the total number of items + before: Cursor for backward pagination - get items before this position. Use + first_cursor from previous response. + + include_total: Whether to include total count in response (expensive operation) extra_headers: Send extra headers @@ -273,9 +278,8 @@ def list( """ if not data_source_id: raise ValueError(f"Expected a non-empty value for `data_source_id` but received {data_source_id!r}") - return self._get_api_list( + return self._get( f"/v1/data_sources/{data_source_id}/connectors", - page=SyncCursor[DataSourceConnector], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -284,13 +288,14 @@ def list( query=maybe_transform( { "limit": limit, - "cursor": cursor, + "after": after, + "before": before, "include_total": include_total, }, connector_list_params.ConnectorListParams, ), ), - model=DataSourceConnector, + cast_to=ConnectorListResponse, ) def delete( @@ -546,12 +551,13 @@ async def update( cast_to=DataSourceConnector, ) - def list( + async def list( self, data_source_id: str, *, limit: int | NotGiven = NOT_GIVEN, - cursor: Optional[str] | NotGiven = NOT_GIVEN, + after: Optional[str] | NotGiven = NOT_GIVEN, + before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -559,7 +565,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[DataSourceConnector, AsyncCursor[DataSourceConnector]]: + ) -> ConnectorListResponse: """ Get all connectors for a data source. @@ -571,11 +577,15 @@ def list( Args: data_source_id: The ID of the data source to get connectors for - limit: Maximum number of items to return per page + limit: Maximum number of items to return per page (1-100) - cursor: Cursor for pagination (base64 encoded cursor) + after: Cursor for forward pagination - get items after this position. Use last_cursor + from previous response. - include_total: Whether to include the total number of items + before: Cursor for backward pagination - get items before this position. Use + first_cursor from previous response. + + include_total: Whether to include total count in response (expensive operation) extra_headers: Send extra headers @@ -587,24 +597,24 @@ def list( """ if not data_source_id: raise ValueError(f"Expected a non-empty value for `data_source_id` but received {data_source_id!r}") - return self._get_api_list( + return await self._get( f"/v1/data_sources/{data_source_id}/connectors", - page=AsyncCursor[DataSourceConnector], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=maybe_transform( + query=await async_maybe_transform( { "limit": limit, - "cursor": cursor, + "after": after, + "before": before, "include_total": include_total, }, connector_list_params.ConnectorListParams, ), ), - model=DataSourceConnector, + cast_to=ConnectorListResponse, ) async def delete( diff --git a/src/mixedbread/resources/data_sources/data_sources.py b/src/mixedbread/resources/data_sources/data_sources.py index d9e4920f..c8a83074 100644 --- a/src/mixedbread/resources/data_sources/data_sources.py +++ b/src/mixedbread/resources/data_sources/data_sources.py @@ -32,11 +32,11 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ...pagination import SyncCursor, AsyncCursor -from ..._base_client import AsyncPaginator, make_request_options +from ..._base_client import make_request_options from ...types.data_source import DataSource from ...types.oauth2_params import Oauth2Params from ...types.data_source_type import DataSourceType +from ...types.data_source_list_response import DataSourceListResponse from ...types.data_source_delete_response import DataSourceDeleteResponse __all__ = ["DataSourcesResource", "AsyncDataSourcesResource"] @@ -356,7 +356,8 @@ def list( self, *, limit: int | NotGiven = NOT_GIVEN, - cursor: Optional[str] | NotGiven = NOT_GIVEN, + after: Optional[str] | NotGiven = NOT_GIVEN, + before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -364,18 +365,22 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncCursor[DataSource]: + ) -> DataSourceListResponse: """ Get all data sources. Returns: The list of data sources. Args: - limit: Maximum number of items to return per page + limit: Maximum number of items to return per page (1-100) - cursor: Cursor for pagination (base64 encoded cursor) + after: Cursor for forward pagination - get items after this position. Use last_cursor + from previous response. - include_total: Whether to include the total number of items + before: Cursor for backward pagination - get items before this position. Use + first_cursor from previous response. + + include_total: Whether to include total count in response (expensive operation) extra_headers: Send extra headers @@ -385,9 +390,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - return self._get_api_list( + return self._get( "/v1/data_sources/", - page=SyncCursor[DataSource], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -396,13 +400,14 @@ def list( query=maybe_transform( { "limit": limit, - "cursor": cursor, + "after": after, + "before": before, "include_total": include_total, }, data_source_list_params.DataSourceListParams, ), ), - model=DataSource, + cast_to=DataSourceListResponse, ) def delete( @@ -753,11 +758,12 @@ async def update( cast_to=DataSource, ) - def list( + async def list( self, *, limit: int | NotGiven = NOT_GIVEN, - cursor: Optional[str] | NotGiven = NOT_GIVEN, + after: Optional[str] | NotGiven = NOT_GIVEN, + before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -765,18 +771,22 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[DataSource, AsyncCursor[DataSource]]: + ) -> DataSourceListResponse: """ Get all data sources. Returns: The list of data sources. Args: - limit: Maximum number of items to return per page + limit: Maximum number of items to return per page (1-100) - cursor: Cursor for pagination (base64 encoded cursor) + after: Cursor for forward pagination - get items after this position. Use last_cursor + from previous response. - include_total: Whether to include the total number of items + before: Cursor for backward pagination - get items before this position. Use + first_cursor from previous response. + + include_total: Whether to include total count in response (expensive operation) extra_headers: Send extra headers @@ -786,24 +796,24 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - return self._get_api_list( + return await self._get( "/v1/data_sources/", - page=AsyncCursor[DataSource], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=maybe_transform( + query=await async_maybe_transform( { "limit": limit, - "cursor": cursor, + "after": after, + "before": before, "include_total": include_total, }, data_source_list_params.DataSourceListParams, ), ), - model=DataSource, + cast_to=DataSourceListResponse, ) async def delete( diff --git a/src/mixedbread/resources/files.py b/src/mixedbread/resources/files.py index f02646cb..10f6a213 100644 --- a/src/mixedbread/resources/files.py +++ b/src/mixedbread/resources/files.py @@ -25,9 +25,9 @@ async_to_custom_raw_response_wrapper, async_to_custom_streamed_response_wrapper, ) -from ..pagination import SyncCursor, AsyncCursor -from .._base_client import AsyncPaginator, make_request_options +from .._base_client import make_request_options from ..types.file_object import FileObject +from ..types.file_list_response import FileListResponse from ..types.file_delete_response import FileDeleteResponse __all__ = ["FilesResource", "AsyncFilesResource"] @@ -191,15 +191,17 @@ def list( self, *, limit: int | NotGiven = NOT_GIVEN, - cursor: Optional[str] | NotGiven = NOT_GIVEN, + after: Optional[str] | NotGiven = NOT_GIVEN, + before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, + q: Optional[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncCursor[FileObject]: + ) -> FileListResponse: """ List all files for the authenticated user. @@ -208,11 +210,17 @@ def list( Returns: A list of files belonging to the user. Args: - limit: Maximum number of items to return per page + limit: Maximum number of items to return per page (1-100) - cursor: Cursor for pagination (base64 encoded cursor) + after: Cursor for forward pagination - get items after this position. Use last_cursor + from previous response. - include_total: Whether to include the total number of items + before: Cursor for backward pagination - get items before this position. Use + first_cursor from previous response. + + include_total: Whether to include total count in response (expensive operation) + + q: Search query for fuzzy matching over name and description fields extra_headers: Send extra headers @@ -222,9 +230,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - return self._get_api_list( + return self._get( "/v1/files", - page=SyncCursor[FileObject], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -233,13 +240,15 @@ def list( query=maybe_transform( { "limit": limit, - "cursor": cursor, + "after": after, + "before": before, "include_total": include_total, + "q": q, }, file_list_params.FileListParams, ), ), - model=FileObject, + cast_to=FileListResponse, ) def delete( @@ -476,19 +485,21 @@ async def update( cast_to=FileObject, ) - def list( + async def list( self, *, limit: int | NotGiven = NOT_GIVEN, - cursor: Optional[str] | NotGiven = NOT_GIVEN, + after: Optional[str] | NotGiven = NOT_GIVEN, + before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, + q: Optional[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[FileObject, AsyncCursor[FileObject]]: + ) -> FileListResponse: """ List all files for the authenticated user. @@ -497,11 +508,17 @@ def list( Returns: A list of files belonging to the user. Args: - limit: Maximum number of items to return per page + limit: Maximum number of items to return per page (1-100) - cursor: Cursor for pagination (base64 encoded cursor) + after: Cursor for forward pagination - get items after this position. Use last_cursor + from previous response. - include_total: Whether to include the total number of items + before: Cursor for backward pagination - get items before this position. Use + first_cursor from previous response. + + include_total: Whether to include total count in response (expensive operation) + + q: Search query for fuzzy matching over name and description fields extra_headers: Send extra headers @@ -511,24 +528,25 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - return self._get_api_list( + return await self._get( "/v1/files", - page=AsyncCursor[FileObject], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=maybe_transform( + query=await async_maybe_transform( { "limit": limit, - "cursor": cursor, + "after": after, + "before": before, "include_total": include_total, + "q": q, }, file_list_params.FileListParams, ), ), - model=FileObject, + cast_to=FileListResponse, ) async def delete( diff --git a/src/mixedbread/resources/parsing/jobs.py b/src/mixedbread/resources/parsing/jobs.py index 1d458ae7..f439ac92 100644 --- a/src/mixedbread/resources/parsing/jobs.py +++ b/src/mixedbread/resources/parsing/jobs.py @@ -19,14 +19,14 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ...pagination import SyncCursor, AsyncCursor -from ..._base_client import AsyncPaginator, make_request_options +from ..._base_client import make_request_options from ...types.parsing import ReturnFormat, ChunkingStrategy, job_list_params, job_create_params from ...types.parsing.parsing_job import ParsingJob from ...types.parsing.element_type import ElementType from ...types.parsing.return_format import ReturnFormat from ...types.parsing.chunking_strategy import ChunkingStrategy from ...types.parsing.job_list_response import JobListResponse +from ...types.parsing.parsing_job_status import ParsingJobStatus from ...types.parsing.job_delete_response import JobDeleteResponse __all__ = ["JobsResource", "AsyncJobsResource"] @@ -154,15 +154,17 @@ def list( self, *, limit: int | NotGiven = NOT_GIVEN, - cursor: Optional[str] | NotGiven = NOT_GIVEN, + after: Optional[str] | NotGiven = NOT_GIVEN, + before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, + statuses: Optional[List[ParsingJobStatus]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncCursor[JobListResponse]: + ) -> JobListResponse: """List parsing jobs with pagination. Args: limit: The number of items to return. @@ -172,11 +174,17 @@ def list( Returns: List of parsing jobs with pagination. Args: - limit: Maximum number of items to return per page + limit: Maximum number of items to return per page (1-100) - cursor: Cursor for pagination (base64 encoded cursor) + after: Cursor for forward pagination - get items after this position. Use last_cursor + from previous response. - include_total: Whether to include the total number of items + before: Cursor for backward pagination - get items before this position. Use + first_cursor from previous response. + + include_total: Whether to include total count in response (expensive operation) + + statuses: Status to filter by extra_headers: Send extra headers @@ -186,9 +194,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - return self._get_api_list( + return self._get( "/v1/parsing/jobs", - page=SyncCursor[JobListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -197,13 +204,15 @@ def list( query=maybe_transform( { "limit": limit, - "cursor": cursor, + "after": after, + "before": before, "include_total": include_total, + "statuses": statuses, }, job_list_params.JobListParams, ), ), - model=JobListResponse, + cast_to=JobListResponse, ) def delete( @@ -560,19 +569,21 @@ async def retrieve( cast_to=ParsingJob, ) - def list( + async def list( self, *, limit: int | NotGiven = NOT_GIVEN, - cursor: Optional[str] | NotGiven = NOT_GIVEN, + after: Optional[str] | NotGiven = NOT_GIVEN, + before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, + statuses: Optional[List[ParsingJobStatus]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[JobListResponse, AsyncCursor[JobListResponse]]: + ) -> JobListResponse: """List parsing jobs with pagination. Args: limit: The number of items to return. @@ -582,11 +593,17 @@ def list( Returns: List of parsing jobs with pagination. Args: - limit: Maximum number of items to return per page + limit: Maximum number of items to return per page (1-100) - cursor: Cursor for pagination (base64 encoded cursor) + after: Cursor for forward pagination - get items after this position. Use last_cursor + from previous response. - include_total: Whether to include the total number of items + before: Cursor for backward pagination - get items before this position. Use + first_cursor from previous response. + + include_total: Whether to include total count in response (expensive operation) + + statuses: Status to filter by extra_headers: Send extra headers @@ -596,24 +613,25 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - return self._get_api_list( + return await self._get( "/v1/parsing/jobs", - page=AsyncCursor[JobListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=maybe_transform( + query=await async_maybe_transform( { "limit": limit, - "cursor": cursor, + "after": after, + "before": before, "include_total": include_total, + "statuses": statuses, }, job_list_params.JobListParams, ), ), - model=JobListResponse, + cast_to=JobListResponse, ) async def delete( diff --git a/src/mixedbread/resources/vector_stores/files.py b/src/mixedbread/resources/vector_stores/files.py index 189660a1..6bd6b1c7 100644 --- a/src/mixedbread/resources/vector_stores/files.py +++ b/src/mixedbread/resources/vector_stores/files.py @@ -18,10 +18,10 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ...pagination import SyncCursor, AsyncCursor -from ..._base_client import AsyncPaginator, make_request_options +from ..._base_client import make_request_options from ...types.vector_stores import file_list_params, file_create_params, file_search_params from ...types.vector_stores.vector_store_file import VectorStoreFile +from ...types.vector_stores.file_list_response import FileListResponse from ...types.vector_stores.file_delete_response import FileDeleteResponse from ...types.vector_stores.file_search_response import FileSearchResponse from ...types.vector_stores.vector_store_file_status import VectorStoreFileStatus @@ -160,7 +160,8 @@ def list( vector_store_identifier: str, *, limit: int | NotGiven = NOT_GIVEN, - cursor: Optional[str] | NotGiven = NOT_GIVEN, + after: Optional[str] | NotGiven = NOT_GIVEN, + before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, statuses: Optional[List[VectorStoreFileStatus]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -169,7 +170,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncCursor[VectorStoreFile]: + ) -> FileListResponse: """ List files indexed in a vector store with pagination. @@ -181,11 +182,15 @@ def list( Args: vector_store_identifier: The ID or name of the vector store - limit: Maximum number of items to return per page + limit: Maximum number of items to return per page (1-100) - cursor: Cursor for pagination (base64 encoded cursor) + after: Cursor for forward pagination - get items after this position. Use last_cursor + from previous response. - include_total: Whether to include the total number of items + before: Cursor for backward pagination - get items before this position. Use + first_cursor from previous response. + + include_total: Whether to include total count in response (expensive operation) statuses: Status to filter by @@ -201,9 +206,8 @@ def list( raise ValueError( f"Expected a non-empty value for `vector_store_identifier` but received {vector_store_identifier!r}" ) - return self._get_api_list( + return self._get( f"/v1/vector_stores/{vector_store_identifier}/files", - page=SyncCursor[VectorStoreFile], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -212,14 +216,15 @@ def list( query=maybe_transform( { "limit": limit, - "cursor": cursor, + "after": after, + "before": before, "include_total": include_total, "statuses": statuses, }, file_list_params.FileListParams, ), ), - model=VectorStoreFile, + cast_to=FileListResponse, ) def delete( @@ -578,12 +583,13 @@ async def retrieve( cast_to=VectorStoreFile, ) - def list( + async def list( self, vector_store_identifier: str, *, limit: int | NotGiven = NOT_GIVEN, - cursor: Optional[str] | NotGiven = NOT_GIVEN, + after: Optional[str] | NotGiven = NOT_GIVEN, + before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, statuses: Optional[List[VectorStoreFileStatus]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -592,7 +598,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[VectorStoreFile, AsyncCursor[VectorStoreFile]]: + ) -> FileListResponse: """ List files indexed in a vector store with pagination. @@ -604,11 +610,15 @@ def list( Args: vector_store_identifier: The ID or name of the vector store - limit: Maximum number of items to return per page + limit: Maximum number of items to return per page (1-100) - cursor: Cursor for pagination (base64 encoded cursor) + after: Cursor for forward pagination - get items after this position. Use last_cursor + from previous response. - include_total: Whether to include the total number of items + before: Cursor for backward pagination - get items before this position. Use + first_cursor from previous response. + + include_total: Whether to include total count in response (expensive operation) statuses: Status to filter by @@ -624,25 +634,25 @@ def list( raise ValueError( f"Expected a non-empty value for `vector_store_identifier` but received {vector_store_identifier!r}" ) - return self._get_api_list( + return await self._get( f"/v1/vector_stores/{vector_store_identifier}/files", - page=AsyncCursor[VectorStoreFile], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=maybe_transform( + query=await async_maybe_transform( { "limit": limit, - "cursor": cursor, + "after": after, + "before": before, "include_total": include_total, "statuses": statuses, }, file_list_params.FileListParams, ), ), - model=VectorStoreFile, + cast_to=FileListResponse, ) async def delete( diff --git a/src/mixedbread/resources/vector_stores/vector_stores.py b/src/mixedbread/resources/vector_stores/vector_stores.py index 768923bf..96bf67de 100644 --- a/src/mixedbread/resources/vector_stores/vector_stores.py +++ b/src/mixedbread/resources/vector_stores/vector_stores.py @@ -31,10 +31,10 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ...pagination import SyncCursor, AsyncCursor -from ..._base_client import AsyncPaginator, make_request_options +from ..._base_client import make_request_options from ...types.vector_store import VectorStore from ...types.expires_after_param import ExpiresAfterParam +from ...types.vector_store_list_response import VectorStoreListResponse from ...types.vector_store_delete_response import VectorStoreDeleteResponse from ...types.vector_store_search_response import VectorStoreSearchResponse from ...types.vector_store_chunk_search_options_param import VectorStoreChunkSearchOptionsParam @@ -244,7 +244,8 @@ def list( self, *, limit: int | NotGiven = NOT_GIVEN, - cursor: Optional[str] | NotGiven = NOT_GIVEN, + after: Optional[str] | NotGiven = NOT_GIVEN, + before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, q: Optional[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -253,7 +254,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncCursor[VectorStore]: + ) -> VectorStoreListResponse: """ List all vector stores with optional search. @@ -263,11 +264,15 @@ def list( Returns: VectorStoreListResponse: The list of vector stores. Args: - limit: Maximum number of items to return per page + limit: Maximum number of items to return per page (1-100) - cursor: Cursor for pagination (base64 encoded cursor) + after: Cursor for forward pagination - get items after this position. Use last_cursor + from previous response. - include_total: Whether to include the total number of items + before: Cursor for backward pagination - get items before this position. Use + first_cursor from previous response. + + include_total: Whether to include total count in response (expensive operation) q: Search query for fuzzy matching over name and description fields @@ -279,9 +284,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - return self._get_api_list( + return self._get( "/v1/vector_stores", - page=SyncCursor[VectorStore], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -290,14 +294,15 @@ def list( query=maybe_transform( { "limit": limit, - "cursor": cursor, + "after": after, + "before": before, "include_total": include_total, "q": q, }, vector_store_list_params.VectorStoreListParams, ), ), - model=VectorStore, + cast_to=VectorStoreListResponse, ) def delete( @@ -687,11 +692,12 @@ async def update( cast_to=VectorStore, ) - def list( + async def list( self, *, limit: int | NotGiven = NOT_GIVEN, - cursor: Optional[str] | NotGiven = NOT_GIVEN, + after: Optional[str] | NotGiven = NOT_GIVEN, + before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, q: Optional[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -700,7 +706,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[VectorStore, AsyncCursor[VectorStore]]: + ) -> VectorStoreListResponse: """ List all vector stores with optional search. @@ -710,11 +716,15 @@ def list( Returns: VectorStoreListResponse: The list of vector stores. Args: - limit: Maximum number of items to return per page + limit: Maximum number of items to return per page (1-100) - cursor: Cursor for pagination (base64 encoded cursor) + after: Cursor for forward pagination - get items after this position. Use last_cursor + from previous response. - include_total: Whether to include the total number of items + before: Cursor for backward pagination - get items before this position. Use + first_cursor from previous response. + + include_total: Whether to include total count in response (expensive operation) q: Search query for fuzzy matching over name and description fields @@ -726,25 +736,25 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - return self._get_api_list( + return await self._get( "/v1/vector_stores", - page=AsyncCursor[VectorStore], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=maybe_transform( + query=await async_maybe_transform( { "limit": limit, - "cursor": cursor, + "after": after, + "before": before, "include_total": include_total, "q": q, }, vector_store_list_params.VectorStoreListParams, ), ), - model=VectorStore, + cast_to=VectorStoreListResponse, ) async def delete( diff --git a/src/mixedbread/types/__init__.py b/src/mixedbread/types/__init__.py index 5fead10f..a726eb8f 100644 --- a/src/mixedbread/types/__init__.py +++ b/src/mixedbread/types/__init__.py @@ -18,6 +18,7 @@ from .data_source_type import DataSourceType as DataSourceType from .file_list_params import FileListParams as FileListParams from .file_create_params import FileCreateParams as FileCreateParams +from .file_list_response import FileListResponse as FileListResponse from .file_update_params import FileUpdateParams as FileUpdateParams from .api_key_list_params import APIKeyListParams as APIKeyListParams from .client_embed_params import ClientEmbedParams as ClientEmbedParams @@ -35,10 +36,12 @@ from .notion_data_source_param import NotionDataSourceParam as NotionDataSourceParam from .vector_store_list_params import VectorStoreListParams as VectorStoreListParams from .data_source_create_params import DataSourceCreateParams as DataSourceCreateParams +from .data_source_list_response import DataSourceListResponse as DataSourceListResponse from .data_source_oauth2_params import DataSourceOauth2Params as DataSourceOauth2Params from .data_source_update_params import DataSourceUpdateParams as DataSourceUpdateParams from .embedding_create_response import EmbeddingCreateResponse as EmbeddingCreateResponse from .vector_store_create_params import VectorStoreCreateParams as VectorStoreCreateParams +from .vector_store_list_response import VectorStoreListResponse as VectorStoreListResponse from .vector_store_search_params import VectorStoreSearchParams as VectorStoreSearchParams from .vector_store_update_params import VectorStoreUpdateParams as VectorStoreUpdateParams from .data_source_delete_response import DataSourceDeleteResponse as DataSourceDeleteResponse diff --git a/src/mixedbread/types/data_source_list_params.py b/src/mixedbread/types/data_source_list_params.py index 86e27bce..07eb80f4 100644 --- a/src/mixedbread/types/data_source_list_params.py +++ b/src/mixedbread/types/data_source_list_params.py @@ -10,10 +10,19 @@ class DataSourceListParams(TypedDict, total=False): limit: int - """Maximum number of items to return per page""" + """Maximum number of items to return per page (1-100)""" - cursor: Optional[str] - """Cursor for pagination (base64 encoded cursor)""" + after: Optional[str] + """Cursor for forward pagination - get items after this position. + + Use last_cursor from previous response. + """ + + before: Optional[str] + """Cursor for backward pagination - get items before this position. + + Use first_cursor from previous response. + """ include_total: bool - """Whether to include the total number of items""" + """Whether to include total count in response (expensive operation)""" diff --git a/src/mixedbread/types/data_source_list_response.py b/src/mixedbread/types/data_source_list_response.py new file mode 100644 index 00000000..0c7298f5 --- /dev/null +++ b/src/mixedbread/types/data_source_list_response.py @@ -0,0 +1,69 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from .._models import BaseModel +from .data_source import DataSource + +__all__ = ["DataSourceListResponse", "Pagination"] + + +class Pagination(BaseModel): + has_more: bool + """ + Contextual direction-aware flag: True if more items exist in the requested + pagination direction. For 'after': more items after this page. For 'before': + more items before this page. + """ + + first_cursor: Optional[str] = None + """Cursor of the first item in this page. + + Use for backward pagination. None if page is empty. + """ + + last_cursor: Optional[str] = None + """Cursor of the last item in this page. + + Use for forward pagination. None if page is empty. + """ + + total: Optional[int] = None + """Total number of items available across all pages. + + Only included when include_total=true was requested. Expensive operation - use + sparingly. + """ + + +class DataSourceListResponse(BaseModel): + pagination: Pagination + """Response model for cursor-based pagination. + + Examples: Forward pagination response: { "has_more": true, "first_cursor": + "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMSIsImlkIjoiYWJjMTIzIn0=", "last_cursor": + "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMCIsImlkIjoieHl6Nzg5In0=", "total": null } + + Final page response: + { + "has_more": false, + "first_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOSIsImlkIjoibGFzdDEyMyJ9", + "last_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOCIsImlkIjoiZmluYWw0NTYifQ==", + "total": 42 + } + + Empty results: + { + "has_more": false, + "first_cursor": null, + "last_cursor": null, + "total": 0 + } + """ + + data: List[DataSource] + """The list of data sources""" + + object: Optional[Literal["list"]] = None + """The object type of the response""" diff --git a/src/mixedbread/types/data_sources/__init__.py b/src/mixedbread/types/data_sources/__init__.py index c35b6f2e..c925bcc7 100644 --- a/src/mixedbread/types/data_sources/__init__.py +++ b/src/mixedbread/types/data_sources/__init__.py @@ -5,5 +5,6 @@ from .connector_list_params import ConnectorListParams as ConnectorListParams from .data_source_connector import DataSourceConnector as DataSourceConnector from .connector_create_params import ConnectorCreateParams as ConnectorCreateParams +from .connector_list_response import ConnectorListResponse as ConnectorListResponse from .connector_update_params import ConnectorUpdateParams as ConnectorUpdateParams from .connector_delete_response import ConnectorDeleteResponse as ConnectorDeleteResponse diff --git a/src/mixedbread/types/data_sources/connector_list_params.py b/src/mixedbread/types/data_sources/connector_list_params.py index 09a46fd0..cb3da959 100644 --- a/src/mixedbread/types/data_sources/connector_list_params.py +++ b/src/mixedbread/types/data_sources/connector_list_params.py @@ -10,10 +10,19 @@ class ConnectorListParams(TypedDict, total=False): limit: int - """Maximum number of items to return per page""" + """Maximum number of items to return per page (1-100)""" - cursor: Optional[str] - """Cursor for pagination (base64 encoded cursor)""" + after: Optional[str] + """Cursor for forward pagination - get items after this position. + + Use last_cursor from previous response. + """ + + before: Optional[str] + """Cursor for backward pagination - get items before this position. + + Use first_cursor from previous response. + """ include_total: bool - """Whether to include the total number of items""" + """Whether to include total count in response (expensive operation)""" diff --git a/src/mixedbread/types/data_sources/connector_list_response.py b/src/mixedbread/types/data_sources/connector_list_response.py new file mode 100644 index 00000000..c6f2f388 --- /dev/null +++ b/src/mixedbread/types/data_sources/connector_list_response.py @@ -0,0 +1,69 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from ..._models import BaseModel +from .data_source_connector import DataSourceConnector + +__all__ = ["ConnectorListResponse", "Pagination"] + + +class Pagination(BaseModel): + has_more: bool + """ + Contextual direction-aware flag: True if more items exist in the requested + pagination direction. For 'after': more items after this page. For 'before': + more items before this page. + """ + + first_cursor: Optional[str] = None + """Cursor of the first item in this page. + + Use for backward pagination. None if page is empty. + """ + + last_cursor: Optional[str] = None + """Cursor of the last item in this page. + + Use for forward pagination. None if page is empty. + """ + + total: Optional[int] = None + """Total number of items available across all pages. + + Only included when include_total=true was requested. Expensive operation - use + sparingly. + """ + + +class ConnectorListResponse(BaseModel): + pagination: Pagination + """Response model for cursor-based pagination. + + Examples: Forward pagination response: { "has_more": true, "first_cursor": + "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMSIsImlkIjoiYWJjMTIzIn0=", "last_cursor": + "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMCIsImlkIjoieHl6Nzg5In0=", "total": null } + + Final page response: + { + "has_more": false, + "first_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOSIsImlkIjoibGFzdDEyMyJ9", + "last_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOCIsImlkIjoiZmluYWw0NTYifQ==", + "total": 42 + } + + Empty results: + { + "has_more": false, + "first_cursor": null, + "last_cursor": null, + "total": 0 + } + """ + + data: List[DataSourceConnector] + """The list of connectors""" + + object: Optional[Literal["list"]] = None + """The object type of the response""" diff --git a/src/mixedbread/types/file_list_params.py b/src/mixedbread/types/file_list_params.py index e7b9d891..83207e3d 100644 --- a/src/mixedbread/types/file_list_params.py +++ b/src/mixedbread/types/file_list_params.py @@ -10,10 +10,22 @@ class FileListParams(TypedDict, total=False): limit: int - """Maximum number of items to return per page""" + """Maximum number of items to return per page (1-100)""" - cursor: Optional[str] - """Cursor for pagination (base64 encoded cursor)""" + after: Optional[str] + """Cursor for forward pagination - get items after this position. + + Use last_cursor from previous response. + """ + + before: Optional[str] + """Cursor for backward pagination - get items before this position. + + Use first_cursor from previous response. + """ include_total: bool - """Whether to include the total number of items""" + """Whether to include total count in response (expensive operation)""" + + q: Optional[str] + """Search query for fuzzy matching over name and description fields""" diff --git a/src/mixedbread/types/file_list_response.py b/src/mixedbread/types/file_list_response.py new file mode 100644 index 00000000..c7322db2 --- /dev/null +++ b/src/mixedbread/types/file_list_response.py @@ -0,0 +1,69 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from .._models import BaseModel +from .file_object import FileObject + +__all__ = ["FileListResponse", "Pagination"] + + +class Pagination(BaseModel): + has_more: bool + """ + Contextual direction-aware flag: True if more items exist in the requested + pagination direction. For 'after': more items after this page. For 'before': + more items before this page. + """ + + first_cursor: Optional[str] = None + """Cursor of the first item in this page. + + Use for backward pagination. None if page is empty. + """ + + last_cursor: Optional[str] = None + """Cursor of the last item in this page. + + Use for forward pagination. None if page is empty. + """ + + total: Optional[int] = None + """Total number of items available across all pages. + + Only included when include_total=true was requested. Expensive operation - use + sparingly. + """ + + +class FileListResponse(BaseModel): + pagination: Pagination + """Response model for cursor-based pagination. + + Examples: Forward pagination response: { "has_more": true, "first_cursor": + "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMSIsImlkIjoiYWJjMTIzIn0=", "last_cursor": + "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMCIsImlkIjoieHl6Nzg5In0=", "total": null } + + Final page response: + { + "has_more": false, + "first_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOSIsImlkIjoibGFzdDEyMyJ9", + "last_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOCIsImlkIjoiZmluYWw0NTYifQ==", + "total": 42 + } + + Empty results: + { + "has_more": false, + "first_cursor": null, + "last_cursor": null, + "total": 0 + } + """ + + object: Optional[Literal["list"]] = None + """The object type of the response""" + + data: List[FileObject] + """The list of files""" diff --git a/src/mixedbread/types/parsing/job_list_params.py b/src/mixedbread/types/parsing/job_list_params.py index 92a016a9..979c53a3 100644 --- a/src/mixedbread/types/parsing/job_list_params.py +++ b/src/mixedbread/types/parsing/job_list_params.py @@ -2,18 +2,32 @@ from __future__ import annotations -from typing import Optional +from typing import List, Optional from typing_extensions import TypedDict +from .parsing_job_status import ParsingJobStatus + __all__ = ["JobListParams"] class JobListParams(TypedDict, total=False): limit: int - """Maximum number of items to return per page""" + """Maximum number of items to return per page (1-100)""" + + after: Optional[str] + """Cursor for forward pagination - get items after this position. + + Use last_cursor from previous response. + """ - cursor: Optional[str] - """Cursor for pagination (base64 encoded cursor)""" + before: Optional[str] + """Cursor for backward pagination - get items before this position. + + Use first_cursor from previous response. + """ include_total: bool - """Whether to include the total number of items""" + """Whether to include total count in response (expensive operation)""" + + statuses: Optional[List[ParsingJobStatus]] + """Status to filter by""" diff --git a/src/mixedbread/types/parsing/job_list_response.py b/src/mixedbread/types/parsing/job_list_response.py index 509d1620..3833e4f8 100644 --- a/src/mixedbread/types/parsing/job_list_response.py +++ b/src/mixedbread/types/parsing/job_list_response.py @@ -1,16 +1,44 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional +from typing import List, Optional from datetime import datetime from typing_extensions import Literal from ..._models import BaseModel from .parsing_job_status import ParsingJobStatus -__all__ = ["JobListResponse"] +__all__ = ["JobListResponse", "Pagination", "Data"] -class JobListResponse(BaseModel): +class Pagination(BaseModel): + has_more: bool + """ + Contextual direction-aware flag: True if more items exist in the requested + pagination direction. For 'after': more items after this page. For 'before': + more items before this page. + """ + + first_cursor: Optional[str] = None + """Cursor of the first item in this page. + + Use for backward pagination. None if page is empty. + """ + + last_cursor: Optional[str] = None + """Cursor of the last item in this page. + + Use for forward pagination. None if page is empty. + """ + + total: Optional[int] = None + """Total number of items available across all pages. + + Only included when include_total=true was requested. Expensive operation - use + sparingly. + """ + + +class Data(BaseModel): id: str """The ID of the job""" @@ -34,3 +62,35 @@ class JobListResponse(BaseModel): object: Optional[Literal["parsing_job"]] = None """The type of the object""" + + +class JobListResponse(BaseModel): + pagination: Pagination + """Response model for cursor-based pagination. + + Examples: Forward pagination response: { "has_more": true, "first_cursor": + "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMSIsImlkIjoiYWJjMTIzIn0=", "last_cursor": + "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMCIsImlkIjoieHl6Nzg5In0=", "total": null } + + Final page response: + { + "has_more": false, + "first_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOSIsImlkIjoibGFzdDEyMyJ9", + "last_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOCIsImlkIjoiZmluYWw0NTYifQ==", + "total": 42 + } + + Empty results: + { + "has_more": false, + "first_cursor": null, + "last_cursor": null, + "total": 0 + } + """ + + data: List[Data] + """The list of parsing jobs""" + + object: Optional[Literal["list"]] = None + """The object type of the response""" diff --git a/src/mixedbread/types/vector_store_list_params.py b/src/mixedbread/types/vector_store_list_params.py index d42f0b1f..cdad6947 100644 --- a/src/mixedbread/types/vector_store_list_params.py +++ b/src/mixedbread/types/vector_store_list_params.py @@ -10,13 +10,22 @@ class VectorStoreListParams(TypedDict, total=False): limit: int - """Maximum number of items to return per page""" + """Maximum number of items to return per page (1-100)""" - cursor: Optional[str] - """Cursor for pagination (base64 encoded cursor)""" + after: Optional[str] + """Cursor for forward pagination - get items after this position. + + Use last_cursor from previous response. + """ + + before: Optional[str] + """Cursor for backward pagination - get items before this position. + + Use first_cursor from previous response. + """ include_total: bool - """Whether to include the total number of items""" + """Whether to include total count in response (expensive operation)""" q: Optional[str] """Search query for fuzzy matching over name and description fields""" diff --git a/src/mixedbread/types/vector_store_list_response.py b/src/mixedbread/types/vector_store_list_response.py new file mode 100644 index 00000000..5ab4c798 --- /dev/null +++ b/src/mixedbread/types/vector_store_list_response.py @@ -0,0 +1,69 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from .._models import BaseModel +from .vector_store import VectorStore + +__all__ = ["VectorStoreListResponse", "Pagination"] + + +class Pagination(BaseModel): + has_more: bool + """ + Contextual direction-aware flag: True if more items exist in the requested + pagination direction. For 'after': more items after this page. For 'before': + more items before this page. + """ + + first_cursor: Optional[str] = None + """Cursor of the first item in this page. + + Use for backward pagination. None if page is empty. + """ + + last_cursor: Optional[str] = None + """Cursor of the last item in this page. + + Use for forward pagination. None if page is empty. + """ + + total: Optional[int] = None + """Total number of items available across all pages. + + Only included when include_total=true was requested. Expensive operation - use + sparingly. + """ + + +class VectorStoreListResponse(BaseModel): + pagination: Pagination + """Response model for cursor-based pagination. + + Examples: Forward pagination response: { "has_more": true, "first_cursor": + "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMSIsImlkIjoiYWJjMTIzIn0=", "last_cursor": + "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMCIsImlkIjoieHl6Nzg5In0=", "total": null } + + Final page response: + { + "has_more": false, + "first_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOSIsImlkIjoibGFzdDEyMyJ9", + "last_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOCIsImlkIjoiZmluYWw0NTYifQ==", + "total": 42 + } + + Empty results: + { + "has_more": false, + "first_cursor": null, + "last_cursor": null, + "total": 0 + } + """ + + object: Optional[Literal["list"]] = None + """The object type of the response""" + + data: List[VectorStore] + """The list of vector stores""" diff --git a/src/mixedbread/types/vector_stores/__init__.py b/src/mixedbread/types/vector_stores/__init__.py index 6ce1aafe..f0cee6f2 100644 --- a/src/mixedbread/types/vector_stores/__init__.py +++ b/src/mixedbread/types/vector_stores/__init__.py @@ -5,6 +5,7 @@ from .file_list_params import FileListParams as FileListParams from .vector_store_file import VectorStoreFile as VectorStoreFile from .file_create_params import FileCreateParams as FileCreateParams +from .file_list_response import FileListResponse as FileListResponse from .file_search_params import FileSearchParams as FileSearchParams from .rerank_config_param import RerankConfigParam as RerankConfigParam from .file_delete_response import FileDeleteResponse as FileDeleteResponse diff --git a/src/mixedbread/types/vector_stores/file_list_params.py b/src/mixedbread/types/vector_stores/file_list_params.py index 105ebeff..49fe0c08 100644 --- a/src/mixedbread/types/vector_stores/file_list_params.py +++ b/src/mixedbread/types/vector_stores/file_list_params.py @@ -12,13 +12,22 @@ class FileListParams(TypedDict, total=False): limit: int - """Maximum number of items to return per page""" + """Maximum number of items to return per page (1-100)""" - cursor: Optional[str] - """Cursor for pagination (base64 encoded cursor)""" + after: Optional[str] + """Cursor for forward pagination - get items after this position. + + Use last_cursor from previous response. + """ + + before: Optional[str] + """Cursor for backward pagination - get items before this position. + + Use first_cursor from previous response. + """ include_total: bool - """Whether to include the total number of items""" + """Whether to include total count in response (expensive operation)""" statuses: Optional[List[VectorStoreFileStatus]] """Status to filter by""" diff --git a/src/mixedbread/types/vector_stores/file_list_response.py b/src/mixedbread/types/vector_stores/file_list_response.py new file mode 100644 index 00000000..252d1c93 --- /dev/null +++ b/src/mixedbread/types/vector_stores/file_list_response.py @@ -0,0 +1,69 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from ..._models import BaseModel +from .vector_store_file import VectorStoreFile + +__all__ = ["FileListResponse", "Pagination"] + + +class Pagination(BaseModel): + has_more: bool + """ + Contextual direction-aware flag: True if more items exist in the requested + pagination direction. For 'after': more items after this page. For 'before': + more items before this page. + """ + + first_cursor: Optional[str] = None + """Cursor of the first item in this page. + + Use for backward pagination. None if page is empty. + """ + + last_cursor: Optional[str] = None + """Cursor of the last item in this page. + + Use for forward pagination. None if page is empty. + """ + + total: Optional[int] = None + """Total number of items available across all pages. + + Only included when include_total=true was requested. Expensive operation - use + sparingly. + """ + + +class FileListResponse(BaseModel): + pagination: Pagination + """Response model for cursor-based pagination. + + Examples: Forward pagination response: { "has_more": true, "first_cursor": + "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMSIsImlkIjoiYWJjMTIzIn0=", "last_cursor": + "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMCIsImlkIjoieHl6Nzg5In0=", "total": null } + + Final page response: + { + "has_more": false, + "first_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOSIsImlkIjoibGFzdDEyMyJ9", + "last_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOCIsImlkIjoiZmluYWw0NTYifQ==", + "total": 42 + } + + Empty results: + { + "has_more": false, + "first_cursor": null, + "last_cursor": null, + "total": 0 + } + """ + + object: Optional[Literal["list"]] = None + """The object type of the response""" + + data: List[VectorStoreFile] + """The list of vector store files""" diff --git a/tests/api_resources/data_sources/test_connectors.py b/tests/api_resources/data_sources/test_connectors.py index 352fed19..f0b2b2e3 100644 --- a/tests/api_resources/data_sources/test_connectors.py +++ b/tests/api_resources/data_sources/test_connectors.py @@ -9,9 +9,9 @@ from mixedbread import Mixedbread, AsyncMixedbread from tests.utils import assert_matches_type -from mixedbread.pagination import SyncCursor, AsyncCursor from mixedbread.types.data_sources import ( DataSourceConnector, + ConnectorListResponse, ConnectorDeleteResponse, ) @@ -188,17 +188,18 @@ def test_method_list(self, client: Mixedbread) -> None: connector = client.data_sources.connectors.list( data_source_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) - assert_matches_type(SyncCursor[DataSourceConnector], connector, path=["response"]) + assert_matches_type(ConnectorListResponse, connector, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Mixedbread) -> None: connector = client.data_sources.connectors.list( data_source_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - limit=1000, - cursor="cursor", - include_total=True, + limit=10, + after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + include_total=False, ) - assert_matches_type(SyncCursor[DataSourceConnector], connector, path=["response"]) + assert_matches_type(ConnectorListResponse, connector, path=["response"]) @parametrize def test_raw_response_list(self, client: Mixedbread) -> None: @@ -209,7 +210,7 @@ def test_raw_response_list(self, client: Mixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" connector = response.parse() - assert_matches_type(SyncCursor[DataSourceConnector], connector, path=["response"]) + assert_matches_type(ConnectorListResponse, connector, path=["response"]) @parametrize def test_streaming_response_list(self, client: Mixedbread) -> None: @@ -220,7 +221,7 @@ def test_streaming_response_list(self, client: Mixedbread) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" connector = response.parse() - assert_matches_type(SyncCursor[DataSourceConnector], connector, path=["response"]) + assert_matches_type(ConnectorListResponse, connector, path=["response"]) assert cast(Any, response.is_closed) is True @@ -452,17 +453,18 @@ async def test_method_list(self, async_client: AsyncMixedbread) -> None: connector = await async_client.data_sources.connectors.list( data_source_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) - assert_matches_type(AsyncCursor[DataSourceConnector], connector, path=["response"]) + assert_matches_type(ConnectorListResponse, connector, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) -> None: connector = await async_client.data_sources.connectors.list( data_source_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - limit=1000, - cursor="cursor", - include_total=True, + limit=10, + after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + include_total=False, ) - assert_matches_type(AsyncCursor[DataSourceConnector], connector, path=["response"]) + assert_matches_type(ConnectorListResponse, connector, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncMixedbread) -> None: @@ -473,7 +475,7 @@ async def test_raw_response_list(self, async_client: AsyncMixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" connector = await response.parse() - assert_matches_type(AsyncCursor[DataSourceConnector], connector, path=["response"]) + assert_matches_type(ConnectorListResponse, connector, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncMixedbread) -> None: @@ -484,7 +486,7 @@ async def test_streaming_response_list(self, async_client: AsyncMixedbread) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" connector = await response.parse() - assert_matches_type(AsyncCursor[DataSourceConnector], connector, path=["response"]) + assert_matches_type(ConnectorListResponse, connector, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/parsing/test_jobs.py b/tests/api_resources/parsing/test_jobs.py index 49f25077..5586218b 100644 --- a/tests/api_resources/parsing/test_jobs.py +++ b/tests/api_resources/parsing/test_jobs.py @@ -9,7 +9,6 @@ from mixedbread import Mixedbread, AsyncMixedbread from tests.utils import assert_matches_type -from mixedbread.pagination import SyncCursor, AsyncCursor from mixedbread.types.parsing import ( ParsingJob, JobListResponse, @@ -105,16 +104,18 @@ def test_path_params_retrieve(self, client: Mixedbread) -> None: @parametrize def test_method_list(self, client: Mixedbread) -> None: job = client.parsing.jobs.list() - assert_matches_type(SyncCursor[JobListResponse], job, path=["response"]) + assert_matches_type(JobListResponse, job, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Mixedbread) -> None: job = client.parsing.jobs.list( - limit=1000, - cursor="cursor", - include_total=True, + limit=10, + after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + include_total=False, + statuses=["pending", "in_progress"], ) - assert_matches_type(SyncCursor[JobListResponse], job, path=["response"]) + assert_matches_type(JobListResponse, job, path=["response"]) @parametrize def test_raw_response_list(self, client: Mixedbread) -> None: @@ -123,7 +124,7 @@ def test_raw_response_list(self, client: Mixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" job = response.parse() - assert_matches_type(SyncCursor[JobListResponse], job, path=["response"]) + assert_matches_type(JobListResponse, job, path=["response"]) @parametrize def test_streaming_response_list(self, client: Mixedbread) -> None: @@ -132,7 +133,7 @@ def test_streaming_response_list(self, client: Mixedbread) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" job = response.parse() - assert_matches_type(SyncCursor[JobListResponse], job, path=["response"]) + assert_matches_type(JobListResponse, job, path=["response"]) assert cast(Any, response.is_closed) is True @@ -301,16 +302,18 @@ async def test_path_params_retrieve(self, async_client: AsyncMixedbread) -> None @parametrize async def test_method_list(self, async_client: AsyncMixedbread) -> None: job = await async_client.parsing.jobs.list() - assert_matches_type(AsyncCursor[JobListResponse], job, path=["response"]) + assert_matches_type(JobListResponse, job, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) -> None: job = await async_client.parsing.jobs.list( - limit=1000, - cursor="cursor", - include_total=True, + limit=10, + after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + include_total=False, + statuses=["pending", "in_progress"], ) - assert_matches_type(AsyncCursor[JobListResponse], job, path=["response"]) + assert_matches_type(JobListResponse, job, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncMixedbread) -> None: @@ -319,7 +322,7 @@ async def test_raw_response_list(self, async_client: AsyncMixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" job = await response.parse() - assert_matches_type(AsyncCursor[JobListResponse], job, path=["response"]) + assert_matches_type(JobListResponse, job, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncMixedbread) -> None: @@ -328,7 +331,7 @@ async def test_streaming_response_list(self, async_client: AsyncMixedbread) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" job = await response.parse() - assert_matches_type(AsyncCursor[JobListResponse], job, path=["response"]) + assert_matches_type(JobListResponse, job, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_data_sources.py b/tests/api_resources/test_data_sources.py index 8c6cc68b..3e2075e0 100644 --- a/tests/api_resources/test_data_sources.py +++ b/tests/api_resources/test_data_sources.py @@ -11,9 +11,9 @@ from tests.utils import assert_matches_type from mixedbread.types import ( DataSource, + DataSourceListResponse, DataSourceDeleteResponse, ) -from mixedbread.pagination import SyncCursor, AsyncCursor base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -250,16 +250,17 @@ def test_path_params_update_overload_2(self, client: Mixedbread) -> None: @parametrize def test_method_list(self, client: Mixedbread) -> None: data_source = client.data_sources.list() - assert_matches_type(SyncCursor[DataSource], data_source, path=["response"]) + assert_matches_type(DataSourceListResponse, data_source, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Mixedbread) -> None: data_source = client.data_sources.list( - limit=1000, - cursor="cursor", - include_total=True, + limit=10, + after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + include_total=False, ) - assert_matches_type(SyncCursor[DataSource], data_source, path=["response"]) + assert_matches_type(DataSourceListResponse, data_source, path=["response"]) @parametrize def test_raw_response_list(self, client: Mixedbread) -> None: @@ -268,7 +269,7 @@ def test_raw_response_list(self, client: Mixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" data_source = response.parse() - assert_matches_type(SyncCursor[DataSource], data_source, path=["response"]) + assert_matches_type(DataSourceListResponse, data_source, path=["response"]) @parametrize def test_streaming_response_list(self, client: Mixedbread) -> None: @@ -277,7 +278,7 @@ def test_streaming_response_list(self, client: Mixedbread) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" data_source = response.parse() - assert_matches_type(SyncCursor[DataSource], data_source, path=["response"]) + assert_matches_type(DataSourceListResponse, data_source, path=["response"]) assert cast(Any, response.is_closed) is True @@ -554,16 +555,17 @@ async def test_path_params_update_overload_2(self, async_client: AsyncMixedbread @parametrize async def test_method_list(self, async_client: AsyncMixedbread) -> None: data_source = await async_client.data_sources.list() - assert_matches_type(AsyncCursor[DataSource], data_source, path=["response"]) + assert_matches_type(DataSourceListResponse, data_source, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) -> None: data_source = await async_client.data_sources.list( - limit=1000, - cursor="cursor", - include_total=True, + limit=10, + after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + include_total=False, ) - assert_matches_type(AsyncCursor[DataSource], data_source, path=["response"]) + assert_matches_type(DataSourceListResponse, data_source, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncMixedbread) -> None: @@ -572,7 +574,7 @@ async def test_raw_response_list(self, async_client: AsyncMixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" data_source = await response.parse() - assert_matches_type(AsyncCursor[DataSource], data_source, path=["response"]) + assert_matches_type(DataSourceListResponse, data_source, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncMixedbread) -> None: @@ -581,7 +583,7 @@ async def test_streaming_response_list(self, async_client: AsyncMixedbread) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" data_source = await response.parse() - assert_matches_type(AsyncCursor[DataSource], data_source, path=["response"]) + assert_matches_type(DataSourceListResponse, data_source, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_files.py b/tests/api_resources/test_files.py index 51deafef..5fb0941b 100644 --- a/tests/api_resources/test_files.py +++ b/tests/api_resources/test_files.py @@ -11,14 +11,17 @@ from mixedbread import Mixedbread, AsyncMixedbread from tests.utils import assert_matches_type -from mixedbread.types import FileObject, FileDeleteResponse +from mixedbread.types import ( + FileObject, + FileListResponse, + FileDeleteResponse, +) from mixedbread._response import ( BinaryAPIResponse, AsyncBinaryAPIResponse, StreamedBinaryAPIResponse, AsyncStreamedBinaryAPIResponse, ) -from mixedbread.pagination import SyncCursor, AsyncCursor base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -140,16 +143,18 @@ def test_path_params_update(self, client: Mixedbread) -> None: @parametrize def test_method_list(self, client: Mixedbread) -> None: file = client.files.list() - assert_matches_type(SyncCursor[FileObject], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Mixedbread) -> None: file = client.files.list( - limit=1000, - cursor="cursor", - include_total=True, + limit=10, + after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + include_total=False, + q="x", ) - assert_matches_type(SyncCursor[FileObject], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) @parametrize def test_raw_response_list(self, client: Mixedbread) -> None: @@ -158,7 +163,7 @@ def test_raw_response_list(self, client: Mixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" file = response.parse() - assert_matches_type(SyncCursor[FileObject], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) @parametrize def test_streaming_response_list(self, client: Mixedbread) -> None: @@ -167,7 +172,7 @@ def test_streaming_response_list(self, client: Mixedbread) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" file = response.parse() - assert_matches_type(SyncCursor[FileObject], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) assert cast(Any, response.is_closed) is True @@ -385,16 +390,18 @@ async def test_path_params_update(self, async_client: AsyncMixedbread) -> None: @parametrize async def test_method_list(self, async_client: AsyncMixedbread) -> None: file = await async_client.files.list() - assert_matches_type(AsyncCursor[FileObject], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) -> None: file = await async_client.files.list( - limit=1000, - cursor="cursor", - include_total=True, + limit=10, + after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + include_total=False, + q="x", ) - assert_matches_type(AsyncCursor[FileObject], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncMixedbread) -> None: @@ -403,7 +410,7 @@ async def test_raw_response_list(self, async_client: AsyncMixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" file = await response.parse() - assert_matches_type(AsyncCursor[FileObject], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncMixedbread) -> None: @@ -412,7 +419,7 @@ async def test_streaming_response_list(self, async_client: AsyncMixedbread) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" file = await response.parse() - assert_matches_type(AsyncCursor[FileObject], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_vector_stores.py b/tests/api_resources/test_vector_stores.py index 2fe4ab9f..f8a62782 100644 --- a/tests/api_resources/test_vector_stores.py +++ b/tests/api_resources/test_vector_stores.py @@ -11,11 +11,11 @@ from tests.utils import assert_matches_type from mixedbread.types import ( VectorStore, + VectorStoreListResponse, VectorStoreDeleteResponse, VectorStoreSearchResponse, VectorStoreQuestionAnsweringResponse, ) -from mixedbread.pagination import SyncCursor, AsyncCursor base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -161,17 +161,18 @@ def test_path_params_update(self, client: Mixedbread) -> None: @parametrize def test_method_list(self, client: Mixedbread) -> None: vector_store = client.vector_stores.list() - assert_matches_type(SyncCursor[VectorStore], vector_store, path=["response"]) + assert_matches_type(VectorStoreListResponse, vector_store, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Mixedbread) -> None: vector_store = client.vector_stores.list( - limit=1000, - cursor="cursor", - include_total=True, + limit=10, + after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + include_total=False, q="x", ) - assert_matches_type(SyncCursor[VectorStore], vector_store, path=["response"]) + assert_matches_type(VectorStoreListResponse, vector_store, path=["response"]) @parametrize def test_raw_response_list(self, client: Mixedbread) -> None: @@ -180,7 +181,7 @@ def test_raw_response_list(self, client: Mixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" vector_store = response.parse() - assert_matches_type(SyncCursor[VectorStore], vector_store, path=["response"]) + assert_matches_type(VectorStoreListResponse, vector_store, path=["response"]) @parametrize def test_streaming_response_list(self, client: Mixedbread) -> None: @@ -189,7 +190,7 @@ def test_streaming_response_list(self, client: Mixedbread) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" vector_store = response.parse() - assert_matches_type(SyncCursor[VectorStore], vector_store, path=["response"]) + assert_matches_type(VectorStoreListResponse, vector_store, path=["response"]) assert cast(Any, response.is_closed) is True @@ -548,17 +549,18 @@ async def test_path_params_update(self, async_client: AsyncMixedbread) -> None: @parametrize async def test_method_list(self, async_client: AsyncMixedbread) -> None: vector_store = await async_client.vector_stores.list() - assert_matches_type(AsyncCursor[VectorStore], vector_store, path=["response"]) + assert_matches_type(VectorStoreListResponse, vector_store, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) -> None: vector_store = await async_client.vector_stores.list( - limit=1000, - cursor="cursor", - include_total=True, + limit=10, + after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + include_total=False, q="x", ) - assert_matches_type(AsyncCursor[VectorStore], vector_store, path=["response"]) + assert_matches_type(VectorStoreListResponse, vector_store, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncMixedbread) -> None: @@ -567,7 +569,7 @@ async def test_raw_response_list(self, async_client: AsyncMixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" vector_store = await response.parse() - assert_matches_type(AsyncCursor[VectorStore], vector_store, path=["response"]) + assert_matches_type(VectorStoreListResponse, vector_store, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncMixedbread) -> None: @@ -576,7 +578,7 @@ async def test_streaming_response_list(self, async_client: AsyncMixedbread) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" vector_store = await response.parse() - assert_matches_type(AsyncCursor[VectorStore], vector_store, path=["response"]) + assert_matches_type(VectorStoreListResponse, vector_store, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/vector_stores/test_files.py b/tests/api_resources/vector_stores/test_files.py index 62eea508..e3122544 100644 --- a/tests/api_resources/vector_stores/test_files.py +++ b/tests/api_resources/vector_stores/test_files.py @@ -9,9 +9,9 @@ from mixedbread import Mixedbread, AsyncMixedbread from tests.utils import assert_matches_type -from mixedbread.pagination import SyncCursor, AsyncCursor from mixedbread.types.vector_stores import ( VectorStoreFile, + FileListResponse, FileDeleteResponse, FileSearchResponse, ) @@ -134,18 +134,19 @@ def test_method_list(self, client: Mixedbread) -> None: file = client.vector_stores.files.list( vector_store_identifier="vector_store_identifier", ) - assert_matches_type(SyncCursor[VectorStoreFile], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Mixedbread) -> None: file = client.vector_stores.files.list( vector_store_identifier="vector_store_identifier", - limit=1000, - cursor="cursor", - include_total=True, + limit=10, + after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + include_total=False, statuses=["pending", "in_progress"], ) - assert_matches_type(SyncCursor[VectorStoreFile], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) @parametrize def test_raw_response_list(self, client: Mixedbread) -> None: @@ -156,7 +157,7 @@ def test_raw_response_list(self, client: Mixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" file = response.parse() - assert_matches_type(SyncCursor[VectorStoreFile], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) @parametrize def test_streaming_response_list(self, client: Mixedbread) -> None: @@ -167,7 +168,7 @@ def test_streaming_response_list(self, client: Mixedbread) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" file = response.parse() - assert_matches_type(SyncCursor[VectorStoreFile], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) assert cast(Any, response.is_closed) is True @@ -436,18 +437,19 @@ async def test_method_list(self, async_client: AsyncMixedbread) -> None: file = await async_client.vector_stores.files.list( vector_store_identifier="vector_store_identifier", ) - assert_matches_type(AsyncCursor[VectorStoreFile], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) -> None: file = await async_client.vector_stores.files.list( vector_store_identifier="vector_store_identifier", - limit=1000, - cursor="cursor", - include_total=True, + limit=10, + after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", + include_total=False, statuses=["pending", "in_progress"], ) - assert_matches_type(AsyncCursor[VectorStoreFile], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncMixedbread) -> None: @@ -458,7 +460,7 @@ async def test_raw_response_list(self, async_client: AsyncMixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" file = await response.parse() - assert_matches_type(AsyncCursor[VectorStoreFile], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncMixedbread) -> None: @@ -469,7 +471,7 @@ async def test_streaming_response_list(self, async_client: AsyncMixedbread) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" file = await response.parse() - assert_matches_type(AsyncCursor[VectorStoreFile], file, path=["response"]) + assert_matches_type(FileListResponse, file, path=["response"]) assert cast(Any, response.is_closed) is True From c6371032b1859a021315bfffe91a7cdad09bfd57 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 10:25:28 +0000 Subject: [PATCH 2/3] feat(api): update via SDK Studio --- .stats.yml | 6 +-- src/mixedbread/pagination.py | 46 +++++++++++----- .../resources/data_sources/connectors.py | 32 ++++-------- .../resources/data_sources/data_sources.py | 32 ++++-------- src/mixedbread/resources/files.py | 40 ++++---------- src/mixedbread/resources/parsing/jobs.py | 41 ++++----------- .../resources/vector_stores/files.py | 32 ++++-------- .../resources/vector_stores/vector_stores.py | 32 ++++-------- .../types/data_source_list_params.py | 17 ++---- .../types/data_source_list_response.py | 52 ++++--------------- .../data_sources/connector_list_params.py | 17 ++---- .../data_sources/connector_list_response.py | 52 ++++--------------- src/mixedbread/types/file_list_params.py | 20 ++----- src/mixedbread/types/file_list_response.py | 52 ++++--------------- .../types/parsing/job_list_params.py | 24 ++------- .../types/parsing/job_list_response.py | 52 ++++--------------- .../types/vector_store_list_params.py | 17 ++---- .../types/vector_store_list_response.py | 52 ++++--------------- .../types/vector_stores/file_list_params.py | 17 ++---- .../types/vector_stores/file_list_response.py | 52 ++++--------------- .../data_sources/test_connectors.py | 14 +++-- tests/api_resources/parsing/test_jobs.py | 16 +++--- tests/api_resources/test_data_sources.py | 14 +++-- tests/api_resources/test_files.py | 16 +++--- tests/api_resources/test_vector_stores.py | 14 +++-- .../api_resources/vector_stores/test_files.py | 14 +++-- 26 files changed, 216 insertions(+), 557 deletions(-) diff --git a/.stats.yml b/.stats.yml index f49ee495..0866595f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 49 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-fe968780e87b8a5ff65ea009ade00fb0e27e951f7ce16d39a2ae0957740add45.yml -openapi_spec_hash: 9a29ae1bb05df2061e321b0d1adef675 -config_hash: 95ffbc5d87b528d727a944596d7cf051 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-7361ed078e7c394c7cb1da4a3e2f3417d4498de5eea648cf9d3caaa0ddf85f78.yml +openapi_spec_hash: 4ae67ffa9040c2d5a87026df79c1feaf +config_hash: 6098ac28bc4ec5be0c546035a5d81394 diff --git a/src/mixedbread/pagination.py b/src/mixedbread/pagination.py index 59f96e24..a983df1e 100644 --- a/src/mixedbread/pagination.py +++ b/src/mixedbread/pagination.py @@ -97,14 +97,12 @@ def next_page_info(self) -> Optional[PageInfo]: class CursorPagination(BaseModel): - next_cursor: Optional[str] = None + first_cursor: Optional[str] = None - prev_cursor: Optional[str] = None + last_cursor: Optional[str] = None has_more: Optional[bool] = None - has_prev: Optional[bool] = None - total: Optional[int] = None @@ -132,14 +130,24 @@ def has_next_page(self) -> bool: @override def next_page_info(self) -> Optional[PageInfo]: - next_cursor = None + if self._options.params.get("before"): + first_cursor = None + if self.pagination is not None: + if self.pagination.first_cursor is not None: + first_cursor = self.pagination.first_cursor + if not first_cursor: + return None + + return PageInfo(params={"before": first_cursor}) + + last_cursor = None if self.pagination is not None: - if self.pagination.next_cursor is not None: - next_cursor = self.pagination.next_cursor - if not next_cursor: + if self.pagination.last_cursor is not None: + last_cursor = self.pagination.last_cursor + if not last_cursor: return None - return PageInfo(params={"cursor": next_cursor}) + return PageInfo(params={"after": last_cursor}) class AsyncCursor(BaseAsyncPage[_T], BasePage[_T], Generic[_T]): @@ -166,11 +174,21 @@ def has_next_page(self) -> bool: @override def next_page_info(self) -> Optional[PageInfo]: - next_cursor = None + if self._options.params.get("before"): + first_cursor = None + if self.pagination is not None: + if self.pagination.first_cursor is not None: + first_cursor = self.pagination.first_cursor + if not first_cursor: + return None + + return PageInfo(params={"before": first_cursor}) + + last_cursor = None if self.pagination is not None: - if self.pagination.next_cursor is not None: - next_cursor = self.pagination.next_cursor - if not next_cursor: + if self.pagination.last_cursor is not None: + last_cursor = self.pagination.last_cursor + if not last_cursor: return None - return PageInfo(params={"cursor": next_cursor}) + return PageInfo(params={"after": last_cursor}) diff --git a/src/mixedbread/resources/data_sources/connectors.py b/src/mixedbread/resources/data_sources/connectors.py index f333b4e9..fd110748 100644 --- a/src/mixedbread/resources/data_sources/connectors.py +++ b/src/mixedbread/resources/data_sources/connectors.py @@ -237,8 +237,7 @@ def list( data_source_id: str, *, limit: int | NotGiven = NOT_GIVEN, - after: Optional[str] | NotGiven = NOT_GIVEN, - before: Optional[str] | NotGiven = NOT_GIVEN, + cursor: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -258,15 +257,11 @@ def list( Args: data_source_id: The ID of the data source to get connectors for - limit: Maximum number of items to return per page (1-100) + limit: Maximum number of items to return per page - after: Cursor for forward pagination - get items after this position. Use last_cursor - from previous response. + cursor: Cursor for pagination (base64 encoded cursor) - before: Cursor for backward pagination - get items before this position. Use - first_cursor from previous response. - - include_total: Whether to include total count in response (expensive operation) + include_total: Whether to include the total number of items extra_headers: Send extra headers @@ -288,8 +283,7 @@ def list( query=maybe_transform( { "limit": limit, - "after": after, - "before": before, + "cursor": cursor, "include_total": include_total, }, connector_list_params.ConnectorListParams, @@ -556,8 +550,7 @@ async def list( data_source_id: str, *, limit: int | NotGiven = NOT_GIVEN, - after: Optional[str] | NotGiven = NOT_GIVEN, - before: Optional[str] | NotGiven = NOT_GIVEN, + cursor: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -577,15 +570,11 @@ async def list( Args: data_source_id: The ID of the data source to get connectors for - limit: Maximum number of items to return per page (1-100) - - after: Cursor for forward pagination - get items after this position. Use last_cursor - from previous response. + limit: Maximum number of items to return per page - before: Cursor for backward pagination - get items before this position. Use - first_cursor from previous response. + cursor: Cursor for pagination (base64 encoded cursor) - include_total: Whether to include total count in response (expensive operation) + include_total: Whether to include the total number of items extra_headers: Send extra headers @@ -607,8 +596,7 @@ async def list( query=await async_maybe_transform( { "limit": limit, - "after": after, - "before": before, + "cursor": cursor, "include_total": include_total, }, connector_list_params.ConnectorListParams, diff --git a/src/mixedbread/resources/data_sources/data_sources.py b/src/mixedbread/resources/data_sources/data_sources.py index c8a83074..d82939db 100644 --- a/src/mixedbread/resources/data_sources/data_sources.py +++ b/src/mixedbread/resources/data_sources/data_sources.py @@ -356,8 +356,7 @@ def list( self, *, limit: int | NotGiven = NOT_GIVEN, - after: Optional[str] | NotGiven = NOT_GIVEN, - before: Optional[str] | NotGiven = NOT_GIVEN, + cursor: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -372,15 +371,11 @@ def list( Returns: The list of data sources. Args: - limit: Maximum number of items to return per page (1-100) + limit: Maximum number of items to return per page - after: Cursor for forward pagination - get items after this position. Use last_cursor - from previous response. + cursor: Cursor for pagination (base64 encoded cursor) - before: Cursor for backward pagination - get items before this position. Use - first_cursor from previous response. - - include_total: Whether to include total count in response (expensive operation) + include_total: Whether to include the total number of items extra_headers: Send extra headers @@ -400,8 +395,7 @@ def list( query=maybe_transform( { "limit": limit, - "after": after, - "before": before, + "cursor": cursor, "include_total": include_total, }, data_source_list_params.DataSourceListParams, @@ -762,8 +756,7 @@ async def list( self, *, limit: int | NotGiven = NOT_GIVEN, - after: Optional[str] | NotGiven = NOT_GIVEN, - before: Optional[str] | NotGiven = NOT_GIVEN, + cursor: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -778,15 +771,11 @@ async def list( Returns: The list of data sources. Args: - limit: Maximum number of items to return per page (1-100) - - after: Cursor for forward pagination - get items after this position. Use last_cursor - from previous response. + limit: Maximum number of items to return per page - before: Cursor for backward pagination - get items before this position. Use - first_cursor from previous response. + cursor: Cursor for pagination (base64 encoded cursor) - include_total: Whether to include total count in response (expensive operation) + include_total: Whether to include the total number of items extra_headers: Send extra headers @@ -806,8 +795,7 @@ async def list( query=await async_maybe_transform( { "limit": limit, - "after": after, - "before": before, + "cursor": cursor, "include_total": include_total, }, data_source_list_params.DataSourceListParams, diff --git a/src/mixedbread/resources/files.py b/src/mixedbread/resources/files.py index 10f6a213..207336ac 100644 --- a/src/mixedbread/resources/files.py +++ b/src/mixedbread/resources/files.py @@ -191,10 +191,8 @@ def list( self, *, limit: int | NotGiven = NOT_GIVEN, - after: Optional[str] | NotGiven = NOT_GIVEN, - before: Optional[str] | NotGiven = NOT_GIVEN, + cursor: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, - q: Optional[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -210,17 +208,11 @@ def list( Returns: A list of files belonging to the user. Args: - limit: Maximum number of items to return per page (1-100) + limit: Maximum number of items to return per page - after: Cursor for forward pagination - get items after this position. Use last_cursor - from previous response. + cursor: Cursor for pagination (base64 encoded cursor) - before: Cursor for backward pagination - get items before this position. Use - first_cursor from previous response. - - include_total: Whether to include total count in response (expensive operation) - - q: Search query for fuzzy matching over name and description fields + include_total: Whether to include the total number of items extra_headers: Send extra headers @@ -240,10 +232,8 @@ def list( query=maybe_transform( { "limit": limit, - "after": after, - "before": before, + "cursor": cursor, "include_total": include_total, - "q": q, }, file_list_params.FileListParams, ), @@ -489,10 +479,8 @@ async def list( self, *, limit: int | NotGiven = NOT_GIVEN, - after: Optional[str] | NotGiven = NOT_GIVEN, - before: Optional[str] | NotGiven = NOT_GIVEN, + cursor: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, - q: Optional[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -508,17 +496,11 @@ async def list( Returns: A list of files belonging to the user. Args: - limit: Maximum number of items to return per page (1-100) - - after: Cursor for forward pagination - get items after this position. Use last_cursor - from previous response. - - before: Cursor for backward pagination - get items before this position. Use - first_cursor from previous response. + limit: Maximum number of items to return per page - include_total: Whether to include total count in response (expensive operation) + cursor: Cursor for pagination (base64 encoded cursor) - q: Search query for fuzzy matching over name and description fields + include_total: Whether to include the total number of items extra_headers: Send extra headers @@ -538,10 +520,8 @@ async def list( query=await async_maybe_transform( { "limit": limit, - "after": after, - "before": before, + "cursor": cursor, "include_total": include_total, - "q": q, }, file_list_params.FileListParams, ), diff --git a/src/mixedbread/resources/parsing/jobs.py b/src/mixedbread/resources/parsing/jobs.py index f439ac92..1cbe0b7a 100644 --- a/src/mixedbread/resources/parsing/jobs.py +++ b/src/mixedbread/resources/parsing/jobs.py @@ -26,7 +26,6 @@ from ...types.parsing.return_format import ReturnFormat from ...types.parsing.chunking_strategy import ChunkingStrategy from ...types.parsing.job_list_response import JobListResponse -from ...types.parsing.parsing_job_status import ParsingJobStatus from ...types.parsing.job_delete_response import JobDeleteResponse __all__ = ["JobsResource", "AsyncJobsResource"] @@ -154,10 +153,8 @@ def list( self, *, limit: int | NotGiven = NOT_GIVEN, - after: Optional[str] | NotGiven = NOT_GIVEN, - before: Optional[str] | NotGiven = NOT_GIVEN, + cursor: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, - statuses: Optional[List[ParsingJobStatus]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -174,17 +171,11 @@ def list( Returns: List of parsing jobs with pagination. Args: - limit: Maximum number of items to return per page (1-100) + limit: Maximum number of items to return per page - after: Cursor for forward pagination - get items after this position. Use last_cursor - from previous response. + cursor: Cursor for pagination (base64 encoded cursor) - before: Cursor for backward pagination - get items before this position. Use - first_cursor from previous response. - - include_total: Whether to include total count in response (expensive operation) - - statuses: Status to filter by + include_total: Whether to include the total number of items extra_headers: Send extra headers @@ -204,10 +195,8 @@ def list( query=maybe_transform( { "limit": limit, - "after": after, - "before": before, + "cursor": cursor, "include_total": include_total, - "statuses": statuses, }, job_list_params.JobListParams, ), @@ -573,10 +562,8 @@ async def list( self, *, limit: int | NotGiven = NOT_GIVEN, - after: Optional[str] | NotGiven = NOT_GIVEN, - before: Optional[str] | NotGiven = NOT_GIVEN, + cursor: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, - statuses: Optional[List[ParsingJobStatus]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -593,17 +580,11 @@ async def list( Returns: List of parsing jobs with pagination. Args: - limit: Maximum number of items to return per page (1-100) - - after: Cursor for forward pagination - get items after this position. Use last_cursor - from previous response. - - before: Cursor for backward pagination - get items before this position. Use - first_cursor from previous response. + limit: Maximum number of items to return per page - include_total: Whether to include total count in response (expensive operation) + cursor: Cursor for pagination (base64 encoded cursor) - statuses: Status to filter by + include_total: Whether to include the total number of items extra_headers: Send extra headers @@ -623,10 +604,8 @@ async def list( query=await async_maybe_transform( { "limit": limit, - "after": after, - "before": before, + "cursor": cursor, "include_total": include_total, - "statuses": statuses, }, job_list_params.JobListParams, ), diff --git a/src/mixedbread/resources/vector_stores/files.py b/src/mixedbread/resources/vector_stores/files.py index 6bd6b1c7..b84f574f 100644 --- a/src/mixedbread/resources/vector_stores/files.py +++ b/src/mixedbread/resources/vector_stores/files.py @@ -160,8 +160,7 @@ def list( vector_store_identifier: str, *, limit: int | NotGiven = NOT_GIVEN, - after: Optional[str] | NotGiven = NOT_GIVEN, - before: Optional[str] | NotGiven = NOT_GIVEN, + cursor: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, statuses: Optional[List[VectorStoreFileStatus]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -182,15 +181,11 @@ def list( Args: vector_store_identifier: The ID or name of the vector store - limit: Maximum number of items to return per page (1-100) + limit: Maximum number of items to return per page - after: Cursor for forward pagination - get items after this position. Use last_cursor - from previous response. + cursor: Cursor for pagination (base64 encoded cursor) - before: Cursor for backward pagination - get items before this position. Use - first_cursor from previous response. - - include_total: Whether to include total count in response (expensive operation) + include_total: Whether to include the total number of items statuses: Status to filter by @@ -216,8 +211,7 @@ def list( query=maybe_transform( { "limit": limit, - "after": after, - "before": before, + "cursor": cursor, "include_total": include_total, "statuses": statuses, }, @@ -588,8 +582,7 @@ async def list( vector_store_identifier: str, *, limit: int | NotGiven = NOT_GIVEN, - after: Optional[str] | NotGiven = NOT_GIVEN, - before: Optional[str] | NotGiven = NOT_GIVEN, + cursor: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, statuses: Optional[List[VectorStoreFileStatus]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -610,15 +603,11 @@ async def list( Args: vector_store_identifier: The ID or name of the vector store - limit: Maximum number of items to return per page (1-100) - - after: Cursor for forward pagination - get items after this position. Use last_cursor - from previous response. + limit: Maximum number of items to return per page - before: Cursor for backward pagination - get items before this position. Use - first_cursor from previous response. + cursor: Cursor for pagination (base64 encoded cursor) - include_total: Whether to include total count in response (expensive operation) + include_total: Whether to include the total number of items statuses: Status to filter by @@ -644,8 +633,7 @@ async def list( query=await async_maybe_transform( { "limit": limit, - "after": after, - "before": before, + "cursor": cursor, "include_total": include_total, "statuses": statuses, }, diff --git a/src/mixedbread/resources/vector_stores/vector_stores.py b/src/mixedbread/resources/vector_stores/vector_stores.py index 96bf67de..21f559df 100644 --- a/src/mixedbread/resources/vector_stores/vector_stores.py +++ b/src/mixedbread/resources/vector_stores/vector_stores.py @@ -244,8 +244,7 @@ def list( self, *, limit: int | NotGiven = NOT_GIVEN, - after: Optional[str] | NotGiven = NOT_GIVEN, - before: Optional[str] | NotGiven = NOT_GIVEN, + cursor: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, q: Optional[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -264,15 +263,11 @@ def list( Returns: VectorStoreListResponse: The list of vector stores. Args: - limit: Maximum number of items to return per page (1-100) + limit: Maximum number of items to return per page - after: Cursor for forward pagination - get items after this position. Use last_cursor - from previous response. + cursor: Cursor for pagination (base64 encoded cursor) - before: Cursor for backward pagination - get items before this position. Use - first_cursor from previous response. - - include_total: Whether to include total count in response (expensive operation) + include_total: Whether to include the total number of items q: Search query for fuzzy matching over name and description fields @@ -294,8 +289,7 @@ def list( query=maybe_transform( { "limit": limit, - "after": after, - "before": before, + "cursor": cursor, "include_total": include_total, "q": q, }, @@ -696,8 +690,7 @@ async def list( self, *, limit: int | NotGiven = NOT_GIVEN, - after: Optional[str] | NotGiven = NOT_GIVEN, - before: Optional[str] | NotGiven = NOT_GIVEN, + cursor: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, q: Optional[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -716,15 +709,11 @@ async def list( Returns: VectorStoreListResponse: The list of vector stores. Args: - limit: Maximum number of items to return per page (1-100) - - after: Cursor for forward pagination - get items after this position. Use last_cursor - from previous response. + limit: Maximum number of items to return per page - before: Cursor for backward pagination - get items before this position. Use - first_cursor from previous response. + cursor: Cursor for pagination (base64 encoded cursor) - include_total: Whether to include total count in response (expensive operation) + include_total: Whether to include the total number of items q: Search query for fuzzy matching over name and description fields @@ -746,8 +735,7 @@ async def list( query=await async_maybe_transform( { "limit": limit, - "after": after, - "before": before, + "cursor": cursor, "include_total": include_total, "q": q, }, diff --git a/src/mixedbread/types/data_source_list_params.py b/src/mixedbread/types/data_source_list_params.py index 07eb80f4..86e27bce 100644 --- a/src/mixedbread/types/data_source_list_params.py +++ b/src/mixedbread/types/data_source_list_params.py @@ -10,19 +10,10 @@ class DataSourceListParams(TypedDict, total=False): limit: int - """Maximum number of items to return per page (1-100)""" + """Maximum number of items to return per page""" - after: Optional[str] - """Cursor for forward pagination - get items after this position. - - Use last_cursor from previous response. - """ - - before: Optional[str] - """Cursor for backward pagination - get items before this position. - - Use first_cursor from previous response. - """ + cursor: Optional[str] + """Cursor for pagination (base64 encoded cursor)""" include_total: bool - """Whether to include total count in response (expensive operation)""" + """Whether to include the total number of items""" diff --git a/src/mixedbread/types/data_source_list_response.py b/src/mixedbread/types/data_source_list_response.py index 0c7298f5..4c95ef7a 100644 --- a/src/mixedbread/types/data_source_list_response.py +++ b/src/mixedbread/types/data_source_list_response.py @@ -10,57 +10,25 @@ class Pagination(BaseModel): - has_more: bool - """ - Contextual direction-aware flag: True if more items exist in the requested - pagination direction. For 'after': more items after this page. For 'before': - more items before this page. - """ - - first_cursor: Optional[str] = None - """Cursor of the first item in this page. + next_cursor: Optional[str] = None + """Cursor for the next page, null if no more pages""" - Use for backward pagination. None if page is empty. - """ + prev_cursor: Optional[str] = None + """Cursor for the previous page, null if no previous pages""" - last_cursor: Optional[str] = None - """Cursor of the last item in this page. + has_more: bool + """Whether there are more items available""" - Use for forward pagination. None if page is empty. - """ + has_prev: bool + """Whether there are previous items available""" total: Optional[int] = None - """Total number of items available across all pages. - - Only included when include_total=true was requested. Expensive operation - use - sparingly. - """ + """Total number of items available""" class DataSourceListResponse(BaseModel): pagination: Pagination - """Response model for cursor-based pagination. - - Examples: Forward pagination response: { "has_more": true, "first_cursor": - "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMSIsImlkIjoiYWJjMTIzIn0=", "last_cursor": - "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMCIsImlkIjoieHl6Nzg5In0=", "total": null } - - Final page response: - { - "has_more": false, - "first_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOSIsImlkIjoibGFzdDEyMyJ9", - "last_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOCIsImlkIjoiZmluYWw0NTYifQ==", - "total": 42 - } - - Empty results: - { - "has_more": false, - "first_cursor": null, - "last_cursor": null, - "total": 0 - } - """ + """Response model for cursor-based pagination.""" data: List[DataSource] """The list of data sources""" diff --git a/src/mixedbread/types/data_sources/connector_list_params.py b/src/mixedbread/types/data_sources/connector_list_params.py index cb3da959..09a46fd0 100644 --- a/src/mixedbread/types/data_sources/connector_list_params.py +++ b/src/mixedbread/types/data_sources/connector_list_params.py @@ -10,19 +10,10 @@ class ConnectorListParams(TypedDict, total=False): limit: int - """Maximum number of items to return per page (1-100)""" + """Maximum number of items to return per page""" - after: Optional[str] - """Cursor for forward pagination - get items after this position. - - Use last_cursor from previous response. - """ - - before: Optional[str] - """Cursor for backward pagination - get items before this position. - - Use first_cursor from previous response. - """ + cursor: Optional[str] + """Cursor for pagination (base64 encoded cursor)""" include_total: bool - """Whether to include total count in response (expensive operation)""" + """Whether to include the total number of items""" diff --git a/src/mixedbread/types/data_sources/connector_list_response.py b/src/mixedbread/types/data_sources/connector_list_response.py index c6f2f388..e63cf824 100644 --- a/src/mixedbread/types/data_sources/connector_list_response.py +++ b/src/mixedbread/types/data_sources/connector_list_response.py @@ -10,57 +10,25 @@ class Pagination(BaseModel): - has_more: bool - """ - Contextual direction-aware flag: True if more items exist in the requested - pagination direction. For 'after': more items after this page. For 'before': - more items before this page. - """ - - first_cursor: Optional[str] = None - """Cursor of the first item in this page. + next_cursor: Optional[str] = None + """Cursor for the next page, null if no more pages""" - Use for backward pagination. None if page is empty. - """ + prev_cursor: Optional[str] = None + """Cursor for the previous page, null if no previous pages""" - last_cursor: Optional[str] = None - """Cursor of the last item in this page. + has_more: bool + """Whether there are more items available""" - Use for forward pagination. None if page is empty. - """ + has_prev: bool + """Whether there are previous items available""" total: Optional[int] = None - """Total number of items available across all pages. - - Only included when include_total=true was requested. Expensive operation - use - sparingly. - """ + """Total number of items available""" class ConnectorListResponse(BaseModel): pagination: Pagination - """Response model for cursor-based pagination. - - Examples: Forward pagination response: { "has_more": true, "first_cursor": - "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMSIsImlkIjoiYWJjMTIzIn0=", "last_cursor": - "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMCIsImlkIjoieHl6Nzg5In0=", "total": null } - - Final page response: - { - "has_more": false, - "first_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOSIsImlkIjoibGFzdDEyMyJ9", - "last_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOCIsImlkIjoiZmluYWw0NTYifQ==", - "total": 42 - } - - Empty results: - { - "has_more": false, - "first_cursor": null, - "last_cursor": null, - "total": 0 - } - """ + """Response model for cursor-based pagination.""" data: List[DataSourceConnector] """The list of connectors""" diff --git a/src/mixedbread/types/file_list_params.py b/src/mixedbread/types/file_list_params.py index 83207e3d..e7b9d891 100644 --- a/src/mixedbread/types/file_list_params.py +++ b/src/mixedbread/types/file_list_params.py @@ -10,22 +10,10 @@ class FileListParams(TypedDict, total=False): limit: int - """Maximum number of items to return per page (1-100)""" + """Maximum number of items to return per page""" - after: Optional[str] - """Cursor for forward pagination - get items after this position. - - Use last_cursor from previous response. - """ - - before: Optional[str] - """Cursor for backward pagination - get items before this position. - - Use first_cursor from previous response. - """ + cursor: Optional[str] + """Cursor for pagination (base64 encoded cursor)""" include_total: bool - """Whether to include total count in response (expensive operation)""" - - q: Optional[str] - """Search query for fuzzy matching over name and description fields""" + """Whether to include the total number of items""" diff --git a/src/mixedbread/types/file_list_response.py b/src/mixedbread/types/file_list_response.py index c7322db2..b66a56ad 100644 --- a/src/mixedbread/types/file_list_response.py +++ b/src/mixedbread/types/file_list_response.py @@ -10,57 +10,25 @@ class Pagination(BaseModel): - has_more: bool - """ - Contextual direction-aware flag: True if more items exist in the requested - pagination direction. For 'after': more items after this page. For 'before': - more items before this page. - """ - - first_cursor: Optional[str] = None - """Cursor of the first item in this page. + next_cursor: Optional[str] = None + """Cursor for the next page, null if no more pages""" - Use for backward pagination. None if page is empty. - """ + prev_cursor: Optional[str] = None + """Cursor for the previous page, null if no previous pages""" - last_cursor: Optional[str] = None - """Cursor of the last item in this page. + has_more: bool + """Whether there are more items available""" - Use for forward pagination. None if page is empty. - """ + has_prev: bool + """Whether there are previous items available""" total: Optional[int] = None - """Total number of items available across all pages. - - Only included when include_total=true was requested. Expensive operation - use - sparingly. - """ + """Total number of items available""" class FileListResponse(BaseModel): pagination: Pagination - """Response model for cursor-based pagination. - - Examples: Forward pagination response: { "has_more": true, "first_cursor": - "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMSIsImlkIjoiYWJjMTIzIn0=", "last_cursor": - "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMCIsImlkIjoieHl6Nzg5In0=", "total": null } - - Final page response: - { - "has_more": false, - "first_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOSIsImlkIjoibGFzdDEyMyJ9", - "last_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOCIsImlkIjoiZmluYWw0NTYifQ==", - "total": 42 - } - - Empty results: - { - "has_more": false, - "first_cursor": null, - "last_cursor": null, - "total": 0 - } - """ + """Response model for cursor-based pagination.""" object: Optional[Literal["list"]] = None """The object type of the response""" diff --git a/src/mixedbread/types/parsing/job_list_params.py b/src/mixedbread/types/parsing/job_list_params.py index 979c53a3..92a016a9 100644 --- a/src/mixedbread/types/parsing/job_list_params.py +++ b/src/mixedbread/types/parsing/job_list_params.py @@ -2,32 +2,18 @@ from __future__ import annotations -from typing import List, Optional +from typing import Optional from typing_extensions import TypedDict -from .parsing_job_status import ParsingJobStatus - __all__ = ["JobListParams"] class JobListParams(TypedDict, total=False): limit: int - """Maximum number of items to return per page (1-100)""" - - after: Optional[str] - """Cursor for forward pagination - get items after this position. - - Use last_cursor from previous response. - """ + """Maximum number of items to return per page""" - before: Optional[str] - """Cursor for backward pagination - get items before this position. - - Use first_cursor from previous response. - """ + cursor: Optional[str] + """Cursor for pagination (base64 encoded cursor)""" include_total: bool - """Whether to include total count in response (expensive operation)""" - - statuses: Optional[List[ParsingJobStatus]] - """Status to filter by""" + """Whether to include the total number of items""" diff --git a/src/mixedbread/types/parsing/job_list_response.py b/src/mixedbread/types/parsing/job_list_response.py index 3833e4f8..b0aea3f0 100644 --- a/src/mixedbread/types/parsing/job_list_response.py +++ b/src/mixedbread/types/parsing/job_list_response.py @@ -11,31 +11,20 @@ class Pagination(BaseModel): - has_more: bool - """ - Contextual direction-aware flag: True if more items exist in the requested - pagination direction. For 'after': more items after this page. For 'before': - more items before this page. - """ - - first_cursor: Optional[str] = None - """Cursor of the first item in this page. + next_cursor: Optional[str] = None + """Cursor for the next page, null if no more pages""" - Use for backward pagination. None if page is empty. - """ + prev_cursor: Optional[str] = None + """Cursor for the previous page, null if no previous pages""" - last_cursor: Optional[str] = None - """Cursor of the last item in this page. + has_more: bool + """Whether there are more items available""" - Use for forward pagination. None if page is empty. - """ + has_prev: bool + """Whether there are previous items available""" total: Optional[int] = None - """Total number of items available across all pages. - - Only included when include_total=true was requested. Expensive operation - use - sparingly. - """ + """Total number of items available""" class Data(BaseModel): @@ -66,28 +55,7 @@ class Data(BaseModel): class JobListResponse(BaseModel): pagination: Pagination - """Response model for cursor-based pagination. - - Examples: Forward pagination response: { "has_more": true, "first_cursor": - "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMSIsImlkIjoiYWJjMTIzIn0=", "last_cursor": - "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMCIsImlkIjoieHl6Nzg5In0=", "total": null } - - Final page response: - { - "has_more": false, - "first_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOSIsImlkIjoibGFzdDEyMyJ9", - "last_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOCIsImlkIjoiZmluYWw0NTYifQ==", - "total": 42 - } - - Empty results: - { - "has_more": false, - "first_cursor": null, - "last_cursor": null, - "total": 0 - } - """ + """Response model for cursor-based pagination.""" data: List[Data] """The list of parsing jobs""" diff --git a/src/mixedbread/types/vector_store_list_params.py b/src/mixedbread/types/vector_store_list_params.py index cdad6947..d42f0b1f 100644 --- a/src/mixedbread/types/vector_store_list_params.py +++ b/src/mixedbread/types/vector_store_list_params.py @@ -10,22 +10,13 @@ class VectorStoreListParams(TypedDict, total=False): limit: int - """Maximum number of items to return per page (1-100)""" + """Maximum number of items to return per page""" - after: Optional[str] - """Cursor for forward pagination - get items after this position. - - Use last_cursor from previous response. - """ - - before: Optional[str] - """Cursor for backward pagination - get items before this position. - - Use first_cursor from previous response. - """ + cursor: Optional[str] + """Cursor for pagination (base64 encoded cursor)""" include_total: bool - """Whether to include total count in response (expensive operation)""" + """Whether to include the total number of items""" q: Optional[str] """Search query for fuzzy matching over name and description fields""" diff --git a/src/mixedbread/types/vector_store_list_response.py b/src/mixedbread/types/vector_store_list_response.py index 5ab4c798..54664f1a 100644 --- a/src/mixedbread/types/vector_store_list_response.py +++ b/src/mixedbread/types/vector_store_list_response.py @@ -10,57 +10,25 @@ class Pagination(BaseModel): - has_more: bool - """ - Contextual direction-aware flag: True if more items exist in the requested - pagination direction. For 'after': more items after this page. For 'before': - more items before this page. - """ - - first_cursor: Optional[str] = None - """Cursor of the first item in this page. + next_cursor: Optional[str] = None + """Cursor for the next page, null if no more pages""" - Use for backward pagination. None if page is empty. - """ + prev_cursor: Optional[str] = None + """Cursor for the previous page, null if no previous pages""" - last_cursor: Optional[str] = None - """Cursor of the last item in this page. + has_more: bool + """Whether there are more items available""" - Use for forward pagination. None if page is empty. - """ + has_prev: bool + """Whether there are previous items available""" total: Optional[int] = None - """Total number of items available across all pages. - - Only included when include_total=true was requested. Expensive operation - use - sparingly. - """ + """Total number of items available""" class VectorStoreListResponse(BaseModel): pagination: Pagination - """Response model for cursor-based pagination. - - Examples: Forward pagination response: { "has_more": true, "first_cursor": - "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMSIsImlkIjoiYWJjMTIzIn0=", "last_cursor": - "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMCIsImlkIjoieHl6Nzg5In0=", "total": null } - - Final page response: - { - "has_more": false, - "first_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOSIsImlkIjoibGFzdDEyMyJ9", - "last_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOCIsImlkIjoiZmluYWw0NTYifQ==", - "total": 42 - } - - Empty results: - { - "has_more": false, - "first_cursor": null, - "last_cursor": null, - "total": 0 - } - """ + """Response model for cursor-based pagination.""" object: Optional[Literal["list"]] = None """The object type of the response""" diff --git a/src/mixedbread/types/vector_stores/file_list_params.py b/src/mixedbread/types/vector_stores/file_list_params.py index 49fe0c08..105ebeff 100644 --- a/src/mixedbread/types/vector_stores/file_list_params.py +++ b/src/mixedbread/types/vector_stores/file_list_params.py @@ -12,22 +12,13 @@ class FileListParams(TypedDict, total=False): limit: int - """Maximum number of items to return per page (1-100)""" + """Maximum number of items to return per page""" - after: Optional[str] - """Cursor for forward pagination - get items after this position. - - Use last_cursor from previous response. - """ - - before: Optional[str] - """Cursor for backward pagination - get items before this position. - - Use first_cursor from previous response. - """ + cursor: Optional[str] + """Cursor for pagination (base64 encoded cursor)""" include_total: bool - """Whether to include total count in response (expensive operation)""" + """Whether to include the total number of items""" statuses: Optional[List[VectorStoreFileStatus]] """Status to filter by""" diff --git a/src/mixedbread/types/vector_stores/file_list_response.py b/src/mixedbread/types/vector_stores/file_list_response.py index 252d1c93..e566de6b 100644 --- a/src/mixedbread/types/vector_stores/file_list_response.py +++ b/src/mixedbread/types/vector_stores/file_list_response.py @@ -10,57 +10,25 @@ class Pagination(BaseModel): - has_more: bool - """ - Contextual direction-aware flag: True if more items exist in the requested - pagination direction. For 'after': more items after this page. For 'before': - more items before this page. - """ - - first_cursor: Optional[str] = None - """Cursor of the first item in this page. + next_cursor: Optional[str] = None + """Cursor for the next page, null if no more pages""" - Use for backward pagination. None if page is empty. - """ + prev_cursor: Optional[str] = None + """Cursor for the previous page, null if no previous pages""" - last_cursor: Optional[str] = None - """Cursor of the last item in this page. + has_more: bool + """Whether there are more items available""" - Use for forward pagination. None if page is empty. - """ + has_prev: bool + """Whether there are previous items available""" total: Optional[int] = None - """Total number of items available across all pages. - - Only included when include_total=true was requested. Expensive operation - use - sparingly. - """ + """Total number of items available""" class FileListResponse(BaseModel): pagination: Pagination - """Response model for cursor-based pagination. - - Examples: Forward pagination response: { "has_more": true, "first_cursor": - "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMSIsImlkIjoiYWJjMTIzIn0=", "last_cursor": - "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMCIsImlkIjoieHl6Nzg5In0=", "total": null } - - Final page response: - { - "has_more": false, - "first_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOSIsImlkIjoibGFzdDEyMyJ9", - "last_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0yOCIsImlkIjoiZmluYWw0NTYifQ==", - "total": 42 - } - - Empty results: - { - "has_more": false, - "first_cursor": null, - "last_cursor": null, - "total": 0 - } - """ + """Response model for cursor-based pagination.""" object: Optional[Literal["list"]] = None """The object type of the response""" diff --git a/tests/api_resources/data_sources/test_connectors.py b/tests/api_resources/data_sources/test_connectors.py index f0b2b2e3..f32aeafb 100644 --- a/tests/api_resources/data_sources/test_connectors.py +++ b/tests/api_resources/data_sources/test_connectors.py @@ -194,10 +194,9 @@ def test_method_list(self, client: Mixedbread) -> None: def test_method_list_with_all_params(self, client: Mixedbread) -> None: connector = client.data_sources.connectors.list( data_source_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - limit=10, - after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - include_total=False, + limit=1000, + cursor="cursor", + include_total=True, ) assert_matches_type(ConnectorListResponse, connector, path=["response"]) @@ -459,10 +458,9 @@ async def test_method_list(self, async_client: AsyncMixedbread) -> None: async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) -> None: connector = await async_client.data_sources.connectors.list( data_source_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - limit=10, - after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - include_total=False, + limit=1000, + cursor="cursor", + include_total=True, ) assert_matches_type(ConnectorListResponse, connector, path=["response"]) diff --git a/tests/api_resources/parsing/test_jobs.py b/tests/api_resources/parsing/test_jobs.py index 5586218b..7b22a611 100644 --- a/tests/api_resources/parsing/test_jobs.py +++ b/tests/api_resources/parsing/test_jobs.py @@ -109,11 +109,9 @@ def test_method_list(self, client: Mixedbread) -> None: @parametrize def test_method_list_with_all_params(self, client: Mixedbread) -> None: job = client.parsing.jobs.list( - limit=10, - after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - include_total=False, - statuses=["pending", "in_progress"], + limit=1000, + cursor="cursor", + include_total=True, ) assert_matches_type(JobListResponse, job, path=["response"]) @@ -307,11 +305,9 @@ async def test_method_list(self, async_client: AsyncMixedbread) -> None: @parametrize async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) -> None: job = await async_client.parsing.jobs.list( - limit=10, - after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - include_total=False, - statuses=["pending", "in_progress"], + limit=1000, + cursor="cursor", + include_total=True, ) assert_matches_type(JobListResponse, job, path=["response"]) diff --git a/tests/api_resources/test_data_sources.py b/tests/api_resources/test_data_sources.py index 3e2075e0..94ad5653 100644 --- a/tests/api_resources/test_data_sources.py +++ b/tests/api_resources/test_data_sources.py @@ -255,10 +255,9 @@ def test_method_list(self, client: Mixedbread) -> None: @parametrize def test_method_list_with_all_params(self, client: Mixedbread) -> None: data_source = client.data_sources.list( - limit=10, - after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - include_total=False, + limit=1000, + cursor="cursor", + include_total=True, ) assert_matches_type(DataSourceListResponse, data_source, path=["response"]) @@ -560,10 +559,9 @@ async def test_method_list(self, async_client: AsyncMixedbread) -> None: @parametrize async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) -> None: data_source = await async_client.data_sources.list( - limit=10, - after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - include_total=False, + limit=1000, + cursor="cursor", + include_total=True, ) assert_matches_type(DataSourceListResponse, data_source, path=["response"]) diff --git a/tests/api_resources/test_files.py b/tests/api_resources/test_files.py index 5fb0941b..9fdc535d 100644 --- a/tests/api_resources/test_files.py +++ b/tests/api_resources/test_files.py @@ -148,11 +148,9 @@ def test_method_list(self, client: Mixedbread) -> None: @parametrize def test_method_list_with_all_params(self, client: Mixedbread) -> None: file = client.files.list( - limit=10, - after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - include_total=False, - q="x", + limit=1000, + cursor="cursor", + include_total=True, ) assert_matches_type(FileListResponse, file, path=["response"]) @@ -395,11 +393,9 @@ async def test_method_list(self, async_client: AsyncMixedbread) -> None: @parametrize async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) -> None: file = await async_client.files.list( - limit=10, - after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - include_total=False, - q="x", + limit=1000, + cursor="cursor", + include_total=True, ) assert_matches_type(FileListResponse, file, path=["response"]) diff --git a/tests/api_resources/test_vector_stores.py b/tests/api_resources/test_vector_stores.py index f8a62782..4be0efcc 100644 --- a/tests/api_resources/test_vector_stores.py +++ b/tests/api_resources/test_vector_stores.py @@ -166,10 +166,9 @@ def test_method_list(self, client: Mixedbread) -> None: @parametrize def test_method_list_with_all_params(self, client: Mixedbread) -> None: vector_store = client.vector_stores.list( - limit=10, - after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - include_total=False, + limit=1000, + cursor="cursor", + include_total=True, q="x", ) assert_matches_type(VectorStoreListResponse, vector_store, path=["response"]) @@ -554,10 +553,9 @@ async def test_method_list(self, async_client: AsyncMixedbread) -> None: @parametrize async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) -> None: vector_store = await async_client.vector_stores.list( - limit=10, - after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - include_total=False, + limit=1000, + cursor="cursor", + include_total=True, q="x", ) assert_matches_type(VectorStoreListResponse, vector_store, path=["response"]) diff --git a/tests/api_resources/vector_stores/test_files.py b/tests/api_resources/vector_stores/test_files.py index e3122544..3b56df7d 100644 --- a/tests/api_resources/vector_stores/test_files.py +++ b/tests/api_resources/vector_stores/test_files.py @@ -140,10 +140,9 @@ def test_method_list(self, client: Mixedbread) -> None: def test_method_list_with_all_params(self, client: Mixedbread) -> None: file = client.vector_stores.files.list( vector_store_identifier="vector_store_identifier", - limit=10, - after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - include_total=False, + limit=1000, + cursor="cursor", + include_total=True, statuses=["pending", "in_progress"], ) assert_matches_type(FileListResponse, file, path=["response"]) @@ -443,10 +442,9 @@ async def test_method_list(self, async_client: AsyncMixedbread) -> None: async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) -> None: file = await async_client.vector_stores.files.list( vector_store_identifier="vector_store_identifier", - limit=10, - after="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", - include_total=False, + limit=1000, + cursor="cursor", + include_total=True, statuses=["pending", "in_progress"], ) assert_matches_type(FileListResponse, file, path=["response"]) From c564b264277cf7b14728dde903c079725b869312 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 10:25:46 +0000 Subject: [PATCH 3/3] release: 0.14.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 9 +++++++++ pyproject.toml | 2 +- src/mixedbread/_version.py | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f80776a4..a26ebfc1 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.13.2" + ".": "0.14.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index dbfcf8d4..63e099ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.14.0 (2025-06-30) + +Full Changelog: [v0.13.2...v0.14.0](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.13.2...v0.14.0) + +### Features + +* **api:** api update ([a6dd8b2](https://github.com/mixedbread-ai/mixedbread-python/commit/a6dd8b2449e5f204d198f657bacf4113af1474ff)) +* **api:** update via SDK Studio ([c637103](https://github.com/mixedbread-ai/mixedbread-python/commit/c6371032b1859a021315bfffe91a7cdad09bfd57)) + ## 0.13.2 (2025-06-30) Full Changelog: [v0.13.1...v0.13.2](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.13.1...v0.13.2) diff --git a/pyproject.toml b/pyproject.toml index 41a2114a..ecd51575 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mixedbread" -version = "0.13.2" +version = "0.14.0" description = "The official Python library for the Mixedbread API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/mixedbread/_version.py b/src/mixedbread/_version.py index 405a4a61..0b58cc93 100644 --- a/src/mixedbread/_version.py +++ b/src/mixedbread/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "mixedbread" -__version__ = "0.13.2" # x-release-please-version +__version__ = "0.14.0" # x-release-please-version