diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1b5dc400..0a40b9d7 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.39.0" + ".": "0.40.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 82ef3004..e44510d0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 62 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-c53a9b02bf4bd345435a03b4178aed1b7c8ac04a2508f370b5361bf305a3f803.yml -openapi_spec_hash: f05a6df876280efad08ed2f0ab78d5fc +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-636ffd012f5b88d33c33cd0de8290a01564009f31d8004a87a2d516435c03868.yml +openapi_spec_hash: 91c662ed12c45e766bc325d47fd6e285 config_hash: 6fa04d08d4e1a3a45f562e37fab0ea71 diff --git a/CHANGELOG.md b/CHANGELOG.md index e8f38812..0509a3f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## 0.40.0 (2025-11-11) + +Full Changelog: [v0.39.0...v0.40.0](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.39.0...v0.40.0) + +### Features + +* **api:** api update ([93c24d4](https://github.com/mixedbread-ai/mixedbread-python/commit/93c24d40549f6e7d1cb881313a40bcdd19fed4ab)) +* **api:** api update ([478b973](https://github.com/mixedbread-ai/mixedbread-python/commit/478b9736d4da0411c814620a61b2675faed9173c)) + + +### Bug Fixes + +* compat with Python 3.14 ([99a4c1c](https://github.com/mixedbread-ai/mixedbread-python/commit/99a4c1c553bd638b2d7e2f050ca33824623c93e8)) + + +### Chores + +* **package:** drop Python 3.8 support ([54a77eb](https://github.com/mixedbread-ai/mixedbread-python/commit/54a77eb9af52ced156a07b0d524068cb5337dd8f)) + ## 0.39.0 (2025-11-07) Full Changelog: [v0.38.0...v0.39.0](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.38.0...v0.39.0) diff --git a/README.md b/README.md index ade28bb0..fc0e2f30 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![PyPI version](https://img.shields.io/pypi/v/mixedbread.svg?label=pypi%20(stable))](https://pypi.org/project/mixedbread/) -The Mixedbread API Python SDK library provides convenient access to the Mixedbread REST API from any Python 3.8+ +The Mixedbread API Python SDK library provides convenient access to the Mixedbread REST API from any Python 3.9+ application. The library includes type definitions for all request params and response fields, and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx). @@ -455,7 +455,7 @@ print(mixedbread.__version__) ## Requirements -Python 3.8 or higher. +Python 3.9 or higher. ## Contributing diff --git a/pyproject.toml b/pyproject.toml index f2df0f6e..5b3f8eab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mixedbread" -version = "0.39.0" +version = "0.40.0" description = "The official Python library for the Mixedbread API" dynamic = ["readme"] license = "Apache-2.0" @@ -15,11 +15,10 @@ dependencies = [ "distro>=1.7.0, <2", "sniffio", ] -requires-python = ">= 3.8" +requires-python = ">= 3.9" classifiers = [ "Typing :: Typed", "Intended Audience :: Developers", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -141,7 +140,7 @@ filterwarnings = [ # there are a couple of flags that are still disabled by # default in strict mode as they are experimental and niche. typeCheckingMode = "strict" -pythonVersion = "3.8" +pythonVersion = "3.9" exclude = [ "_dev", diff --git a/src/mixedbread/_models.py b/src/mixedbread/_models.py index 6a3cd1d2..fcec2cf9 100644 --- a/src/mixedbread/_models.py +++ b/src/mixedbread/_models.py @@ -2,6 +2,7 @@ import os import inspect +import weakref from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, Optional, cast from datetime import date, datetime from typing_extensions import ( @@ -573,6 +574,9 @@ class CachedDiscriminatorType(Protocol): __discriminator__: DiscriminatorDetails +DISCRIMINATOR_CACHE: weakref.WeakKeyDictionary[type, DiscriminatorDetails] = weakref.WeakKeyDictionary() + + class DiscriminatorDetails: field_name: str """The name of the discriminator field in the variant class, e.g. @@ -615,8 +619,9 @@ def __init__( def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, ...]) -> DiscriminatorDetails | None: - if isinstance(union, CachedDiscriminatorType): - return union.__discriminator__ + cached = DISCRIMINATOR_CACHE.get(union) + if cached is not None: + return cached discriminator_field_name: str | None = None @@ -669,7 +674,7 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, discriminator_field=discriminator_field_name, discriminator_alias=discriminator_alias, ) - cast(CachedDiscriminatorType, union).__discriminator__ = details + DISCRIMINATOR_CACHE.setdefault(union, details) return details diff --git a/src/mixedbread/_utils/_sync.py b/src/mixedbread/_utils/_sync.py index ad7ec71b..f6027c18 100644 --- a/src/mixedbread/_utils/_sync.py +++ b/src/mixedbread/_utils/_sync.py @@ -1,10 +1,8 @@ from __future__ import annotations -import sys import asyncio import functools -import contextvars -from typing import Any, TypeVar, Callable, Awaitable +from typing import TypeVar, Callable, Awaitable from typing_extensions import ParamSpec import anyio @@ -15,34 +13,11 @@ T_ParamSpec = ParamSpec("T_ParamSpec") -if sys.version_info >= (3, 9): - _asyncio_to_thread = asyncio.to_thread -else: - # backport of https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread - # for Python 3.8 support - async def _asyncio_to_thread( - func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs - ) -> Any: - """Asynchronously run function *func* in a separate thread. - - Any *args and **kwargs supplied for this function are directly passed - to *func*. Also, the current :class:`contextvars.Context` is propagated, - allowing context variables from the main thread to be accessed in the - separate thread. - - Returns a coroutine that can be awaited to get the eventual result of *func*. - """ - loop = asyncio.events.get_running_loop() - ctx = contextvars.copy_context() - func_call = functools.partial(ctx.run, func, *args, **kwargs) - return await loop.run_in_executor(None, func_call) - - async def to_thread( func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs ) -> T_Retval: if sniffio.current_async_library() == "asyncio": - return await _asyncio_to_thread(func, *args, **kwargs) + return await asyncio.to_thread(func, *args, **kwargs) return await anyio.to_thread.run_sync( functools.partial(func, *args, **kwargs), @@ -53,10 +28,7 @@ async def to_thread( def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]: """ Take a blocking function and create an async one that receives the same - positional and keyword arguments. For python version 3.9 and above, it uses - asyncio.to_thread to run the function in a separate thread. For python version - 3.8, it uses locally defined copy of the asyncio.to_thread function which was - introduced in python 3.9. + positional and keyword arguments. Usage: diff --git a/src/mixedbread/_version.py b/src/mixedbread/_version.py index d0ade071..326f9b6c 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.39.0" # x-release-please-version +__version__ = "0.40.0" # x-release-please-version diff --git a/src/mixedbread/types/parsing/parsing_job.py b/src/mixedbread/types/parsing/parsing_job.py index c950c5a4..7eaa134d 100644 --- a/src/mixedbread/types/parsing/parsing_job.py +++ b/src/mixedbread/types/parsing/parsing_job.py @@ -34,7 +34,7 @@ class ResultChunkElement(BaseModel): class ResultChunk(BaseModel): - content: str + content: Optional[str] = None """The full content of the chunk""" content_to_embed: str diff --git a/src/mixedbread/types/scored_audio_url_input_chunk.py b/src/mixedbread/types/scored_audio_url_input_chunk.py index 0babf168..107ae57e 100644 --- a/src/mixedbread/types/scored_audio_url_input_chunk.py +++ b/src/mixedbread/types/scored_audio_url_input_chunk.py @@ -49,6 +49,10 @@ class GeneratedMetadataMarkdownChunkGeneratedMetadata(BaseModel): heading_context: Optional[List[GeneratedMetadataMarkdownChunkGeneratedMetadataHeadingContext]] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -73,6 +77,10 @@ class GeneratedMetadataTextChunkGeneratedMetadata(BaseModel): file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -119,6 +127,10 @@ class GeneratedMetadataCodeChunkGeneratedMetadata(BaseModel): file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. diff --git a/src/mixedbread/types/scored_image_url_input_chunk.py b/src/mixedbread/types/scored_image_url_input_chunk.py index c1ea6bfa..fc929eb4 100644 --- a/src/mixedbread/types/scored_image_url_input_chunk.py +++ b/src/mixedbread/types/scored_image_url_input_chunk.py @@ -49,6 +49,10 @@ class GeneratedMetadataMarkdownChunkGeneratedMetadata(BaseModel): heading_context: Optional[List[GeneratedMetadataMarkdownChunkGeneratedMetadataHeadingContext]] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -73,6 +77,10 @@ class GeneratedMetadataTextChunkGeneratedMetadata(BaseModel): file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -119,6 +127,10 @@ class GeneratedMetadataCodeChunkGeneratedMetadata(BaseModel): file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. diff --git a/src/mixedbread/types/scored_text_input_chunk.py b/src/mixedbread/types/scored_text_input_chunk.py index 762a2a1c..2eeddb07 100644 --- a/src/mixedbread/types/scored_text_input_chunk.py +++ b/src/mixedbread/types/scored_text_input_chunk.py @@ -48,6 +48,10 @@ class GeneratedMetadataMarkdownChunkGeneratedMetadata(BaseModel): heading_context: Optional[List[GeneratedMetadataMarkdownChunkGeneratedMetadataHeadingContext]] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -72,6 +76,10 @@ class GeneratedMetadataTextChunkGeneratedMetadata(BaseModel): file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -118,6 +126,10 @@ class GeneratedMetadataCodeChunkGeneratedMetadata(BaseModel): file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. diff --git a/src/mixedbread/types/scored_video_url_input_chunk.py b/src/mixedbread/types/scored_video_url_input_chunk.py index 3329d671..488f80d0 100644 --- a/src/mixedbread/types/scored_video_url_input_chunk.py +++ b/src/mixedbread/types/scored_video_url_input_chunk.py @@ -49,6 +49,10 @@ class GeneratedMetadataMarkdownChunkGeneratedMetadata(BaseModel): heading_context: Optional[List[GeneratedMetadataMarkdownChunkGeneratedMetadataHeadingContext]] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -73,6 +77,10 @@ class GeneratedMetadataTextChunkGeneratedMetadata(BaseModel): file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -119,6 +127,10 @@ class GeneratedMetadataCodeChunkGeneratedMetadata(BaseModel): file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. diff --git a/src/mixedbread/types/stores/store_file.py b/src/mixedbread/types/stores/store_file.py index 58dcef0c..dccbbe40 100644 --- a/src/mixedbread/types/stores/store_file.py +++ b/src/mixedbread/types/stores/store_file.py @@ -92,6 +92,10 @@ class ChunkTextInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadata(BaseMod List[ChunkTextInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadataHeadingContext] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -116,6 +120,10 @@ class ChunkTextInputChunkGeneratedMetadataTextChunkGeneratedMetadata(BaseModel): file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -162,6 +170,10 @@ class ChunkTextInputChunkGeneratedMetadataCodeChunkGeneratedMetadata(BaseModel): file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -270,6 +282,10 @@ class ChunkImageURLInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadata(Bas List[ChunkImageURLInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadataHeadingContext] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -294,6 +310,10 @@ class ChunkImageURLInputChunkGeneratedMetadataTextChunkGeneratedMetadata(BaseMod file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -340,6 +360,10 @@ class ChunkImageURLInputChunkGeneratedMetadataCodeChunkGeneratedMetadata(BaseMod file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -459,6 +483,10 @@ class ChunkAudioURLInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadata(Bas List[ChunkAudioURLInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadataHeadingContext] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -483,6 +511,10 @@ class ChunkAudioURLInputChunkGeneratedMetadataTextChunkGeneratedMetadata(BaseMod file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -529,6 +561,10 @@ class ChunkAudioURLInputChunkGeneratedMetadataCodeChunkGeneratedMetadata(BaseMod file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -648,6 +684,10 @@ class ChunkVideoURLInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadata(Bas List[ChunkVideoURLInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadataHeadingContext] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -672,6 +712,10 @@ class ChunkVideoURLInputChunkGeneratedMetadataTextChunkGeneratedMetadata(BaseMod file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -718,6 +762,10 @@ class ChunkVideoURLInputChunkGeneratedMetadataCodeChunkGeneratedMetadata(BaseMod file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. diff --git a/src/mixedbread/types/vector_store_question_answering_response.py b/src/mixedbread/types/vector_store_question_answering_response.py index 29d115f6..6f1d5a9b 100644 --- a/src/mixedbread/types/vector_store_question_answering_response.py +++ b/src/mixedbread/types/vector_store_question_answering_response.py @@ -94,6 +94,10 @@ class SourceMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredTextInputChunk ] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -120,6 +124,10 @@ class SourceMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredTextInputChunk file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -170,6 +178,10 @@ class SourceMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredTextInputChunk file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -307,6 +319,10 @@ class SourceMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredImageURLInputC ] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -333,6 +349,10 @@ class SourceMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredImageURLInputC file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -383,6 +403,10 @@ class SourceMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredImageURLInputC file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -531,6 +555,10 @@ class SourceMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredAudioURLInputC ] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -557,6 +585,10 @@ class SourceMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredAudioURLInputC file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -607,6 +639,10 @@ class SourceMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredAudioURLInputC file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -755,6 +791,10 @@ class SourceMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredVideoURLInputC ] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -781,6 +821,10 @@ class SourceMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredVideoURLInputC file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -831,6 +875,10 @@ class SourceMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredVideoURLInputC file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. diff --git a/src/mixedbread/types/vector_store_search_response.py b/src/mixedbread/types/vector_store_search_response.py index 41f4d77b..dd5c4f2c 100644 --- a/src/mixedbread/types/vector_store_search_response.py +++ b/src/mixedbread/types/vector_store_search_response.py @@ -94,6 +94,10 @@ class DataMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredTextInputChunkGe ] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -120,6 +124,10 @@ class DataMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredTextInputChunkGe file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -170,6 +178,10 @@ class DataMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredTextInputChunkGe file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -307,6 +319,10 @@ class DataMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredImageURLInputChu ] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -333,6 +349,10 @@ class DataMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredImageURLInputChu file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -383,6 +403,10 @@ class DataMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredImageURLInputChu file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -531,6 +555,10 @@ class DataMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredAudioURLInputChu ] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -557,6 +585,10 @@ class DataMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredAudioURLInputChu file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -607,6 +639,10 @@ class DataMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredAudioURLInputChu file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -755,6 +791,10 @@ class DataMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredVideoURLInputChu ] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -781,6 +821,10 @@ class DataMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredVideoURLInputChu file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -831,6 +875,10 @@ class DataMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredVideoURLInputChu file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. diff --git a/src/mixedbread/types/vector_stores/scored_vector_store_file.py b/src/mixedbread/types/vector_stores/scored_vector_store_file.py index 85e4721e..55e1ed55 100644 --- a/src/mixedbread/types/vector_stores/scored_vector_store_file.py +++ b/src/mixedbread/types/vector_stores/scored_vector_store_file.py @@ -96,6 +96,10 @@ class ChunkMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredTextInputChunkG ] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -122,6 +126,10 @@ class ChunkMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredTextInputChunkG file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -172,6 +180,10 @@ class ChunkMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredTextInputChunkG file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -309,6 +321,10 @@ class ChunkMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredImageURLInputCh ] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -335,6 +351,10 @@ class ChunkMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredImageURLInputCh file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -385,6 +405,10 @@ class ChunkMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredImageURLInputCh file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -533,6 +557,10 @@ class ChunkMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredAudioURLInputCh ] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -559,6 +587,10 @@ class ChunkMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredAudioURLInputCh file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -609,6 +641,10 @@ class ChunkMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredAudioURLInputCh file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -757,6 +793,10 @@ class ChunkMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredVideoURLInputCh ] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -783,6 +823,10 @@ class ChunkMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredVideoURLInputCh file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -833,6 +877,10 @@ class ChunkMxbaiOmniAPIRoutesV1DeprecatedVectorStoresModelsScoredVideoURLInputCh file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. diff --git a/src/mixedbread/types/vector_stores/vector_store_file.py b/src/mixedbread/types/vector_stores/vector_store_file.py index 2fc6168d..02f8f31a 100644 --- a/src/mixedbread/types/vector_stores/vector_store_file.py +++ b/src/mixedbread/types/vector_stores/vector_store_file.py @@ -86,6 +86,10 @@ class ChunkTextInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadata(BaseMod List[ChunkTextInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadataHeadingContext] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -110,6 +114,10 @@ class ChunkTextInputChunkGeneratedMetadataTextChunkGeneratedMetadata(BaseModel): file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -156,6 +164,10 @@ class ChunkTextInputChunkGeneratedMetadataCodeChunkGeneratedMetadata(BaseModel): file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -264,6 +276,10 @@ class ChunkImageURLInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadata(Bas List[ChunkImageURLInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadataHeadingContext] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -288,6 +304,10 @@ class ChunkImageURLInputChunkGeneratedMetadataTextChunkGeneratedMetadata(BaseMod file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -334,6 +354,10 @@ class ChunkImageURLInputChunkGeneratedMetadataCodeChunkGeneratedMetadata(BaseMod file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -453,6 +477,10 @@ class ChunkAudioURLInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadata(Bas List[ChunkAudioURLInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadataHeadingContext] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -477,6 +505,10 @@ class ChunkAudioURLInputChunkGeneratedMetadataTextChunkGeneratedMetadata(BaseMod file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -523,6 +555,10 @@ class ChunkAudioURLInputChunkGeneratedMetadataCodeChunkGeneratedMetadata(BaseMod file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -642,6 +678,10 @@ class ChunkVideoURLInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadata(Bas List[ChunkVideoURLInputChunkGeneratedMetadataMarkdownChunkGeneratedMetadataHeadingContext] ] = None + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -666,6 +706,10 @@ class ChunkVideoURLInputChunkGeneratedMetadataTextChunkGeneratedMetadata(BaseMod file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. @@ -712,6 +756,10 @@ class ChunkVideoURLInputChunkGeneratedMetadataCodeChunkGeneratedMetadata(BaseMod file_size: int + start_line: Optional[int] = None + + num_lines: Optional[int] = None + if TYPE_CHECKING: # Some versions of Pydantic <2.8.0 have a bug and don’t allow assigning a # value to this field, so for compatibility we avoid doing it at runtime. diff --git a/tests/test_models.py b/tests/test_models.py index 4a12ab5d..a8c78064 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -9,7 +9,7 @@ from mixedbread._utils import PropertyInfo from mixedbread._compat import PYDANTIC_V1, parse_obj, model_dump, model_json -from mixedbread._models import BaseModel, construct_type +from mixedbread._models import DISCRIMINATOR_CACHE, BaseModel, construct_type class BasicModel(BaseModel): @@ -809,7 +809,7 @@ class B(BaseModel): UnionType = cast(Any, Union[A, B]) - assert not hasattr(UnionType, "__discriminator__") + assert not DISCRIMINATOR_CACHE.get(UnionType) m = construct_type( value={"type": "b", "data": "foo"}, type_=cast(Any, Annotated[UnionType, PropertyInfo(discriminator="type")]) @@ -818,7 +818,7 @@ class B(BaseModel): assert m.type == "b" assert m.data == "foo" # type: ignore[comparison-overlap] - discriminator = UnionType.__discriminator__ + discriminator = DISCRIMINATOR_CACHE.get(UnionType) assert discriminator is not None m = construct_type( @@ -830,7 +830,7 @@ class B(BaseModel): # if the discriminator details object stays the same between invocations then # we hit the cache - assert UnionType.__discriminator__ is discriminator + assert DISCRIMINATOR_CACHE.get(UnionType) is discriminator @pytest.mark.skipif(PYDANTIC_V1, reason="TypeAliasType is not supported in Pydantic v1")