diff --git a/.stats.yml b/.stats.yml index 00db8629..c0a3743f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 32 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-82c2c1c322149cd73b2e8e45f475919b941752a89e74464ccecd1aee9352e9be.yml openapi_spec_hash: dbd7616a32c90fd25b32994830fb12f6 -config_hash: 2a44785dc321bd6e458c4e767035de1b +config_hash: 404d016390359897b6f1ea74357b2ace diff --git a/api.md b/api.md index 556c3a91..2c0954d6 100644 --- a/api.md +++ b/api.md @@ -9,12 +9,18 @@ from mixedbread.types import SearchFilter, SearchFilterCondition Types: ```python -from mixedbread.types import Em, Embedding, MultiEncodingEmbedding, InfoResponse, RerankResponse +from mixedbread.types import ( + Embedding, + MultiEncodingEmbedding, + EmbedResponse, + InfoResponse, + RerankResponse, +) ``` Methods: -- client.embed(\*\*params) -> Em +- client.embed(\*\*params) -> EmbedResponse - client.info() -> InfoResponse - client.rerank(\*\*params) -> RerankResponse @@ -145,6 +151,12 @@ Methods: # Embeddings +Types: + +```python +from mixedbread.types import EmbeddingCreateResponse +``` + Methods: -- client.embeddings.create(\*\*params) -> Em +- client.embeddings.create(\*\*params) -> EmbeddingCreateResponse diff --git a/src/mixedbread/_client.py b/src/mixedbread/_client.py index 29b4d595..b9996076 100644 --- a/src/mixedbread/_client.py +++ b/src/mixedbread/_client.py @@ -30,7 +30,6 @@ async_maybe_transform, ) from ._version import __version__ -from .types.em import Em from ._response import ( to_raw_response_wrapper, to_streamed_response_wrapper, @@ -48,6 +47,7 @@ ) from .resources.parsing import parsing from .types.info_response import InfoResponse +from .types.embed_response import EmbedResponse from .resources.extractions import extractions from .types.rerank_response import RerankResponse from .resources.vector_stores import vector_stores @@ -257,7 +257,7 @@ def embed( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Em: + ) -> EmbedResponse: """ Create embeddings for text or images using the specified model, encoding format, and normalization. @@ -304,7 +304,7 @@ def embed( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=Em, + cast_to=EmbedResponse, ) def info( @@ -614,7 +614,7 @@ async def embed( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Em: + ) -> EmbedResponse: """ Create embeddings for text or images using the specified model, encoding format, and normalization. @@ -661,7 +661,7 @@ async def embed( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=Em, + cast_to=EmbedResponse, ) async def info( diff --git a/src/mixedbread/resources/embeddings.py b/src/mixedbread/resources/embeddings.py index f2adc49c..d7390eda 100644 --- a/src/mixedbread/resources/embeddings.py +++ b/src/mixedbread/resources/embeddings.py @@ -14,7 +14,6 @@ async_maybe_transform, ) from .._compat import cached_property -from ..types.em import Em from .._resource import SyncAPIResource, AsyncAPIResource from .._response import ( to_raw_response_wrapper, @@ -23,6 +22,7 @@ async_to_streamed_response_wrapper, ) from .._base_client import make_request_options +from ..types.embedding_create_response import EmbeddingCreateResponse __all__ = ["EmbeddingsResource", "AsyncEmbeddingsResource"] @@ -66,7 +66,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Em: + ) -> EmbeddingCreateResponse: """ Create embeddings for text or images using the specified model, encoding format, and normalization. @@ -113,7 +113,7 @@ def create( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=Em, + cast_to=EmbeddingCreateResponse, ) @@ -156,7 +156,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Em: + ) -> EmbeddingCreateResponse: """ Create embeddings for text or images using the specified model, encoding format, and normalization. @@ -203,7 +203,7 @@ async def create( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=Em, + cast_to=EmbeddingCreateResponse, ) diff --git a/src/mixedbread/types/__init__.py b/src/mixedbread/types/__init__.py index c48a74b0..ee8d1032 100644 --- a/src/mixedbread/types/__init__.py +++ b/src/mixedbread/types/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations -from .em import Em as Em from .shared import SearchFilter as SearchFilter, SearchFilterCondition as SearchFilterCondition from .embedding import Embedding as Embedding from .file_counts import FileCounts as FileCounts @@ -10,6 +9,7 @@ from .vector_store import VectorStore as VectorStore from .expires_after import ExpiresAfter as ExpiresAfter from .info_response import InfoResponse as InfoResponse +from .embed_response import EmbedResponse as EmbedResponse from .rerank_response import RerankResponse as RerankResponse from .file_list_params import FileListParams as FileListParams from .file_create_params import FileCreateParams as FileCreateParams @@ -21,6 +21,7 @@ from .embedding_create_params import EmbeddingCreateParams as EmbeddingCreateParams from .multi_encoding_embedding import MultiEncodingEmbedding as MultiEncodingEmbedding from .vector_store_list_params import VectorStoreListParams as VectorStoreListParams +from .embedding_create_response import EmbeddingCreateResponse as EmbeddingCreateResponse from .scored_vector_store_chunk import ScoredVectorStoreChunk as ScoredVectorStoreChunk from .vector_store_create_params import VectorStoreCreateParams as VectorStoreCreateParams from .vector_store_search_params import VectorStoreSearchParams as VectorStoreSearchParams diff --git a/src/mixedbread/types/em.py b/src/mixedbread/types/embed_response.py similarity index 95% rename from src/mixedbread/types/em.py rename to src/mixedbread/types/embed_response.py index 12277e0a..fb9c8803 100644 --- a/src/mixedbread/types/em.py +++ b/src/mixedbread/types/embed_response.py @@ -7,7 +7,7 @@ from .embedding import Embedding from .multi_encoding_embedding import MultiEncodingEmbedding -__all__ = ["Em", "Usage"] +__all__ = ["EmbedResponse", "Usage"] class Usage(BaseModel): @@ -21,7 +21,7 @@ class Usage(BaseModel): """The number of tokens used for the completion""" -class Em(BaseModel): +class EmbedResponse(BaseModel): usage: Usage """The usage of the model""" diff --git a/src/mixedbread/types/embedding_create_response.py b/src/mixedbread/types/embedding_create_response.py new file mode 100644 index 00000000..8f3605cb --- /dev/null +++ b/src/mixedbread/types/embedding_create_response.py @@ -0,0 +1,60 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from typing_extensions import Literal + +from .._models import BaseModel +from .embedding import Embedding +from .multi_encoding_embedding import MultiEncodingEmbedding + +__all__ = ["EmbeddingCreateResponse", "Usage"] + + +class Usage(BaseModel): + prompt_tokens: int + """The number of tokens used for the prompt""" + + total_tokens: int + """The total number of tokens used""" + + completion_tokens: Optional[int] = None + """The number of tokens used for the completion""" + + +class EmbeddingCreateResponse(BaseModel): + usage: Usage + """The usage of the model""" + + model: str + """The model used""" + + data: Union[List[Embedding], List[MultiEncodingEmbedding]] + """The created embeddings.""" + + object: Optional[ + Literal[ + "list", + "parsing_job", + "job", + "embedding", + "embedding_dict", + "rank_result", + "file", + "vector_store", + "vector_store.file", + "api_key", + ] + ] = None + """The object type of the response""" + + normalized: bool + """Whether the embeddings are normalized.""" + + encoding_format: Union[ + Literal["float", "float16", "base64", "binary", "ubinary", "int8", "uint8"], + List[Literal["float", "float16", "base64", "binary", "ubinary", "int8", "uint8"]], + ] + """The encoding formats of the embeddings.""" + + dimensions: Optional[int] = None + """The number of dimensions used for the embeddings.""" diff --git a/tests/api_resources/test_client.py b/tests/api_resources/test_client.py index dc3ed1d8..1d143378 100644 --- a/tests/api_resources/test_client.py +++ b/tests/api_resources/test_client.py @@ -9,7 +9,7 @@ from mixedbread import Mixedbread, AsyncMixedbread from tests.utils import assert_matches_type -from mixedbread.types import Em, InfoResponse, RerankResponse +from mixedbread.types import InfoResponse, EmbedResponse, RerankResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -23,7 +23,7 @@ def test_method_embed(self, client: Mixedbread) -> None: model="mixedbread-ai/mxbai-embed-large-v1", input=["string"], ) - assert_matches_type(Em, client_, path=["response"]) + assert_matches_type(EmbedResponse, client_, path=["response"]) @parametrize def test_method_embed_with_all_params(self, client: Mixedbread) -> None: @@ -35,7 +35,7 @@ def test_method_embed_with_all_params(self, client: Mixedbread) -> None: normalized=True, encoding_format="float", ) - assert_matches_type(Em, client_, path=["response"]) + assert_matches_type(EmbedResponse, client_, path=["response"]) @parametrize def test_raw_response_embed(self, client: Mixedbread) -> None: @@ -47,7 +47,7 @@ def test_raw_response_embed(self, client: Mixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" client_ = response.parse() - assert_matches_type(Em, client_, path=["response"]) + assert_matches_type(EmbedResponse, client_, path=["response"]) @parametrize def test_streaming_response_embed(self, client: Mixedbread) -> None: @@ -59,7 +59,7 @@ def test_streaming_response_embed(self, client: Mixedbread) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" client_ = response.parse() - assert_matches_type(Em, client_, path=["response"]) + assert_matches_type(EmbedResponse, client_, path=["response"]) assert cast(Any, response.is_closed) is True @@ -144,7 +144,7 @@ async def test_method_embed(self, async_client: AsyncMixedbread) -> None: model="mixedbread-ai/mxbai-embed-large-v1", input=["string"], ) - assert_matches_type(Em, client, path=["response"]) + assert_matches_type(EmbedResponse, client, path=["response"]) @parametrize async def test_method_embed_with_all_params(self, async_client: AsyncMixedbread) -> None: @@ -156,7 +156,7 @@ async def test_method_embed_with_all_params(self, async_client: AsyncMixedbread) normalized=True, encoding_format="float", ) - assert_matches_type(Em, client, path=["response"]) + assert_matches_type(EmbedResponse, client, path=["response"]) @parametrize async def test_raw_response_embed(self, async_client: AsyncMixedbread) -> None: @@ -168,7 +168,7 @@ async def test_raw_response_embed(self, async_client: AsyncMixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" client = await response.parse() - assert_matches_type(Em, client, path=["response"]) + assert_matches_type(EmbedResponse, client, path=["response"]) @parametrize async def test_streaming_response_embed(self, async_client: AsyncMixedbread) -> None: @@ -180,7 +180,7 @@ async def test_streaming_response_embed(self, async_client: AsyncMixedbread) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" client = await response.parse() - assert_matches_type(Em, client, path=["response"]) + assert_matches_type(EmbedResponse, client, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_embeddings.py b/tests/api_resources/test_embeddings.py index 610022ee..ffe758eb 100644 --- a/tests/api_resources/test_embeddings.py +++ b/tests/api_resources/test_embeddings.py @@ -9,7 +9,7 @@ from mixedbread import Mixedbread, AsyncMixedbread from tests.utils import assert_matches_type -from mixedbread.types import Em +from mixedbread.types import EmbeddingCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -23,7 +23,7 @@ def test_method_create(self, client: Mixedbread) -> None: model="mixedbread-ai/mxbai-embed-large-v1", input=["string"], ) - assert_matches_type(Em, embedding, path=["response"]) + assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Mixedbread) -> None: @@ -35,7 +35,7 @@ def test_method_create_with_all_params(self, client: Mixedbread) -> None: normalized=True, encoding_format="float", ) - assert_matches_type(Em, embedding, path=["response"]) + assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"]) @parametrize def test_raw_response_create(self, client: Mixedbread) -> None: @@ -47,7 +47,7 @@ def test_raw_response_create(self, client: Mixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" embedding = response.parse() - assert_matches_type(Em, embedding, path=["response"]) + assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"]) @parametrize def test_streaming_response_create(self, client: Mixedbread) -> None: @@ -59,7 +59,7 @@ def test_streaming_response_create(self, client: Mixedbread) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" embedding = response.parse() - assert_matches_type(Em, embedding, path=["response"]) + assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"]) assert cast(Any, response.is_closed) is True @@ -73,7 +73,7 @@ async def test_method_create(self, async_client: AsyncMixedbread) -> None: model="mixedbread-ai/mxbai-embed-large-v1", input=["string"], ) - assert_matches_type(Em, embedding, path=["response"]) + assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncMixedbread) -> None: @@ -85,7 +85,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncMixedbread normalized=True, encoding_format="float", ) - assert_matches_type(Em, embedding, path=["response"]) + assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncMixedbread) -> None: @@ -97,7 +97,7 @@ async def test_raw_response_create(self, async_client: AsyncMixedbread) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" embedding = await response.parse() - assert_matches_type(Em, embedding, path=["response"]) + assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncMixedbread) -> None: @@ -109,6 +109,6 @@ async def test_streaming_response_create(self, async_client: AsyncMixedbread) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" embedding = await response.parse() - assert_matches_type(Em, embedding, path=["response"]) + assert_matches_type(EmbeddingCreateResponse, embedding, path=["response"]) assert cast(Any, response.is_closed) is True