Skip to content

Commit f923b83

Browse files
feat(api): api update (#4)
1 parent 3ae1b69 commit f923b83

File tree

12 files changed

+58
-819
lines changed

12 files changed

+58
-819
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 5
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-63f6c69af7e01f89d3fcae7ff327ead30958f0e8d893deb0f0e38826361691bb.yml
1+
configured_endpoints: 3
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-458ea970d3418ec635638d00fc0a6a1bacf213a22be5151a04c6107bf693d64d.yml

README.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ from hyperspell import Hyperspell
2828

2929
client = Hyperspell()
3030

31-
response = client.ingest.add()
32-
print(response.document_id)
31+
query = client.query.retrieve(
32+
query="query",
33+
)
3334
```
3435

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

5051

5152
async def main() -> None:
52-
response = await client.ingest.add()
53-
print(response.document_id)
53+
query = await client.query.retrieve(
54+
query="query",
55+
)
5456

5557

5658
asyncio.run(main())
@@ -83,7 +85,9 @@ from hyperspell import Hyperspell
8385
client = Hyperspell()
8486

8587
try:
86-
client.ingest.add()
88+
client.query.retrieve(
89+
query="query",
90+
)
8791
except hyperspell.APIConnectionError as e:
8892
print("The server could not be reached")
8993
print(e.__cause__) # an underlying Exception, likely raised within httpx.
@@ -126,7 +130,9 @@ client = Hyperspell(
126130
)
127131

128132
# Or, configure per-request:
129-
client.with_options(max_retries=5).ingest.add()
133+
client.with_options(max_retries=5).query.retrieve(
134+
query="query",
135+
)
130136
```
131137

132138
### Timeouts
@@ -149,7 +155,9 @@ client = Hyperspell(
149155
)
150156

151157
# Override per-request:
152-
client.with_options(timeout=5.0).ingest.add()
158+
client.with_options(timeout=5.0).query.retrieve(
159+
query="query",
160+
)
153161
```
154162

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

192200
client = Hyperspell()
193-
response = client.ingest.with_raw_response.add()
201+
response = client.query.with_raw_response.retrieve(
202+
query="query",
203+
)
194204
print(response.headers.get('X-My-Header'))
195205

196-
ingest = response.parse() # get the object that `ingest.add()` would have returned
197-
print(ingest.document_id)
206+
query = response.parse() # get the object that `query.retrieve()` would have returned
207+
print(query)
198208
```
199209

200210
These methods return an [`APIResponse`](https://github.com/hyperspell/python-sdk/tree/main/src/hyperspell/_response.py) object.
@@ -208,7 +218,9 @@ The above interface eagerly reads the full response body when you make the reque
208218
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.
209219

210220
```python
211-
with client.ingest.with_streaming_response.add() as response:
221+
with client.query.with_streaming_response.retrieve(
222+
query="query",
223+
) as response:
212224
print(response.headers.get("X-My-Header"))
213225

214226
for line in response.iter_lines():

api.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
# Ingest
2-
3-
Types:
4-
5-
```python
6-
from hyperspell.types import IngestAddResponse, IngestFileResponse
7-
```
8-
9-
Methods:
10-
11-
- <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>
12-
- <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>
13-
141
# Query
152

163
Types:

src/hyperspell/_client.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
get_async_library,
2525
)
2626
from ._version import __version__
27-
from .resources import query, ingest, documents
27+
from .resources import query, documents
2828
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
2929
from ._exceptions import APIStatusError, HyperspellError
3030
from ._base_client import (
@@ -46,7 +46,6 @@
4646

4747

4848
class Hyperspell(SyncAPIClient):
49-
ingest: ingest.IngestResource
5049
query: query.QueryResource
5150
documents: documents.DocumentsResource
5251
with_raw_response: HyperspellWithRawResponse
@@ -106,7 +105,6 @@ def __init__(
106105
_strict_response_validation=_strict_response_validation,
107106
)
108107

109-
self.ingest = ingest.IngestResource(self)
110108
self.query = query.QueryResource(self)
111109
self.documents = documents.DocumentsResource(self)
112110
self.with_raw_response = HyperspellWithRawResponse(self)
@@ -218,7 +216,6 @@ def _make_status_error(
218216

219217

220218
class AsyncHyperspell(AsyncAPIClient):
221-
ingest: ingest.AsyncIngestResource
222219
query: query.AsyncQueryResource
223220
documents: documents.AsyncDocumentsResource
224221
with_raw_response: AsyncHyperspellWithRawResponse
@@ -278,7 +275,6 @@ def __init__(
278275
_strict_response_validation=_strict_response_validation,
279276
)
280277

281-
self.ingest = ingest.AsyncIngestResource(self)
282278
self.query = query.AsyncQueryResource(self)
283279
self.documents = documents.AsyncDocumentsResource(self)
284280
self.with_raw_response = AsyncHyperspellWithRawResponse(self)
@@ -391,28 +387,24 @@ def _make_status_error(
391387

392388
class HyperspellWithRawResponse:
393389
def __init__(self, client: Hyperspell) -> None:
394-
self.ingest = ingest.IngestResourceWithRawResponse(client.ingest)
395390
self.query = query.QueryResourceWithRawResponse(client.query)
396391
self.documents = documents.DocumentsResourceWithRawResponse(client.documents)
397392

398393

399394
class AsyncHyperspellWithRawResponse:
400395
def __init__(self, client: AsyncHyperspell) -> None:
401-
self.ingest = ingest.AsyncIngestResourceWithRawResponse(client.ingest)
402396
self.query = query.AsyncQueryResourceWithRawResponse(client.query)
403397
self.documents = documents.AsyncDocumentsResourceWithRawResponse(client.documents)
404398

405399

406400
class HyperspellWithStreamedResponse:
407401
def __init__(self, client: Hyperspell) -> None:
408-
self.ingest = ingest.IngestResourceWithStreamingResponse(client.ingest)
409402
self.query = query.QueryResourceWithStreamingResponse(client.query)
410403
self.documents = documents.DocumentsResourceWithStreamingResponse(client.documents)
411404

412405

413406
class AsyncHyperspellWithStreamedResponse:
414407
def __init__(self, client: AsyncHyperspell) -> None:
415-
self.ingest = ingest.AsyncIngestResourceWithStreamingResponse(client.ingest)
416408
self.query = query.AsyncQueryResourceWithStreamingResponse(client.query)
417409
self.documents = documents.AsyncDocumentsResourceWithStreamingResponse(client.documents)
418410

src/hyperspell/resources/__init__.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88
QueryResourceWithStreamingResponse,
99
AsyncQueryResourceWithStreamingResponse,
1010
)
11-
from .ingest import (
12-
IngestResource,
13-
AsyncIngestResource,
14-
IngestResourceWithRawResponse,
15-
AsyncIngestResourceWithRawResponse,
16-
IngestResourceWithStreamingResponse,
17-
AsyncIngestResourceWithStreamingResponse,
18-
)
1911
from .documents import (
2012
DocumentsResource,
2113
AsyncDocumentsResource,
@@ -26,12 +18,6 @@
2618
)
2719

2820
__all__ = [
29-
"IngestResource",
30-
"AsyncIngestResource",
31-
"IngestResourceWithRawResponse",
32-
"AsyncIngestResourceWithRawResponse",
33-
"IngestResourceWithStreamingResponse",
34-
"AsyncIngestResourceWithStreamingResponse",
3521
"QueryResource",
3622
"AsyncQueryResource",
3723
"QueryResourceWithRawResponse",

0 commit comments

Comments
 (0)