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/.stats.yml b/.stats.yml index 26f6a536..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-7361ed078e7c394c7cb1da4a3e2f3417d4498de5eea648cf9d3caaa0ddf85f78.yml openapi_spec_hash: 4ae67ffa9040c2d5a87026df79c1feaf -config_hash: 95ffbc5d87b528d727a944596d7cf051 +config_hash: 6098ac28bc4ec5be0c546035a5d81394 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/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/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 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 dbc11701..fd110748 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"] @@ -245,7 +245,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. @@ -273,9 +273,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, @@ -290,7 +289,7 @@ def list( connector_list_params.ConnectorListParams, ), ), - model=DataSourceConnector, + cast_to=ConnectorListResponse, ) def delete( @@ -546,7 +545,7 @@ async def update( cast_to=DataSourceConnector, ) - def list( + async def list( self, data_source_id: str, *, @@ -559,7 +558,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. @@ -587,15 +586,14 @@ 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, @@ -604,7 +602,7 @@ def list( 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..d82939db 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"] @@ -364,7 +364,7 @@ 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. @@ -385,9 +385,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, @@ -402,7 +401,7 @@ def list( data_source_list_params.DataSourceListParams, ), ), - model=DataSource, + cast_to=DataSourceListResponse, ) def delete( @@ -753,7 +752,7 @@ async def update( cast_to=DataSource, ) - def list( + async def list( self, *, limit: int | NotGiven = NOT_GIVEN, @@ -765,7 +764,7 @@ 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. @@ -786,15 +785,14 @@ 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, @@ -803,7 +801,7 @@ def list( 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..207336ac 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"] @@ -199,7 +199,7 @@ def list( 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. @@ -222,9 +222,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, @@ -239,7 +238,7 @@ def list( file_list_params.FileListParams, ), ), - model=FileObject, + cast_to=FileListResponse, ) def delete( @@ -476,7 +475,7 @@ async def update( cast_to=FileObject, ) - def list( + async def list( self, *, limit: int | NotGiven = NOT_GIVEN, @@ -488,7 +487,7 @@ def list( 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. @@ -511,15 +510,14 @@ 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, @@ -528,7 +526,7 @@ def list( 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..1cbe0b7a 100644 --- a/src/mixedbread/resources/parsing/jobs.py +++ b/src/mixedbread/resources/parsing/jobs.py @@ -19,8 +19,7 @@ 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 @@ -162,7 +161,7 @@ def list( 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. @@ -186,9 +185,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, @@ -203,7 +201,7 @@ def list( job_list_params.JobListParams, ), ), - model=JobListResponse, + cast_to=JobListResponse, ) def delete( @@ -560,7 +558,7 @@ async def retrieve( cast_to=ParsingJob, ) - def list( + async def list( self, *, limit: int | NotGiven = NOT_GIVEN, @@ -572,7 +570,7 @@ def list( 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. @@ -596,15 +594,14 @@ 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, @@ -613,7 +610,7 @@ def list( 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..b84f574f 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 @@ -169,7 +169,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. @@ -201,9 +201,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, @@ -219,7 +218,7 @@ def list( file_list_params.FileListParams, ), ), - model=VectorStoreFile, + cast_to=FileListResponse, ) def delete( @@ -578,7 +577,7 @@ async def retrieve( cast_to=VectorStoreFile, ) - def list( + async def list( self, vector_store_identifier: str, *, @@ -592,7 +591,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. @@ -624,15 +623,14 @@ 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, @@ -642,7 +640,7 @@ def list( 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..21f559df 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 @@ -253,7 +253,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. @@ -279,9 +279,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, @@ -297,7 +296,7 @@ def list( vector_store_list_params.VectorStoreListParams, ), ), - model=VectorStore, + cast_to=VectorStoreListResponse, ) def delete( @@ -687,7 +686,7 @@ async def update( cast_to=VectorStore, ) - def list( + async def list( self, *, limit: int | NotGiven = NOT_GIVEN, @@ -700,7 +699,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. @@ -726,15 +725,14 @@ 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, @@ -744,7 +742,7 @@ def list( 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_response.py b/src/mixedbread/types/data_source_list_response.py new file mode 100644 index 00000000..4c95ef7a --- /dev/null +++ b/src/mixedbread/types/data_source_list_response.py @@ -0,0 +1,37 @@ +# 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): + next_cursor: Optional[str] = None + """Cursor for the next page, null if no more pages""" + + prev_cursor: Optional[str] = None + """Cursor for the previous page, null if no previous pages""" + + has_more: bool + """Whether there are more items available""" + + has_prev: bool + """Whether there are previous items available""" + + total: Optional[int] = None + """Total number of items available""" + + +class DataSourceListResponse(BaseModel): + pagination: Pagination + """Response model for cursor-based pagination.""" + + 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_response.py b/src/mixedbread/types/data_sources/connector_list_response.py new file mode 100644 index 00000000..e63cf824 --- /dev/null +++ b/src/mixedbread/types/data_sources/connector_list_response.py @@ -0,0 +1,37 @@ +# 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): + next_cursor: Optional[str] = None + """Cursor for the next page, null if no more pages""" + + prev_cursor: Optional[str] = None + """Cursor for the previous page, null if no previous pages""" + + has_more: bool + """Whether there are more items available""" + + has_prev: bool + """Whether there are previous items available""" + + total: Optional[int] = None + """Total number of items available""" + + +class ConnectorListResponse(BaseModel): + pagination: Pagination + """Response model for cursor-based pagination.""" + + 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_response.py b/src/mixedbread/types/file_list_response.py new file mode 100644 index 00000000..b66a56ad --- /dev/null +++ b/src/mixedbread/types/file_list_response.py @@ -0,0 +1,37 @@ +# 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): + next_cursor: Optional[str] = None + """Cursor for the next page, null if no more pages""" + + prev_cursor: Optional[str] = None + """Cursor for the previous page, null if no previous pages""" + + has_more: bool + """Whether there are more items available""" + + has_prev: bool + """Whether there are previous items available""" + + total: Optional[int] = None + """Total number of items available""" + + +class FileListResponse(BaseModel): + pagination: Pagination + """Response model for cursor-based pagination.""" + + 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_response.py b/src/mixedbread/types/parsing/job_list_response.py index 509d1620..b0aea3f0 100644 --- a/src/mixedbread/types/parsing/job_list_response.py +++ b/src/mixedbread/types/parsing/job_list_response.py @@ -1,16 +1,33 @@ # 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): + next_cursor: Optional[str] = None + """Cursor for the next page, null if no more pages""" + + prev_cursor: Optional[str] = None + """Cursor for the previous page, null if no previous pages""" + + has_more: bool + """Whether there are more items available""" + + has_prev: bool + """Whether there are previous items available""" + + total: Optional[int] = None + """Total number of items available""" + + +class Data(BaseModel): id: str """The ID of the job""" @@ -34,3 +51,14 @@ 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.""" + + 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_response.py b/src/mixedbread/types/vector_store_list_response.py new file mode 100644 index 00000000..54664f1a --- /dev/null +++ b/src/mixedbread/types/vector_store_list_response.py @@ -0,0 +1,37 @@ +# 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): + next_cursor: Optional[str] = None + """Cursor for the next page, null if no more pages""" + + prev_cursor: Optional[str] = None + """Cursor for the previous page, null if no previous pages""" + + has_more: bool + """Whether there are more items available""" + + has_prev: bool + """Whether there are previous items available""" + + total: Optional[int] = None + """Total number of items available""" + + +class VectorStoreListResponse(BaseModel): + pagination: Pagination + """Response model for cursor-based pagination.""" + + 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_response.py b/src/mixedbread/types/vector_stores/file_list_response.py new file mode 100644 index 00000000..e566de6b --- /dev/null +++ b/src/mixedbread/types/vector_stores/file_list_response.py @@ -0,0 +1,37 @@ +# 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): + next_cursor: Optional[str] = None + """Cursor for the next page, null if no more pages""" + + prev_cursor: Optional[str] = None + """Cursor for the previous page, null if no previous pages""" + + has_more: bool + """Whether there are more items available""" + + has_prev: bool + """Whether there are previous items available""" + + total: Optional[int] = None + """Total number of items available""" + + +class FileListResponse(BaseModel): + pagination: Pagination + """Response model for cursor-based pagination.""" + + 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..f32aeafb 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,7 +188,7 @@ 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: @@ -198,7 +198,7 @@ def test_method_list_with_all_params(self, client: Mixedbread) -> None: cursor="cursor", include_total=True, ) - 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 +209,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 +220,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,7 +452,7 @@ 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: @@ -462,7 +462,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) cursor="cursor", include_total=True, ) - 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 +473,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 +484,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..7b22a611 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,7 +104,7 @@ 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: @@ -114,7 +113,7 @@ def test_method_list_with_all_params(self, client: Mixedbread) -> None: cursor="cursor", include_total=True, ) - 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 +122,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 +131,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,7 +300,7 @@ 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: @@ -310,7 +309,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) cursor="cursor", include_total=True, ) - 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 +318,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 +327,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..94ad5653 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,7 +250,7 @@ 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: @@ -259,7 +259,7 @@ def test_method_list_with_all_params(self, client: Mixedbread) -> None: cursor="cursor", include_total=True, ) - 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 +268,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 +277,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,7 +554,7 @@ 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: @@ -563,7 +563,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) cursor="cursor", include_total=True, ) - 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 +572,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 +581,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..9fdc535d 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,7 +143,7 @@ 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: @@ -149,7 +152,7 @@ def test_method_list_with_all_params(self, client: Mixedbread) -> None: cursor="cursor", include_total=True, ) - 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 +161,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 +170,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,7 +388,7 @@ 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: @@ -394,7 +397,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) cursor="cursor", include_total=True, ) - 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 +406,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 +415,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..4be0efcc 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,7 +161,7 @@ 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: @@ -171,7 +171,7 @@ def test_method_list_with_all_params(self, client: Mixedbread) -> None: include_total=True, 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 +180,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 +189,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,7 +548,7 @@ 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: @@ -558,7 +558,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) include_total=True, 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 +567,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 +576,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..3b56df7d 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,7 +134,7 @@ 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: @@ -145,7 +145,7 @@ def test_method_list_with_all_params(self, client: Mixedbread) -> None: include_total=True, 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 +156,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 +167,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,7 +436,7 @@ 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: @@ -447,7 +447,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) include_total=True, 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 +458,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 +469,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