Skip to content
Open
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
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ jobs:
run: rye build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/hyperspell-python'
if: |-
github.repository == 'stainless-sdks/hyperspell-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: github.repository == 'stainless-sdks/hyperspell-python'
if: |-
github.repository == 'stainless-sdks/hyperspell-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
publish:
name: publish
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v6
Expand All @@ -27,5 +30,3 @@ jobs:
- name: Publish to PyPI
run: |
bash ./bin/publish-pypi
env:
PYPI_TOKEN: ${{ secrets.HYPERSPELL_PYPI_TOKEN || secrets.PYPI_TOKEN }}
2 changes: 0 additions & 2 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ jobs:
- name: Check release environment
run: |
bash ./bin/check-release-environment
env:
PYPI_TOKEN: ${{ secrets.HYPERSPELL_PYPI_TOKEN || secrets.PYPI_TOKEN }}
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.33.0"
".": "0.34.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 23
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-36cb6e2474f3fe09749b7a2f24409d48c8db332d624fa7eeb1ee6b6135774133.yml
openapi_spec_hash: 339a1b55d6b1a55213d16bf336045d0d
config_hash: 983708fc30c86269c2149a960d0bfec1
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-e94268bb224f0aa46f151c81dba49c8def81c73b48da8a6f31b4f8a60aa5055c.yml
openapi_spec_hash: 2e2f8148f72a724fbafd05c51b7a62c9
config_hash: b387daed43fa717ef3ac5811ae06307c
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

## 0.34.0 (2026-03-14)

Full Changelog: [v0.33.0...v0.34.0](https://github.com/hyperspell/python-sdk/compare/v0.33.0...v0.34.0)

### Features

* **api:** api update ([f690c84](https://github.com/hyperspell/python-sdk/commit/f690c841ce28801b1511142026b62d7fcc2706ba))
* **api:** api update ([784a11e](https://github.com/hyperspell/python-sdk/commit/784a11e826b748f682186bbb39e8f7580cb4d683))
* **api:** api update ([0f66c9d](https://github.com/hyperspell/python-sdk/commit/0f66c9dfe8e50d22f1a66f6de9b3ee0f1a89ab38))
* **api:** api update ([b76b873](https://github.com/hyperspell/python-sdk/commit/b76b873e4c01f4c9421cc6e452f216c19374b687))
* **api:** api update ([b75e2b3](https://github.com/hyperspell/python-sdk/commit/b75e2b3bbb5a871a39d147e4cb0949d7279f3271))
* **api:** api update ([d330dea](https://github.com/hyperspell/python-sdk/commit/d330deaec6f907f4abee6dd8fc786da018ea72a7))
* **api:** api update ([e01d911](https://github.com/hyperspell/python-sdk/commit/e01d911cb400b1ee3827332299f054d278f867d4))
* **api:** manual updates ([48f1e5b](https://github.com/hyperspell/python-sdk/commit/48f1e5b7a76e607c52a3a29c289352e07ca466c6))


### Chores

* **api:** python trusted publisher ([3d7a283](https://github.com/hyperspell/python-sdk/commit/3d7a283ebe54b78a23964a17a3167c50da0aeba2))
* **ci:** skip uploading artifacts on stainless-internal branches ([2361dcb](https://github.com/hyperspell/python-sdk/commit/2361dcb5e76f8aeca00e12a4fcf6b912fca1084a))
* **internal:** add request options to SSE classes ([6b5c9ad](https://github.com/hyperspell/python-sdk/commit/6b5c9ad8271ecb8887faf8cb678805e6d481459c))
* **internal:** make `test_proxy_environment_variables` more resilient ([3cc3332](https://github.com/hyperspell/python-sdk/commit/3cc33321d35a6162c6c8540b571d4d3c2b63a022))
* **internal:** make `test_proxy_environment_variables` more resilient to env ([2c99a7f](https://github.com/hyperspell/python-sdk/commit/2c99a7f619b2581f2bf7bc2bea4519fc1f6c5733))
* **test:** do not count install time for mock server timeout ([ee29761](https://github.com/hyperspell/python-sdk/commit/ee29761e756adb19eb1f07232abde4e2a1e20d4f))
* update placeholder string ([5608e0b](https://github.com/hyperspell/python-sdk/commit/5608e0bb6e840cd1b52b8ca79ec6042bc704de82))

## 0.33.0 (2026-02-20)

Full Changelog: [v0.32.0...v0.33.0](https://github.com/hyperspell/python-sdk/compare/v0.32.0...v0.33.0)
Expand Down
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ client = Hyperspell()

all_memories = []
# Automatically fetches more pages as needed.
for memory in client.memories.list(
collection="REPLACE_ME",
):
for memory in client.memories.list():
# Do something with memory here
all_memories.append(memory)
print(all_memories)
Expand All @@ -154,9 +152,7 @@ client = AsyncHyperspell()
async def main() -> None:
all_memories = []
# Iterate through items across all pages, issuing requests as needed.
async for memory in client.memories.list(
collection="REPLACE_ME",
):
async for memory in client.memories.list():
all_memories.append(memory)
print(all_memories)

Expand All @@ -167,9 +163,7 @@ 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.memories.list(
collection="REPLACE_ME",
)
first_page = await client.memories.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()
Expand All @@ -181,9 +175,7 @@ if first_page.has_next_page():
Or just work directly with the returned data:

```python
first_page = await client.memories.list(
collection="REPLACE_ME",
)
first_page = await client.memories.list()

print(f"next page cursor: {first_page.next_cursor}") # => "next page cursor: ..."
for memory in first_page.items:
Expand Down
4 changes: 0 additions & 4 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

errors=()

Comment on lines 2 to 4

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness: Removing the PYPI_TOKEN validation lets the script pass even when the token is unset, which can cause release failures later (or worse, publish without auth). Reintroduce the check to fail fast when the secret is missing. 🚨

🤖 AI Agent Prompt for Cursor/Windsurf

📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue

In `bin/check-release-environment` around lines 2-4, reintroduce the PYPI_TOKEN validation block so the script errors when the token is missing. Restore the removed `if [ -z "${PYPI_TOKEN}" ]; then ... fi` block before `lenErrors`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness: Removing the PYPI_TOKEN check means the script now reports the environment as ready even when credentials are missing, which will cause release failures later and make debugging harder. Please restore a preflight validation (or equivalent) before computing lenErrors.

🤖 AI Agent Prompt for Cursor/Windsurf

📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue

In `bin/check-release-environment` around lines 2-6, reintroduce the preflight validation for `PYPI_TOKEN` so the script fails early when credentials are missing. Insert the check between `errors=()` and `lenErrors=${#errors[@]}`.

if [ -z "${PYPI_TOKEN}" ]; then
errors+=("The PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
fi

lenErrors=${#errors[@]}

if [[ lenErrors -gt 0 ]]; then
Comment on lines 4 to 7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness: Removing the PYPI_TOKEN validation makes this script always report the environment as ready, even when the token is unset. That can lead to a release failure later in the pipeline; restore the check so missing secrets fail fast. ⚠️

🤖 AI Agent Prompt for Cursor/Windsurf

📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue

In `bin/check-release-environment` around lines 4-7, reintroduce the PYPI_TOKEN presence check so missing tokens populate the `errors` array and prevent false 'ready' reports. Apply the provided diff snippet exactly.

Comment on lines 4 to 7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness: Removing the PYPI_TOKEN validation means the script will always report the environment as ready even when the token is missing, causing the release process to fail silently at the publish step rather than providing an early, clear error.

🤖 AI Agent Prompt for Cursor/Windsurf

📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue

In bin/check-release-environment, the check for PYPI_TOKEN was removed (lines 4-7 of the diff). Restore the validation block so the script fails early with a clear message when PYPI_TOKEN is not set:

if [ -z "${PYPI_TOKEN}" ]; then
  errors+=("The PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
fi

Add this back before the 'lenErrors=${#errors[@]}' line.

Comment on lines 4 to 7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness: Removing the PYPI_TOKEN validation means the release script will no longer catch a missing PyPI token before attempting to publish, causing silent failures or cryptic errors during the release process.

🤖 AI Agent Prompt for Cursor/Windsurf

📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue

In bin/check-release-environment, the PYPI_TOKEN validation block was removed (lines 4-7 in the diff). Restore the check:

if [ -z "${PYPI_TOKEN}" ]; then
  errors+=("The PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
fi

This block should appear before `lenErrors=${#errors[@]}` to ensure a missing PyPI token is caught before a release is attempted.

Expand Down
6 changes: 5 additions & 1 deletion bin/publish-pypi
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
set -eux
mkdir -p dist
rye build --clean
rye publish --yes --token=$PYPI_TOKEN
if [ -n "${PYPI_TOKEN:-}" ]; then
rye publish --yes --token=$PYPI_TOKEN
else
rye publish --yes
fi
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "hyperspell"
version = "0.33.0"
version = "0.34.0"
description = "The official Python library for the hyperspell API"
dynamic = ["readme"]
license = "MIT"
Expand Down
13 changes: 12 additions & 1 deletion scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
# Pre-install the package so the download doesn't eat into the startup timeout
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version

npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &

# Wait for server to come online
# Wait for server to come online (max 30s)
echo -n "Waiting for server"
attempts=0
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
attempts=$((attempts + 1))
if [ "$attempts" -ge 300 ]; then
echo
echo "Timed out waiting for Prism server to start"
cat .prism.log
exit 1
fi
echo -n "."
sleep 0.1
done
Expand Down
3 changes: 3 additions & 0 deletions src/hyperspell/_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
),
response=self.http_response,
client=cast(Any, self._client),
options=self._options,
),
)

Expand All @@ -162,6 +163,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
cast_to=extract_stream_chunk_type(self._stream_cls),
response=self.http_response,
client=cast(Any, self._client),
options=self._options,
),
)

Expand All @@ -175,6 +177,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
cast_to=cast_to,
response=self.http_response,
client=cast(Any, self._client),
options=self._options,
),
)

Expand Down
11 changes: 8 additions & 3 deletions src/hyperspell/_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import inspect
Comment on lines 4 to 5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate Code: ⚠️ Duplicate Code Detected (Similarity: 95%)

This function Stream.__init__ (options handling addition) duplicates existing code.

📍 Original Location:

src/hyperspell/_streaming.py:6-8

Function: AsyncStream.__init__ (options handling addition)

💡 Recommendation:
Extract the options-storage pattern into a shared mixin or base class. For example, a _OptionsHolder mixin with _options: Optional[FinalRequestOptions] = None and an _init_options(self, options) helper could be inherited by both Stream and AsyncStream. Alternatively, since BaseAPIResponse already carries _options and the stream is always constructed from a response object, consider passing the options via the response rather than re-threading them through the stream constructor.

Consider importing and reusing the existing function instead of duplicating the logic.

from types import TracebackType
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Iterator, AsyncIterator, cast
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Iterator, Optional, AsyncIterator, cast
from typing_extensions import Self, Protocol, TypeGuard, override, get_origin, runtime_checkable

import httpx
Expand All @@ -13,6 +13,7 @@

if TYPE_CHECKING:
from ._client import Hyperspell, AsyncHyperspell
from ._models import FinalRequestOptions


_T = TypeVar("_T")
Expand All @@ -22,7 +23,7 @@ class Stream(Generic[_T]):
"""Provides the core interface to iterate over a synchronous stream response."""

response: httpx.Response

_options: Optional[FinalRequestOptions] = None
_decoder: SSEBytesDecoder

def __init__(
Expand All @@ -31,6 +32,7 @@ def __init__(
cast_to: type[_T],
response: httpx.Response,
client: Hyperspell,
options: Optional[FinalRequestOptions] = None,
timeout: float | None = None,
) -> None:
"""Initialize the synchronous stream.
Expand All @@ -44,6 +46,7 @@ def __init__(
self.response = response
self._cast_to = cast_to
self._client = client
self._options = options
Comment on lines 46 to +49

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate Code: ⚠️ Duplicate Code Detected (Similarity: 95%)

This function Stream.__init__ duplicates existing code.

📍 Original Location:

src/hyperspell/_streaming.py:121-142

Function: AsyncStream.__init__

💡 Recommendation:
Introduce an abstract base class (e.g., BaseStream) that holds the shared state: _options, _cast_to, _client, _timeout, and their initialization. Both Stream and AsyncStream can inherit from it, eliminating the duplicated __init__ initialization block. Alternatively, if the sync/async split makes inheritance awkward, at least extract the shared options initialization into a _init_options(self, options) helper or use a @dataclass-style mixin.

Consider importing and reusing the existing function instead of duplicating the logic.

Comment on lines 46 to +49

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate Code: ⚠️ Duplicate Code Detected (Similarity: 97%)

This function Stream.__init__ (options parameter addition) duplicates existing code.

📍 Original Location:

src/hyperspell/_streaming.py:120-142

Function: AsyncStream.__init__ (options parameter addition)

💡 Recommendation:
Introduce a shared base class (e.g., BaseStream) that holds the common state (_cast_to, _client, _timeout, _options) and the corresponding init parameters, then have Stream and AsyncStream inherit from it. This avoids repeating identical field declarations every time a new shared attribute is added to both classes. Alternatively, at minimum, add a brief comment cross-referencing the mirrored change so future maintainers know to update both classes in tandem.

Consider importing and reusing the existing function instead of duplicating the logic.

Comment on lines 46 to +49

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate Code: ⚠️ Duplicate Code Detected (Similarity: 90%)

This function Stream.__init__ duplicates existing code.

📍 Original Location:

src/hyperspell/_streaming.py:121-142

Function: AsyncStream.__init__

💡 Recommendation:
Consider extracting a BaseStream generic base class containing the shared initialization logic (_cast_to, _client, _timeout, _options, _decoder fields), with Stream and AsyncStream inheriting and only implementing the async/sync-specific iterator methods. This would mean the _options addition only needs to happen once in the base class.

Consider importing and reusing the existing function instead of duplicating the logic.

self._timeout = timeout
self._decoder = client._make_sse_decoder()
self._iterator = self.__stream__()
Expand Down Expand Up @@ -115,7 +118,7 @@ class AsyncStream(Generic[_T]):
"""Provides the core interface to iterate over an asynchronous stream response."""

response: httpx.Response

_options: Optional[FinalRequestOptions] = None
_decoder: SSEDecoder | SSEBytesDecoder

def __init__(
Expand All @@ -124,6 +127,7 @@ def __init__(
cast_to: type[_T],
response: httpx.Response,
client: AsyncHyperspell,
options: Optional[FinalRequestOptions] = None,
timeout: float | None = None,
) -> None:
"""Initialize the asynchronous stream.
Expand All @@ -137,6 +141,7 @@ def __init__(
self.response = response
self._cast_to = cast_to
self._client = client
self._options = options
self._timeout = timeout
self._decoder = client._make_sse_decoder()
self._iterator = self.__stream__()
Expand Down
2 changes: 1 addition & 1 deletion src/hyperspell/_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__ = "hyperspell"
__version__ = "0.33.0" # x-release-please-version
__version__ = "0.34.0" # x-release-please-version
Loading