Skip to content
Closed
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 .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.41"
".": "1.0.0"
}
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: daf46fcf1979db0bfe4221c9a4197cd1
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 1.0.0 (2025-04-03)

Full Changelog: [v0.1.0-alpha.41...v1.0.0](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.1.0-alpha.41...v1.0.0)

### Features

* **api:** update via SDK Studio ([#180](https://github.com/mixedbread-ai/mixedbread-python/issues/180)) ([312a603](https://github.com/mixedbread-ai/mixedbread-python/commit/312a603bb67da9ff8409b1e0950a0dee03200636))
* **api:** update via SDK Studio ([#182](https://github.com/mixedbread-ai/mixedbread-python/issues/182)) ([33480fc](https://github.com/mixedbread-ai/mixedbread-python/commit/33480fca59f6b3f67ad5acee09781ef22e240600))
* **api:** update via SDK Studio ([#184](https://github.com/mixedbread-ai/mixedbread-python/issues/184)) ([651e092](https://github.com/mixedbread-ai/mixedbread-python/commit/651e0923c62e32345dfc39d67e38ef41dcc22028))

## 0.1.0-alpha.41 (2025-04-03)

Full Changelog: [v0.1.0-alpha.40...v0.1.0-alpha.41](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.1.0-alpha.40...v0.1.0-alpha.41)
Expand Down
110 changes: 77 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The REST API documentation can be found on [mixedbread.com](https://mixedbread.c

```sh
# install from PyPI
pip install --pre mixedbread
pip install mixedbread
```

## Usage
Expand All @@ -33,11 +33,8 @@ client = Mixedbread(
environment="local",
)

response = client.vector_stores.search(
query="how to configure SSL",
vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
)
print(response.object)
vector_store = client.vector_stores.create()
print(vector_store.id)
```

While you can provide an `api_key` keyword argument,
Expand All @@ -62,11 +59,8 @@ client = AsyncMixedbread(


async def main() -> None:
response = await client.vector_stores.search(
query="how to configure SSL",
vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
)
print(response.object)
vector_store = await client.vector_stores.create()
print(vector_store.id)


asyncio.run(main())
Expand All @@ -83,6 +77,71 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ

Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.

## Pagination

List methods in the Mixedbread API are paginated.

This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:

```python
from mixedbread import Mixedbread

client = Mixedbread()

all_vector_stores = []
# Automatically fetches more pages as needed.
for vector_store in client.vector_stores.list():
# Do something with vector_store here
all_vector_stores.append(vector_store)
print(all_vector_stores)
```

Or, asynchronously:

```python
import asyncio
from mixedbread import AsyncMixedbread

client = AsyncMixedbread()


async def main() -> None:
all_vector_stores = []
# Iterate through items across all pages, issuing requests as needed.
async for vector_store in client.vector_stores.list():
all_vector_stores.append(vector_store)
print(all_vector_stores)


asyncio.run(main())
```

Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:

```python
first_page = await client.vector_stores.list()
if first_page.has_next_page():
print(f"will fetch next page using these details: {first_page.next_page_info()}")
next_page = await first_page.get_next_page()
print(f"number of items we just fetched: {len(next_page.data)}")

# Remove `await` for non-async usage.
```

Or just work directly with the returned data:

```python
first_page = await client.vector_stores.list()

print(
f"the current start offset for this page: {first_page.pagination.offset}"
) # => "the current start offset for this page: 1"
for vector_store in first_page.data:
print(vector_store.id)

# Remove `await` for non-async usage.
```

## Nested params

Nested parameters are dictionaries, typed using `TypedDict`, for example:
Expand Down Expand Up @@ -134,10 +193,7 @@ from mixedbread import Mixedbread
client = Mixedbread()

try:
client.vector_stores.search(
query="how to configure SSL",
vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
)
client.vector_stores.create()
except mixedbread.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
Expand Down Expand Up @@ -180,10 +236,7 @@ client = Mixedbread(
)

# Or, configure per-request:
client.with_options(max_retries=5).vector_stores.search(
query="how to configure SSL",
vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
)
client.with_options(max_retries=5).vector_stores.create()
```

### Timeouts
Expand All @@ -206,10 +259,7 @@ client = Mixedbread(
)

# Override per-request:
client.with_options(timeout=5.0).vector_stores.search(
query="how to configure SSL",
vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
)
client.with_options(timeout=5.0).vector_stores.create()
```

On timeout, an `APITimeoutError` is thrown.
Expand Down Expand Up @@ -250,14 +300,11 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
from mixedbread import Mixedbread

client = Mixedbread()
response = client.vector_stores.with_raw_response.search(
query="how to configure SSL",
vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
)
response = client.vector_stores.with_raw_response.create()
print(response.headers.get('X-My-Header'))

vector_store = response.parse() # get the object that `vector_stores.search()` would have returned
print(vector_store.object)
vector_store = response.parse() # get the object that `vector_stores.create()` would have returned
print(vector_store.id)
```

These methods return an [`APIResponse`](https://github.com/mixedbread-ai/mixedbread-python/tree/main/src/mixedbread/_response.py) object.
Expand All @@ -271,10 +318,7 @@ The above interface eagerly reads the full response body when you make the reque
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.

```python
with client.vector_stores.with_streaming_response.search(
query="how to configure SSL",
vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
) as response:
with client.vector_stores.with_streaming_response.create() as response:
print(response.headers.get("X-My-Header"))

for line in response.iter_lines():
Expand Down
12 changes: 9 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,
EmbeddingCreateResponse,
MultiEncodingEmbedding,
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/embedding_create_response.py">EmbeddingCreateResponse</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 @@ -147,4 +153,4 @@ Methods:

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>
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mixedbread"
version = "0.1.0-alpha.41"
version = "1.0.0"
description = "The official Python library for the Mixedbread API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
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 @@ -51,6 +50,7 @@
from .resources.extractions import extractions
from .types.rerank_response import RerankResponse
from .resources.vector_stores import vector_stores
from .types.embedding_create_response import EmbeddingCreateResponse

__all__ = [
"ENVIRONMENTS",
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:
) -> EmbeddingCreateResponse:
"""
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=EmbeddingCreateResponse,
)

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:
) -> EmbeddingCreateResponse:
"""
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=EmbeddingCreateResponse,
)

async def info(
Expand Down
2 changes: 1 addition & 1 deletion src/mixedbread/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "mixedbread"
__version__ = "0.1.0-alpha.41" # x-release-please-version
__version__ = "1.0.0" # x-release-please-version
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
2 changes: 1 addition & 1 deletion src/mixedbread/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,6 +20,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__ = ["EmbeddingCreateResponse", "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 EmbeddingCreateResponse(BaseModel):
usage: Usage
"""The usage of the model"""

Expand Down
Loading
Loading