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
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 5
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-63f6c69af7e01f89d3fcae7ff327ead30958f0e8d893deb0f0e38826361691bb.yml
configured_endpoints: 3
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-458ea970d3418ec635638d00fc0a6a1bacf213a22be5151a04c6107bf693d64d.yml
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ from hyperspell import Hyperspell

client = Hyperspell()

response = client.ingest.add()
print(response.document_id)
query = client.query.retrieve(
query="query",
)
```

While you can provide a `bearer_token` keyword argument,
Expand All @@ -49,8 +50,9 @@ client = AsyncHyperspell()


async def main() -> None:
response = await client.ingest.add()
print(response.document_id)
query = await client.query.retrieve(
query="query",
)


asyncio.run(main())
Expand Down Expand Up @@ -83,7 +85,9 @@ from hyperspell import Hyperspell
client = Hyperspell()

try:
client.ingest.add()
client.query.retrieve(
query="query",
)
except hyperspell.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
Expand Down Expand Up @@ -126,7 +130,9 @@ client = Hyperspell(
)

# Or, configure per-request:
client.with_options(max_retries=5).ingest.add()
client.with_options(max_retries=5).query.retrieve(
query="query",
)
```

### Timeouts
Expand All @@ -149,7 +155,9 @@ client = Hyperspell(
)

# Override per-request:
client.with_options(timeout=5.0).ingest.add()
client.with_options(timeout=5.0).query.retrieve(
query="query",
)
```

On timeout, an `APITimeoutError` is thrown.
Expand Down Expand Up @@ -190,11 +198,13 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
from hyperspell import Hyperspell

client = Hyperspell()
response = client.ingest.with_raw_response.add()
response = client.query.with_raw_response.retrieve(
query="query",
)
print(response.headers.get('X-My-Header'))

ingest = response.parse() # get the object that `ingest.add()` would have returned
print(ingest.document_id)
query = response.parse() # get the object that `query.retrieve()` would have returned
print(query)
```

These methods return an [`APIResponse`](https://github.com/hyperspell/python-sdk/tree/main/src/hyperspell/_response.py) object.
Expand All @@ -208,7 +218,9 @@ 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.ingest.with_streaming_response.add() as response:
with client.query.with_streaming_response.retrieve(
query="query",
) as response:
print(response.headers.get("X-My-Header"))

for line in response.iter_lines():
Expand Down
13 changes: 0 additions & 13 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
# Ingest

Types:

```python
from hyperspell.types import IngestAddResponse, IngestFileResponse
```

Methods:

- <code title="post /ingest">client.ingest.<a href="./src/hyperspell/resources/ingest.py">add</a>(\*\*<a href="src/hyperspell/types/ingest_add_params.py">params</a>) -> <a href="./src/hyperspell/types/ingest_add_response.py">IngestAddResponse</a></code>
- <code title="post /ingest_file">client.ingest.<a href="./src/hyperspell/resources/ingest.py">file</a>(\*\*<a href="src/hyperspell/types/ingest_file_params.py">params</a>) -> <a href="./src/hyperspell/types/ingest_file_response.py">object</a></code>

# Query

Types:
Expand Down
10 changes: 1 addition & 9 deletions src/hyperspell/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
get_async_library,
)
from ._version import __version__
from .resources import query, ingest, documents
from .resources import query, documents
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import APIStatusError, HyperspellError
from ._base_client import (
Expand All @@ -46,7 +46,6 @@


class Hyperspell(SyncAPIClient):
ingest: ingest.IngestResource
query: query.QueryResource
documents: documents.DocumentsResource
with_raw_response: HyperspellWithRawResponse
Expand Down Expand Up @@ -106,7 +105,6 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)

self.ingest = ingest.IngestResource(self)
self.query = query.QueryResource(self)
self.documents = documents.DocumentsResource(self)
self.with_raw_response = HyperspellWithRawResponse(self)
Expand Down Expand Up @@ -218,7 +216,6 @@ def _make_status_error(


class AsyncHyperspell(AsyncAPIClient):
ingest: ingest.AsyncIngestResource
query: query.AsyncQueryResource
documents: documents.AsyncDocumentsResource
with_raw_response: AsyncHyperspellWithRawResponse
Expand Down Expand Up @@ -278,7 +275,6 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)

self.ingest = ingest.AsyncIngestResource(self)
self.query = query.AsyncQueryResource(self)
self.documents = documents.AsyncDocumentsResource(self)
self.with_raw_response = AsyncHyperspellWithRawResponse(self)
Expand Down Expand Up @@ -391,28 +387,24 @@ def _make_status_error(

class HyperspellWithRawResponse:
def __init__(self, client: Hyperspell) -> None:
self.ingest = ingest.IngestResourceWithRawResponse(client.ingest)
self.query = query.QueryResourceWithRawResponse(client.query)
self.documents = documents.DocumentsResourceWithRawResponse(client.documents)


class AsyncHyperspellWithRawResponse:
def __init__(self, client: AsyncHyperspell) -> None:
self.ingest = ingest.AsyncIngestResourceWithRawResponse(client.ingest)
self.query = query.AsyncQueryResourceWithRawResponse(client.query)
self.documents = documents.AsyncDocumentsResourceWithRawResponse(client.documents)


class HyperspellWithStreamedResponse:
def __init__(self, client: Hyperspell) -> None:
self.ingest = ingest.IngestResourceWithStreamingResponse(client.ingest)
self.query = query.QueryResourceWithStreamingResponse(client.query)
self.documents = documents.DocumentsResourceWithStreamingResponse(client.documents)


class AsyncHyperspellWithStreamedResponse:
def __init__(self, client: AsyncHyperspell) -> None:
self.ingest = ingest.AsyncIngestResourceWithStreamingResponse(client.ingest)
self.query = query.AsyncQueryResourceWithStreamingResponse(client.query)
self.documents = documents.AsyncDocumentsResourceWithStreamingResponse(client.documents)

Expand Down
14 changes: 0 additions & 14 deletions src/hyperspell/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
QueryResourceWithStreamingResponse,
AsyncQueryResourceWithStreamingResponse,
)
from .ingest import (
IngestResource,
AsyncIngestResource,
IngestResourceWithRawResponse,
AsyncIngestResourceWithRawResponse,
IngestResourceWithStreamingResponse,
AsyncIngestResourceWithStreamingResponse,
)
from .documents import (
DocumentsResource,
AsyncDocumentsResource,
Expand All @@ -26,12 +18,6 @@
)

__all__ = [
"IngestResource",
"AsyncIngestResource",
"IngestResourceWithRawResponse",
"AsyncIngestResourceWithRawResponse",
"IngestResourceWithStreamingResponse",
"AsyncIngestResourceWithStreamingResponse",
"QueryResource",
"AsyncQueryResource",
"QueryResourceWithRawResponse",
Expand Down
Loading