Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 15 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

- <code title="post /v1/embeddings">client.<a href="./src/mixedbread/_client.py">embed</a>(\*\*<a href="src/mixedbread/types/client_embed_params.py">params</a>) -> <a href="./src/mixedbread/types/em.py">Em</a></code>
- <code title="post /v1/embeddings">client.<a href="./src/mixedbread/_client.py">embed</a>(\*\*<a href="src/mixedbread/types/client_embed_params.py">params</a>) -> <a href="./src/mixedbread/types/embed_response.py">EmbedResponse</a></code>
- <code title="get /">client.<a href="./src/mixedbread/_client.py">info</a>() -> <a href="./src/mixedbread/types/info_response.py">InfoResponse</a></code>
- <code title="post /v1/reranking">client.<a href="./src/mixedbread/_client.py">rerank</a>(\*\*<a href="src/mixedbread/types/client_rerank_params.py">params</a>) -> <a href="./src/mixedbread/types/rerank_response.py">RerankResponse</a></code>

Expand Down Expand Up @@ -145,6 +151,12 @@ Methods:

# Embeddings

Types:

```python
from mixedbread.types import EmbeddingCreateResponse
```

Methods:

- <code title="post /v1/embeddings">client.embeddings.<a href="./src/mixedbread/resources/embeddings.py">create</a>(\*\*<a href="src/mixedbread/types/embedding_create_params.py">params</a>) -> <a href="./src/mixedbread/types/em.py">Em</a></code>
- <code title="post /v1/embeddings">client.embeddings.<a href="./src/mixedbread/resources/embeddings.py">create</a>(\*\*<a href="src/mixedbread/types/embedding_create_params.py">params</a>) -> <a href="./src/mixedbread/types/embedding_create_response.py">EmbeddingCreateResponse</a></code>
10 changes: 5 additions & 5 deletions src/mixedbread/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions src/mixedbread/resources/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"]

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
)


Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
)


Expand Down
3 changes: 2 additions & 1 deletion src/mixedbread/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

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
from .file_object import FileObject as FileObject
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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .embedding import Embedding
from .multi_encoding_embedding import MultiEncodingEmbedding

__all__ = ["Em", "Usage"]
__all__ = ["EmbedResponse", "Usage"]


class Usage(BaseModel):
Expand All @@ -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"""

Expand Down
60 changes: 60 additions & 0 deletions src/mixedbread/types/embedding_create_response.py
Original file line number Diff line number Diff line change
@@ -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."""
18 changes: 9 additions & 9 deletions tests/api_resources/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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

Expand Down
Loading