diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index db3930fd..9c28aaea 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.1.0-alpha.40"
+ ".": "0.1.0-alpha.41"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index a346743e..00db8629 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: 6552b029ab372150ad4054acd59dde95
+config_hash: 2a44785dc321bd6e458c4e767035de1b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a3df2ea2..3d22e525 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## 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)
+
+### Features
+
+* **api:** update via SDK Studio ([#178](https://github.com/mixedbread-ai/mixedbread-python/issues/178)) ([f829faa](https://github.com/mixedbread-ai/mixedbread-python/commit/f829faa2fc0f062ece2c3a63e4cd4819a4f3d866))
+
## 0.1.0-alpha.40 (2025-04-03)
Full Changelog: [v0.1.0-alpha.39...v0.1.0-alpha.40](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.1.0-alpha.39...v0.1.0-alpha.40)
diff --git a/README.md b/README.md
index 5d3e4084..3d966cc2 100644
--- a/README.md
+++ b/README.md
@@ -33,8 +33,11 @@ client = Mixedbread(
environment="local",
)
-vector_store = client.vector_stores.create()
-print(vector_store.id)
+response = client.vector_stores.search(
+ query="how to configure SSL",
+ vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
+)
+print(response.object)
```
While you can provide an `api_key` keyword argument,
@@ -59,8 +62,11 @@ client = AsyncMixedbread(
async def main() -> None:
- vector_store = await client.vector_stores.create()
- print(vector_store.id)
+ response = await client.vector_stores.search(
+ query="how to configure SSL",
+ vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
+ )
+ print(response.object)
asyncio.run(main())
@@ -77,71 +83,6 @@ 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:
@@ -193,7 +134,10 @@ from mixedbread import Mixedbread
client = Mixedbread()
try:
- client.vector_stores.create()
+ client.vector_stores.search(
+ query="how to configure SSL",
+ vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
+ )
except mixedbread.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
@@ -236,7 +180,10 @@ client = Mixedbread(
)
# Or, configure per-request:
-client.with_options(max_retries=5).vector_stores.create()
+client.with_options(max_retries=5).vector_stores.search(
+ query="how to configure SSL",
+ vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
+)
```
### Timeouts
@@ -259,7 +206,10 @@ client = Mixedbread(
)
# Override per-request:
-client.with_options(timeout=5.0).vector_stores.create()
+client.with_options(timeout=5.0).vector_stores.search(
+ query="how to configure SSL",
+ vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
+)
```
On timeout, an `APITimeoutError` is thrown.
@@ -300,11 +250,14 @@ 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.create()
+response = client.vector_stores.with_raw_response.search(
+ query="how to configure SSL",
+ vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
+)
print(response.headers.get('X-My-Header'))
-vector_store = response.parse() # get the object that `vector_stores.create()` would have returned
-print(vector_store.id)
+vector_store = response.parse() # get the object that `vector_stores.search()` would have returned
+print(vector_store.object)
```
These methods return an [`APIResponse`](https://github.com/mixedbread-ai/mixedbread-python/tree/main/src/mixedbread/_response.py) object.
@@ -318,7 +271,10 @@ 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.create() as response:
+with client.vector_stores.with_streaming_response.search(
+ query="how to configure SSL",
+ vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
+) as response:
print(response.headers.get("X-My-Header"))
for line in response.iter_lines():
diff --git a/api.md b/api.md
index a7d820d8..556c3a91 100644
--- a/api.md
+++ b/api.md
@@ -9,18 +9,12 @@ from mixedbread.types import SearchFilter, SearchFilterCondition
Types:
```python
-from mixedbread.types import (
- Embedding,
- EmbeddingCreateResponse,
- MultiEncodingEmbedding,
- InfoResponse,
- RerankResponse,
-)
+from mixedbread.types import Em, Embedding, MultiEncodingEmbedding, InfoResponse, RerankResponse
```
Methods:
-- client.embed(\*\*params) -> EmbeddingCreateResponse
+- client.embed(\*\*params) -> Em
- client.info() -> InfoResponse
- client.rerank(\*\*params) -> RerankResponse
@@ -153,4 +147,4 @@ Methods:
Methods:
-- client.embeddings.create(\*\*params) -> EmbeddingCreateResponse
+- client.embeddings.create(\*\*params) -> Em
diff --git a/pyproject.toml b/pyproject.toml
index f124245d..8871ff50 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "mixedbread"
-version = "0.1.0-alpha.40"
+version = "0.1.0-alpha.41"
description = "The official Python library for the Mixedbread API"
dynamic = ["readme"]
license = "Apache-2.0"
diff --git a/src/mixedbread/_client.py b/src/mixedbread/_client.py
index 30ff9cca..29b4d595 100644
--- a/src/mixedbread/_client.py
+++ b/src/mixedbread/_client.py
@@ -30,6 +30,7 @@
async_maybe_transform,
)
from ._version import __version__
+from .types.em import Em
from ._response import (
to_raw_response_wrapper,
to_streamed_response_wrapper,
@@ -50,7 +51,6 @@
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",
@@ -257,7 +257,7 @@ def embed(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> EmbeddingCreateResponse:
+ ) -> Em:
"""
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=EmbeddingCreateResponse,
+ cast_to=Em,
)
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,
- ) -> EmbeddingCreateResponse:
+ ) -> Em:
"""
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=EmbeddingCreateResponse,
+ cast_to=Em,
)
async def info(
diff --git a/src/mixedbread/_version.py b/src/mixedbread/_version.py
index 92e78fd7..18d791e8 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.1.0-alpha.40" # x-release-please-version
+__version__ = "0.1.0-alpha.41" # x-release-please-version
diff --git a/src/mixedbread/resources/embeddings.py b/src/mixedbread/resources/embeddings.py
index d7390eda..f2adc49c 100644
--- a/src/mixedbread/resources/embeddings.py
+++ b/src/mixedbread/resources/embeddings.py
@@ -14,6 +14,7 @@
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,
@@ -22,7 +23,6 @@
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,
- ) -> EmbeddingCreateResponse:
+ ) -> Em:
"""
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=EmbeddingCreateResponse,
+ cast_to=Em,
)
@@ -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,
- ) -> EmbeddingCreateResponse:
+ ) -> Em:
"""
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=EmbeddingCreateResponse,
+ cast_to=Em,
)
diff --git a/src/mixedbread/types/__init__.py b/src/mixedbread/types/__init__.py
index ae8ce3a4..c48a74b0 100644
--- a/src/mixedbread/types/__init__.py
+++ b/src/mixedbread/types/__init__.py
@@ -2,6 +2,7 @@
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
@@ -20,7 +21,6 @@
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/embedding_create_response.py b/src/mixedbread/types/em.py
similarity index 94%
rename from src/mixedbread/types/embedding_create_response.py
rename to src/mixedbread/types/em.py
index 8f3605cb..12277e0a 100644
--- a/src/mixedbread/types/embedding_create_response.py
+++ b/src/mixedbread/types/em.py
@@ -7,7 +7,7 @@
from .embedding import Embedding
from .multi_encoding_embedding import MultiEncodingEmbedding
-__all__ = ["EmbeddingCreateResponse", "Usage"]
+__all__ = ["Em", "Usage"]
class Usage(BaseModel):
@@ -21,7 +21,7 @@ class Usage(BaseModel):
"""The number of tokens used for the completion"""
-class EmbeddingCreateResponse(BaseModel):
+class Em(BaseModel):
usage: Usage
"""The usage of the model"""
diff --git a/tests/api_resources/test_client.py b/tests/api_resources/test_client.py
index 1c38d8ba..dc3ed1d8 100644
--- a/tests/api_resources/test_client.py
+++ b/tests/api_resources/test_client.py
@@ -9,11 +9,7 @@
from mixedbread import Mixedbread, AsyncMixedbread
from tests.utils import assert_matches_type
-from mixedbread.types import (
- InfoResponse,
- RerankResponse,
- EmbeddingCreateResponse,
-)
+from mixedbread.types import Em, InfoResponse, RerankResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -27,7 +23,7 @@ def test_method_embed(self, client: Mixedbread) -> None:
model="mixedbread-ai/mxbai-embed-large-v1",
input=["string"],
)
- assert_matches_type(EmbeddingCreateResponse, client_, path=["response"])
+ assert_matches_type(Em, client_, path=["response"])
@parametrize
def test_method_embed_with_all_params(self, client: Mixedbread) -> None:
@@ -39,7 +35,7 @@ def test_method_embed_with_all_params(self, client: Mixedbread) -> None:
normalized=True,
encoding_format="float",
)
- assert_matches_type(EmbeddingCreateResponse, client_, path=["response"])
+ assert_matches_type(Em, client_, path=["response"])
@parametrize
def test_raw_response_embed(self, client: Mixedbread) -> None:
@@ -51,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(EmbeddingCreateResponse, client_, path=["response"])
+ assert_matches_type(Em, client_, path=["response"])
@parametrize
def test_streaming_response_embed(self, client: Mixedbread) -> None:
@@ -63,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(EmbeddingCreateResponse, client_, path=["response"])
+ assert_matches_type(Em, client_, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -148,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(EmbeddingCreateResponse, client, path=["response"])
+ assert_matches_type(Em, client, path=["response"])
@parametrize
async def test_method_embed_with_all_params(self, async_client: AsyncMixedbread) -> None:
@@ -160,7 +156,7 @@ async def test_method_embed_with_all_params(self, async_client: AsyncMixedbread)
normalized=True,
encoding_format="float",
)
- assert_matches_type(EmbeddingCreateResponse, client, path=["response"])
+ assert_matches_type(Em, client, path=["response"])
@parametrize
async def test_raw_response_embed(self, async_client: AsyncMixedbread) -> None:
@@ -172,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(EmbeddingCreateResponse, client, path=["response"])
+ assert_matches_type(Em, client, path=["response"])
@parametrize
async def test_streaming_response_embed(self, async_client: AsyncMixedbread) -> None:
@@ -184,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(EmbeddingCreateResponse, client, path=["response"])
+ assert_matches_type(Em, 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 ffe758eb..610022ee 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 EmbeddingCreateResponse
+from mixedbread.types import Em
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(EmbeddingCreateResponse, embedding, path=["response"])
+ assert_matches_type(Em, 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(EmbeddingCreateResponse, embedding, path=["response"])
+ assert_matches_type(Em, 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(EmbeddingCreateResponse, embedding, path=["response"])
+ assert_matches_type(Em, 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(EmbeddingCreateResponse, embedding, path=["response"])
+ assert_matches_type(Em, 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(EmbeddingCreateResponse, embedding, path=["response"])
+ assert_matches_type(Em, 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(EmbeddingCreateResponse, embedding, path=["response"])
+ assert_matches_type(Em, 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(EmbeddingCreateResponse, embedding, path=["response"])
+ assert_matches_type(Em, 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(EmbeddingCreateResponse, embedding, path=["response"])
+ assert_matches_type(Em, embedding, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/test_client.py b/tests/test_client.py
index 9a2b23af..450bfe0b 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -33,7 +33,7 @@
BaseClient,
make_request_options,
)
-from mixedbread.types.vector_store_create_params import VectorStoreCreateParams
+from mixedbread.types.vector_store_search_params import VectorStoreSearchParams
from .utils import update_env
@@ -732,12 +732,18 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str
@mock.patch("mixedbread._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None:
- respx_mock.post("/v1/vector_stores").mock(side_effect=httpx.TimeoutException("Test timeout error"))
+ respx_mock.post("/v1/vector_stores/search").mock(side_effect=httpx.TimeoutException("Test timeout error"))
with pytest.raises(APITimeoutError):
self.client.post(
- "/v1/vector_stores",
- body=cast(object, maybe_transform({}, VectorStoreCreateParams)),
+ "/v1/vector_stores/search",
+ body=cast(
+ object,
+ maybe_transform(
+ dict(query="how to configure SSL", vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"]),
+ VectorStoreSearchParams,
+ ),
+ ),
cast_to=httpx.Response,
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
)
@@ -747,12 +753,18 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> No
@mock.patch("mixedbread._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> None:
- respx_mock.post("/v1/vector_stores").mock(return_value=httpx.Response(500))
+ respx_mock.post("/v1/vector_stores/search").mock(return_value=httpx.Response(500))
with pytest.raises(APIStatusError):
self.client.post(
- "/v1/vector_stores",
- body=cast(object, maybe_transform({}, VectorStoreCreateParams)),
+ "/v1/vector_stores/search",
+ body=cast(
+ object,
+ maybe_transform(
+ dict(query="how to configure SSL", vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"]),
+ VectorStoreSearchParams,
+ ),
+ ),
cast_to=httpx.Response,
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
)
@@ -783,9 +795,11 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
return httpx.Response(500)
return httpx.Response(200)
- respx_mock.post("/v1/vector_stores").mock(side_effect=retry_handler)
+ respx_mock.post("/v1/vector_stores/search").mock(side_effect=retry_handler)
- response = client.vector_stores.with_raw_response.create()
+ response = client.vector_stores.with_raw_response.search(
+ query="how to configure SSL", vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"]
+ )
assert response.retries_taken == failures_before_success
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@@ -807,9 +821,13 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
return httpx.Response(500)
return httpx.Response(200)
- respx_mock.post("/v1/vector_stores").mock(side_effect=retry_handler)
+ respx_mock.post("/v1/vector_stores/search").mock(side_effect=retry_handler)
- response = client.vector_stores.with_raw_response.create(extra_headers={"x-stainless-retry-count": Omit()})
+ response = client.vector_stores.with_raw_response.search(
+ query="how to configure SSL",
+ vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
+ extra_headers={"x-stainless-retry-count": Omit()},
+ )
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
@@ -830,9 +848,13 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
return httpx.Response(500)
return httpx.Response(200)
- respx_mock.post("/v1/vector_stores").mock(side_effect=retry_handler)
+ respx_mock.post("/v1/vector_stores/search").mock(side_effect=retry_handler)
- response = client.vector_stores.with_raw_response.create(extra_headers={"x-stainless-retry-count": "42"})
+ response = client.vector_stores.with_raw_response.search(
+ query="how to configure SSL",
+ vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
+ extra_headers={"x-stainless-retry-count": "42"},
+ )
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
@@ -1518,12 +1540,18 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte
@mock.patch("mixedbread._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None:
- respx_mock.post("/v1/vector_stores").mock(side_effect=httpx.TimeoutException("Test timeout error"))
+ respx_mock.post("/v1/vector_stores/search").mock(side_effect=httpx.TimeoutException("Test timeout error"))
with pytest.raises(APITimeoutError):
await self.client.post(
- "/v1/vector_stores",
- body=cast(object, maybe_transform({}, VectorStoreCreateParams)),
+ "/v1/vector_stores/search",
+ body=cast(
+ object,
+ maybe_transform(
+ dict(query="how to configure SSL", vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"]),
+ VectorStoreSearchParams,
+ ),
+ ),
cast_to=httpx.Response,
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
)
@@ -1533,12 +1561,18 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter)
@mock.patch("mixedbread._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> None:
- respx_mock.post("/v1/vector_stores").mock(return_value=httpx.Response(500))
+ respx_mock.post("/v1/vector_stores/search").mock(return_value=httpx.Response(500))
with pytest.raises(APIStatusError):
await self.client.post(
- "/v1/vector_stores",
- body=cast(object, maybe_transform({}, VectorStoreCreateParams)),
+ "/v1/vector_stores/search",
+ body=cast(
+ object,
+ maybe_transform(
+ dict(query="how to configure SSL", vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"]),
+ VectorStoreSearchParams,
+ ),
+ ),
cast_to=httpx.Response,
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
)
@@ -1570,9 +1604,11 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
return httpx.Response(500)
return httpx.Response(200)
- respx_mock.post("/v1/vector_stores").mock(side_effect=retry_handler)
+ respx_mock.post("/v1/vector_stores/search").mock(side_effect=retry_handler)
- response = await client.vector_stores.with_raw_response.create()
+ response = await client.vector_stores.with_raw_response.search(
+ query="how to configure SSL", vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"]
+ )
assert response.retries_taken == failures_before_success
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@@ -1595,10 +1631,12 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
return httpx.Response(500)
return httpx.Response(200)
- respx_mock.post("/v1/vector_stores").mock(side_effect=retry_handler)
+ respx_mock.post("/v1/vector_stores/search").mock(side_effect=retry_handler)
- response = await client.vector_stores.with_raw_response.create(
- extra_headers={"x-stainless-retry-count": Omit()}
+ response = await client.vector_stores.with_raw_response.search(
+ query="how to configure SSL",
+ vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
+ extra_headers={"x-stainless-retry-count": Omit()},
)
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
@@ -1621,9 +1659,13 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
return httpx.Response(500)
return httpx.Response(200)
- respx_mock.post("/v1/vector_stores").mock(side_effect=retry_handler)
+ respx_mock.post("/v1/vector_stores/search").mock(side_effect=retry_handler)
- response = await client.vector_stores.with_raw_response.create(extra_headers={"x-stainless-retry-count": "42"})
+ response = await client.vector_stores.with_raw_response.search(
+ query="how to configure SSL",
+ vector_store_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
+ extra_headers={"x-stainless-retry-count": "42"},
+ )
assert response.http_request.headers.get("x-stainless-retry-count") == "42"