diff --git a/.gitignore b/.gitignore index 87797408..95ceb189 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .prism.log -.vscode _dev __pycache__ diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 86b0e83d..cb9d2541 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.21.0" + ".": "0.22.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 6c0eef6a..5b9fef09 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-1d55ef57d17d780e3863936f62874ea7f378ed78a30edc0eb4119d9cb3009dc6.yml -openapi_spec_hash: 1c5f41ebd04ef8a89bc257e11d7cb122 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-7f00f72937a82d3184ef21bc91c848984d4c3bacf910a671ac2c5736025d862c.yml +openapi_spec_hash: 5c59e45eebcbb99551e308b194ec6243 config_hash: 810d9712d3d0d6a1f50d71a25511d8a7 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..5b010307 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.analysis.importFormat": "relative", +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c031273..769210bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## 0.22.0 (2025-08-06) + +Full Changelog: [v0.21.0...v0.22.0](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.21.0...v0.22.0) + +### Features + +* **api:** api update ([2c7f796](https://github.com/mixedbread-ai/mixedbread-python/commit/2c7f796de4143fd921495633b9726d81332aa57d)) +* **client:** support file upload requests ([42d18d6](https://github.com/mixedbread-ai/mixedbread-python/commit/42d18d6cd2e38cd4555dd6cc91a424951c8d8b48)) + + +### Chores + +* **internal:** fix ruff target version ([c1d947c](https://github.com/mixedbread-ai/mixedbread-python/commit/c1d947c8b2fd3862cf8cf281239ebf7b69adddab)) +* **internal:** update examples ([b57870e](https://github.com/mixedbread-ai/mixedbread-python/commit/b57870e1d3017a09d0f91dc4feed6e447b3f459d)) +* **project:** add settings file for vscode ([bd31e87](https://github.com/mixedbread-ai/mixedbread-python/commit/bd31e87164a5da07bd649a22feb318d5ef64e0fe)) + ## 0.21.0 (2025-07-23) Full Changelog: [v0.20.1...v0.21.0](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.20.1...v0.21.0) diff --git a/api.md b/api.md index 257f5d28..39630d7d 100644 --- a/api.md +++ b/api.md @@ -1,7 +1,7 @@ # Shared Types ```python -from mixedbread.types import SearchFilter, SearchFilterCondition, Usage +from mixedbread.types import SearchFilterCondition, Usage ``` # Mixedbread diff --git a/pyproject.toml b/pyproject.toml index 1de0d3c4..fc70b2dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mixedbread" -version = "0.21.0" +version = "0.22.0" description = "The official Python library for the Mixedbread API" dynamic = ["readme"] license = "Apache-2.0" @@ -159,7 +159,7 @@ reportPrivateUsage = false [tool.ruff] line-length = 120 output-format = "grouped" -target-version = "py37" +target-version = "py38" [tool.ruff.format] docstring-code-format = true diff --git a/src/mixedbread/_base_client.py b/src/mixedbread/_base_client.py index 40ee1387..d8edf54b 100644 --- a/src/mixedbread/_base_client.py +++ b/src/mixedbread/_base_client.py @@ -532,7 +532,10 @@ def _build_request( is_body_allowed = options.method.lower() != "get" if is_body_allowed: - kwargs["json"] = json_data if is_given(json_data) else None + if isinstance(json_data, bytes): + kwargs["content"] = json_data + else: + kwargs["json"] = json_data if is_given(json_data) else None kwargs["files"] = files else: headers.pop("Content-Type", None) diff --git a/src/mixedbread/_files.py b/src/mixedbread/_files.py index 3bef9c34..729ea489 100644 --- a/src/mixedbread/_files.py +++ b/src/mixedbread/_files.py @@ -69,12 +69,12 @@ def _transform_file(file: FileTypes) -> HttpxFileTypes: return file if is_tuple_t(file): - return (file[0], _read_file_content(file[1]), *file[2:]) + return (file[0], read_file_content(file[1]), *file[2:]) raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple") -def _read_file_content(file: FileContent) -> HttpxFileContent: +def read_file_content(file: FileContent) -> HttpxFileContent: if isinstance(file, os.PathLike): return pathlib.Path(file).read_bytes() return file @@ -111,12 +111,12 @@ async def _async_transform_file(file: FileTypes) -> HttpxFileTypes: return file if is_tuple_t(file): - return (file[0], await _async_read_file_content(file[1]), *file[2:]) + return (file[0], await async_read_file_content(file[1]), *file[2:]) raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple") -async def _async_read_file_content(file: FileContent) -> HttpxFileContent: +async def async_read_file_content(file: FileContent) -> HttpxFileContent: if isinstance(file, os.PathLike): return await anyio.Path(file).read_bytes() diff --git a/src/mixedbread/_version.py b/src/mixedbread/_version.py index 16b3a101..fc182220 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.21.0" # x-release-please-version +__version__ = "0.22.0" # x-release-please-version diff --git a/src/mixedbread/resources/vector_stores/files.py b/src/mixedbread/resources/vector_stores/files.py index 44d28868..38f7bebe 100644 --- a/src/mixedbread/resources/vector_stores/files.py +++ b/src/mixedbread/resources/vector_stores/files.py @@ -171,6 +171,7 @@ def list( before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, statuses: Optional[List[VectorStoreFileStatus]] | NotGiven = NOT_GIVEN, + metadata_filter: Optional[file_list_params.MetadataFilter] | 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, @@ -201,6 +202,8 @@ def list( statuses: Status to filter by + metadata_filter: Metadata filter to apply to the query + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -228,6 +231,7 @@ def list( "before": before, "include_total": include_total, "statuses": statuses, + "metadata_filter": metadata_filter, }, file_list_params.FileListParams, ), @@ -609,6 +613,7 @@ def list( before: Optional[str] | NotGiven = NOT_GIVEN, include_total: bool | NotGiven = NOT_GIVEN, statuses: Optional[List[VectorStoreFileStatus]] | NotGiven = NOT_GIVEN, + metadata_filter: Optional[file_list_params.MetadataFilter] | 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, @@ -639,6 +644,8 @@ def list( statuses: Status to filter by + metadata_filter: Metadata filter to apply to the query + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -666,6 +673,7 @@ def list( "before": before, "include_total": include_total, "statuses": statuses, + "metadata_filter": metadata_filter, }, file_list_params.FileListParams, ), diff --git a/src/mixedbread/types/__init__.py b/src/mixedbread/types/__init__.py index aca3e061..f548be8f 100644 --- a/src/mixedbread/types/__init__.py +++ b/src/mixedbread/types/__init__.py @@ -2,9 +2,7 @@ from __future__ import annotations -from . import shared -from .. import _compat -from .shared import Usage as Usage, SearchFilter as SearchFilter, SearchFilterCondition as SearchFilterCondition +from .shared import Usage as Usage, SearchFilterCondition as SearchFilterCondition from .api_key import APIKey as APIKey from .embedding import Embedding as Embedding from .data_source import DataSource as DataSource @@ -58,12 +56,3 @@ from .vector_store_question_answering_response import ( VectorStoreQuestionAnsweringResponse as VectorStoreQuestionAnsweringResponse, ) - -# Rebuild cyclical models only after all modules are imported. -# This ensures that, when building the deferred (due to cyclical references) model schema, -# Pydantic can resolve the necessary references. -# See: https://github.com/pydantic/pydantic/issues/11250 for more context. -if _compat.PYDANTIC_V2: - shared.search_filter.SearchFilter.model_rebuild(_parent_namespace_depth=0) -else: - shared.search_filter.SearchFilter.update_forward_refs() # type: ignore diff --git a/src/mixedbread/types/shared/__init__.py b/src/mixedbread/types/shared/__init__.py index 66d5dcf9..bdd92589 100644 --- a/src/mixedbread/types/shared/__init__.py +++ b/src/mixedbread/types/shared/__init__.py @@ -1,5 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from .usage import Usage as Usage -from .search_filter import SearchFilter as SearchFilter from .search_filter_condition import SearchFilterCondition as SearchFilterCondition diff --git a/src/mixedbread/types/shared/search_filter.py b/src/mixedbread/types/shared/search_filter.py deleted file mode 100644 index 579ae162..00000000 --- a/src/mixedbread/types/shared/search_filter.py +++ /dev/null @@ -1,38 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import TYPE_CHECKING, List, Union, Optional -from typing_extensions import TypeAlias, TypeAliasType - -from ..._compat import PYDANTIC_V2 -from ..._models import BaseModel -from .search_filter_condition import SearchFilterCondition - -__all__ = ["SearchFilter", "All", "Any", "NoneType"] - -if TYPE_CHECKING or PYDANTIC_V2: - All = TypeAliasType("All", Union["SearchFilter", SearchFilterCondition]) -else: - All: TypeAlias = Union["SearchFilter", SearchFilterCondition] - -if TYPE_CHECKING or PYDANTIC_V2: - Any = TypeAliasType("Any", Union["SearchFilter", SearchFilterCondition]) -else: - Any: TypeAlias = Union["SearchFilter", SearchFilterCondition] - -if TYPE_CHECKING or PYDANTIC_V2: - NoneType = TypeAliasType("NoneType", Union["SearchFilter", SearchFilterCondition]) -else: - NoneType: TypeAlias = Union["SearchFilter", SearchFilterCondition] - - -class SearchFilter(BaseModel): - all: Optional[List[All]] = None - """List of conditions or filters to be ANDed together""" - - any: Optional[List[Any]] = None - """List of conditions or filters to be ORed together""" - - none: Optional[List[NoneType]] = None - """List of conditions or filters to be NOTed""" diff --git a/src/mixedbread/types/shared_params/__init__.py b/src/mixedbread/types/shared_params/__init__.py index c91e740d..69d169c2 100644 --- a/src/mixedbread/types/shared_params/__init__.py +++ b/src/mixedbread/types/shared_params/__init__.py @@ -1,4 +1,3 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from .search_filter import SearchFilter as SearchFilter from .search_filter_condition import SearchFilterCondition as SearchFilterCondition diff --git a/src/mixedbread/types/shared_params/search_filter.py b/src/mixedbread/types/shared_params/search_filter.py deleted file mode 100644 index a952a27a..00000000 --- a/src/mixedbread/types/shared_params/search_filter.py +++ /dev/null @@ -1,37 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import TYPE_CHECKING, Union, Iterable, Optional -from typing_extensions import TypeAlias, TypedDict, TypeAliasType - -from ..._compat import PYDANTIC_V2 -from .search_filter_condition import SearchFilterCondition - -__all__ = ["SearchFilter", "All", "Any", "NoneType"] - -if TYPE_CHECKING or PYDANTIC_V2: - All = TypeAliasType("All", Union["SearchFilter", SearchFilterCondition]) -else: - All: TypeAlias = Union["SearchFilter", SearchFilterCondition] - -if TYPE_CHECKING or PYDANTIC_V2: - Any = TypeAliasType("Any", Union["SearchFilter", SearchFilterCondition]) -else: - Any: TypeAlias = Union["SearchFilter", SearchFilterCondition] - -if TYPE_CHECKING or PYDANTIC_V2: - NoneType = TypeAliasType("NoneType", Union["SearchFilter", SearchFilterCondition]) -else: - NoneType: TypeAlias = Union["SearchFilter", SearchFilterCondition] - - -class SearchFilter(TypedDict, total=False): - all: Optional[Iterable[All]] - """List of conditions or filters to be ANDed together""" - - any: Optional[Iterable[Any]] - """List of conditions or filters to be ORed together""" - - none: Optional[Iterable[NoneType]] - """List of conditions or filters to be NOTed""" diff --git a/src/mixedbread/types/vector_store_question_answering_params.py b/src/mixedbread/types/vector_store_question_answering_params.py index b34189b3..6a21ffca 100644 --- a/src/mixedbread/types/vector_store_question_answering_params.py +++ b/src/mixedbread/types/vector_store_question_answering_params.py @@ -8,7 +8,20 @@ from .shared_params.search_filter_condition import SearchFilterCondition from .vector_store_chunk_search_options_param import VectorStoreChunkSearchOptionsParam -__all__ = ["VectorStoreQuestionAnsweringParams", "Filters", "FiltersUnionMember2", "QaOptions"] +__all__ = [ + "VectorStoreQuestionAnsweringParams", + "Filters", + "FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1", + "FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1All", + "FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1Any", + "FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1None", + "FiltersUnionMember2", + "FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1", + "FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1All", + "FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1Any", + "FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1None", + "QaOptions", +] class VectorStoreQuestionAnsweringParams(TypedDict, total=False): @@ -42,9 +55,49 @@ class VectorStoreQuestionAnsweringParams(TypedDict, total=False): """Question answering configuration options""" -FiltersUnionMember2: TypeAlias = Union["SearchFilter", SearchFilterCondition] +FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1All: TypeAlias = Union[SearchFilterCondition, object] -Filters: TypeAlias = Union["SearchFilter", SearchFilterCondition, Iterable[FiltersUnionMember2]] +FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1Any: TypeAlias = Union[SearchFilterCondition, object] + +FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1None: TypeAlias = Union[SearchFilterCondition, object] + + +class FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1(TypedDict, total=False): + all: Optional[Iterable[FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1All]] + """List of conditions or filters to be ANDed together""" + + any: Optional[Iterable[FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1Any]] + """List of conditions or filters to be ORed together""" + + none: Optional[Iterable[FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1None]] + """List of conditions or filters to be NOTed""" + + +FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1All: TypeAlias = Union[SearchFilterCondition, object] + +FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1Any: TypeAlias = Union[SearchFilterCondition, object] + +FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1None: TypeAlias = Union[SearchFilterCondition, object] + + +class FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1(TypedDict, total=False): + all: Optional[Iterable[FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1All]] + """List of conditions or filters to be ANDed together""" + + any: Optional[Iterable[FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1Any]] + """List of conditions or filters to be ORed together""" + + none: Optional[Iterable[FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1None]] + """List of conditions or filters to be NOTed""" + + +FiltersUnionMember2: TypeAlias = Union[ + FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1, SearchFilterCondition +] + +Filters: TypeAlias = Union[ + FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1, SearchFilterCondition, Iterable[FiltersUnionMember2] +] class QaOptions(TypedDict, total=False): @@ -53,6 +106,3 @@ class QaOptions(TypedDict, total=False): multimodal: bool """Whether to use multimodal context""" - - -from .shared_params.search_filter import SearchFilter diff --git a/src/mixedbread/types/vector_store_search_params.py b/src/mixedbread/types/vector_store_search_params.py index 48fc21e1..84eed57b 100644 --- a/src/mixedbread/types/vector_store_search_params.py +++ b/src/mixedbread/types/vector_store_search_params.py @@ -8,7 +8,19 @@ from .shared_params.search_filter_condition import SearchFilterCondition from .vector_store_chunk_search_options_param import VectorStoreChunkSearchOptionsParam -__all__ = ["VectorStoreSearchParams", "Filters", "FiltersUnionMember2"] +__all__ = [ + "VectorStoreSearchParams", + "Filters", + "FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1", + "FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1All", + "FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1Any", + "FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1None", + "FiltersUnionMember2", + "FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1", + "FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1All", + "FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1Any", + "FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1None", +] class VectorStoreSearchParams(TypedDict, total=False): @@ -33,8 +45,46 @@ class VectorStoreSearchParams(TypedDict, total=False): """Search configuration options""" -FiltersUnionMember2: TypeAlias = Union["SearchFilter", SearchFilterCondition] +FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1All: TypeAlias = Union[SearchFilterCondition, object] -Filters: TypeAlias = Union["SearchFilter", SearchFilterCondition, Iterable[FiltersUnionMember2]] +FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1Any: TypeAlias = Union[SearchFilterCondition, object] -from .shared_params.search_filter import SearchFilter +FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1None: TypeAlias = Union[SearchFilterCondition, object] + + +class FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1(TypedDict, total=False): + all: Optional[Iterable[FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1All]] + """List of conditions or filters to be ANDed together""" + + any: Optional[Iterable[FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1Any]] + """List of conditions or filters to be ORed together""" + + none: Optional[Iterable[FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1None]] + """List of conditions or filters to be NOTed""" + + +FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1All: TypeAlias = Union[SearchFilterCondition, object] + +FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1Any: TypeAlias = Union[SearchFilterCondition, object] + +FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1None: TypeAlias = Union[SearchFilterCondition, object] + + +class FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1(TypedDict, total=False): + all: Optional[Iterable[FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1All]] + """List of conditions or filters to be ANDed together""" + + any: Optional[Iterable[FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1Any]] + """List of conditions or filters to be ORed together""" + + none: Optional[Iterable[FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1None]] + """List of conditions or filters to be NOTed""" + + +FiltersUnionMember2: TypeAlias = Union[ + FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1, SearchFilterCondition +] + +Filters: TypeAlias = Union[ + FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1, SearchFilterCondition, Iterable[FiltersUnionMember2] +] diff --git a/src/mixedbread/types/vector_stores/file_list_params.py b/src/mixedbread/types/vector_stores/file_list_params.py index 49fe0c08..3041af3a 100644 --- a/src/mixedbread/types/vector_stores/file_list_params.py +++ b/src/mixedbread/types/vector_stores/file_list_params.py @@ -2,12 +2,25 @@ from __future__ import annotations -from typing import List, Optional -from typing_extensions import TypedDict +from typing import List, Union, Iterable, Optional +from typing_extensions import TypeAlias, TypedDict from .vector_store_file_status import VectorStoreFileStatus +from ..shared_params.search_filter_condition import SearchFilterCondition -__all__ = ["FileListParams"] +__all__ = [ + "FileListParams", + "MetadataFilter", + "MetadataFilterMxbaiOmniCoreVectorStoreModelsSearchFilter2", + "MetadataFilterMxbaiOmniCoreVectorStoreModelsSearchFilter2All", + "MetadataFilterMxbaiOmniCoreVectorStoreModelsSearchFilter2Any", + "MetadataFilterMxbaiOmniCoreVectorStoreModelsSearchFilter2None", + "MetadataFilterUnionMember2", + "MetadataFilterUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter2", + "MetadataFilterUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter2All", + "MetadataFilterUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter2Any", + "MetadataFilterUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter2None", +] class FileListParams(TypedDict, total=False): @@ -31,3 +44,59 @@ class FileListParams(TypedDict, total=False): statuses: Optional[List[VectorStoreFileStatus]] """Status to filter by""" + + metadata_filter: Optional[MetadataFilter] + """Metadata filter to apply to the query""" + + +MetadataFilterMxbaiOmniCoreVectorStoreModelsSearchFilter2All: TypeAlias = Union[SearchFilterCondition, object] + +MetadataFilterMxbaiOmniCoreVectorStoreModelsSearchFilter2Any: TypeAlias = Union[SearchFilterCondition, object] + +MetadataFilterMxbaiOmniCoreVectorStoreModelsSearchFilter2None: TypeAlias = Union[SearchFilterCondition, object] + + +class MetadataFilterMxbaiOmniCoreVectorStoreModelsSearchFilter2(TypedDict, total=False): + all: Optional[Iterable[MetadataFilterMxbaiOmniCoreVectorStoreModelsSearchFilter2All]] + """List of conditions or filters to be ANDed together""" + + any: Optional[Iterable[MetadataFilterMxbaiOmniCoreVectorStoreModelsSearchFilter2Any]] + """List of conditions or filters to be ORed together""" + + none: Optional[Iterable[MetadataFilterMxbaiOmniCoreVectorStoreModelsSearchFilter2None]] + """List of conditions or filters to be NOTed""" + + +MetadataFilterUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter2All: TypeAlias = Union[ + SearchFilterCondition, object +] + +MetadataFilterUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter2Any: TypeAlias = Union[ + SearchFilterCondition, object +] + +MetadataFilterUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter2None: TypeAlias = Union[ + SearchFilterCondition, object +] + + +class MetadataFilterUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter2(TypedDict, total=False): + all: Optional[Iterable[MetadataFilterUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter2All]] + """List of conditions or filters to be ANDed together""" + + any: Optional[Iterable[MetadataFilterUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter2Any]] + """List of conditions or filters to be ORed together""" + + none: Optional[Iterable[MetadataFilterUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter2None]] + """List of conditions or filters to be NOTed""" + + +MetadataFilterUnionMember2: TypeAlias = Union[ + MetadataFilterUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter2, SearchFilterCondition +] + +MetadataFilter: TypeAlias = Union[ + MetadataFilterMxbaiOmniCoreVectorStoreModelsSearchFilter2, + SearchFilterCondition, + Iterable[MetadataFilterUnionMember2], +] diff --git a/src/mixedbread/types/vector_stores/file_search_params.py b/src/mixedbread/types/vector_stores/file_search_params.py index 3c289bc1..8954e6e5 100644 --- a/src/mixedbread/types/vector_stores/file_search_params.py +++ b/src/mixedbread/types/vector_stores/file_search_params.py @@ -8,7 +8,21 @@ from .rerank_config_param import RerankConfigParam from ..shared_params.search_filter_condition import SearchFilterCondition -__all__ = ["FileSearchParams", "Filters", "FiltersUnionMember2", "SearchOptions", "SearchOptionsRerank"] +__all__ = [ + "FileSearchParams", + "Filters", + "FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1", + "FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1All", + "FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1Any", + "FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1None", + "FiltersUnionMember2", + "FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1", + "FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1All", + "FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1Any", + "FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1None", + "SearchOptions", + "SearchOptionsRerank", +] class FileSearchParams(TypedDict, total=False): @@ -33,9 +47,49 @@ class FileSearchParams(TypedDict, total=False): """Search configuration options""" -FiltersUnionMember2: TypeAlias = Union["SearchFilter", SearchFilterCondition] +FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1All: TypeAlias = Union[SearchFilterCondition, object] -Filters: TypeAlias = Union["SearchFilter", SearchFilterCondition, Iterable[FiltersUnionMember2]] +FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1Any: TypeAlias = Union[SearchFilterCondition, object] + +FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1None: TypeAlias = Union[SearchFilterCondition, object] + + +class FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1(TypedDict, total=False): + all: Optional[Iterable[FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1All]] + """List of conditions or filters to be ANDed together""" + + any: Optional[Iterable[FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1Any]] + """List of conditions or filters to be ORed together""" + + none: Optional[Iterable[FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1None]] + """List of conditions or filters to be NOTed""" + + +FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1All: TypeAlias = Union[SearchFilterCondition, object] + +FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1Any: TypeAlias = Union[SearchFilterCondition, object] + +FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1None: TypeAlias = Union[SearchFilterCondition, object] + + +class FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1(TypedDict, total=False): + all: Optional[Iterable[FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1All]] + """List of conditions or filters to be ANDed together""" + + any: Optional[Iterable[FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1Any]] + """List of conditions or filters to be ORed together""" + + none: Optional[Iterable[FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1None]] + """List of conditions or filters to be NOTed""" + + +FiltersUnionMember2: TypeAlias = Union[ + FiltersUnionMember2MxbaiOmniCoreVectorStoreModelsSearchFilter1, SearchFilterCondition +] + +Filters: TypeAlias = Union[ + FiltersMxbaiOmniCoreVectorStoreModelsSearchFilter1, SearchFilterCondition, Iterable[FiltersUnionMember2] +] SearchOptionsRerank: TypeAlias = Union[bool, RerankConfigParam] @@ -61,6 +115,3 @@ class SearchOptions(TypedDict, total=False): apply_search_rules: bool """Whether to apply search rules""" - - -from ..shared_params.search_filter import SearchFilter diff --git a/tests/api_resources/vector_stores/test_files.py b/tests/api_resources/vector_stores/test_files.py index 6e3bf27e..17014537 100644 --- a/tests/api_resources/vector_stores/test_files.py +++ b/tests/api_resources/vector_stores/test_files.py @@ -154,6 +154,44 @@ def test_method_list_with_all_params(self, client: Mixedbread) -> None: before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", include_total=False, statuses=["pending", "in_progress"], + metadata_filter={ + "all": [ + { + "key": "price", + "value": "100", + "operator": "gt", + }, + { + "key": "color", + "value": "red", + "operator": "eq", + }, + ], + "any": [ + { + "key": "price", + "value": "100", + "operator": "gt", + }, + { + "key": "color", + "value": "red", + "operator": "eq", + }, + ], + "none": [ + { + "key": "price", + "value": "100", + "operator": "gt", + }, + { + "key": "color", + "value": "red", + "operator": "eq", + }, + ], + }, ) assert_matches_type(SyncCursor[VectorStoreFile], file, path=["response"]) @@ -467,6 +505,44 @@ async def test_method_list_with_all_params(self, async_client: AsyncMixedbread) before="eyJjcmVhdGVkX2F0IjoiMjAyNC0xMi0zMVQyMzo1OTo1OS4wMDBaIiwiaWQiOiJhYmMxMjMifQ==", include_total=False, statuses=["pending", "in_progress"], + metadata_filter={ + "all": [ + { + "key": "price", + "value": "100", + "operator": "gt", + }, + { + "key": "color", + "value": "red", + "operator": "eq", + }, + ], + "any": [ + { + "key": "price", + "value": "100", + "operator": "gt", + }, + { + "key": "color", + "value": "red", + "operator": "eq", + }, + ], + "none": [ + { + "key": "price", + "value": "100", + "operator": "gt", + }, + { + "key": "color", + "value": "red", + "operator": "eq", + }, + ], + }, ) assert_matches_type(AsyncCursor[VectorStoreFile], file, path=["response"])