Skip to content

Commit bbe535f

Browse files
feat(api): api update (#8)
1 parent 0f02368 commit bbe535f

7 files changed

Lines changed: 36 additions & 52 deletions

File tree

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 3
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-94e926477d6338146c22b4645e1419c0b3494d6b891062d2da7ad1134ab0aeae.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-2b929bd185bb270d17b7f342cc157df373f6b8043d4d90c9ade596680ee5ea34.yml

src/hyperspell/resources/documents.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import List
5+
from typing import Iterable
66

77
import httpx
88

@@ -49,7 +49,7 @@ def with_streaming_response(self) -> DocumentsResourceWithStreamingResponse:
4949

5050
def retrieve(
5151
self,
52-
document_id: str,
52+
document_id: int,
5353
*,
5454
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5555
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -70,8 +70,6 @@ def retrieve(
7070
7171
timeout: Override the client-level default timeout for this request, in seconds
7272
"""
73-
if not document_id:
74-
raise ValueError(f"Expected a non-empty value for `document_id` but received {document_id!r}")
7573
return self._get(
7674
f"/documents/get/{document_id}",
7775
options=make_request_options(
@@ -83,7 +81,7 @@ def retrieve(
8381
def list(
8482
self,
8583
*,
86-
collections: List[str],
84+
collections: Iterable[int],
8785
filter: document_list_params.Filter | NotGiven = NOT_GIVEN,
8886
limit: int | NotGiven = NOT_GIVEN,
8987
page: int | NotGiven = NOT_GIVEN,
@@ -156,7 +154,7 @@ def with_streaming_response(self) -> AsyncDocumentsResourceWithStreamingResponse
156154

157155
async def retrieve(
158156
self,
159-
document_id: str,
157+
document_id: int,
160158
*,
161159
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
162160
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -177,8 +175,6 @@ async def retrieve(
177175
178176
timeout: Override the client-level default timeout for this request, in seconds
179177
"""
180-
if not document_id:
181-
raise ValueError(f"Expected a non-empty value for `document_id` but received {document_id!r}")
182178
return await self._get(
183179
f"/documents/get/{document_id}",
184180
options=make_request_options(
@@ -190,7 +186,7 @@ async def retrieve(
190186
async def list(
191187
self,
192188
*,
193-
collections: List[str],
189+
collections: Iterable[int],
194190
filter: document_list_params.Filter | NotGiven = NOT_GIVEN,
195191
limit: int | NotGiven = NOT_GIVEN,
196192
page: int | NotGiven = NOT_GIVEN,

src/hyperspell/types/document.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ class Section(BaseModel):
1414

1515
type: Literal["text", "markdown", "table", "image", "messages", "message"]
1616

17-
children_ids: Optional[List[str]] = None
17+
children_ids: Optional[List[int]] = None
1818

19-
document_id: Optional[str] = None
19+
document_id: Optional[int] = None
2020

2121
metadata: Optional[object] = None
2222

23-
parent_id: Optional[str] = None
23+
parent_id: Optional[int] = None
2424

2525

2626
class Document(BaseModel):
27-
collection: str
27+
collection_id: int
2828

29-
resource_id: str
29+
resource_id: int
3030
"""Along with service, uniquely identifies the source document"""
3131

32+
id: Optional[int] = None
33+
3234
created_at: Optional[datetime] = None
3335

3436
ingested_at: Optional[datetime] = None

src/hyperspell/types/document_list_params.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Union
5+
from typing import List, Union, Iterable
66
from datetime import datetime
77
from typing_extensions import Literal, Required, Annotated, TypedDict
88

@@ -12,7 +12,7 @@
1212

1313

1414
class DocumentListParams(TypedDict, total=False):
15-
collections: Required[List[str]]
15+
collections: Required[Iterable[int]]
1616
"""The collections to filter documents by."""
1717

1818
filter: Filter
@@ -29,7 +29,7 @@ class Filter(TypedDict, total=False):
2929
chunk_type: List[Literal["text", "markdown", "table", "image", "messages", "message"]]
3030
"""Only query chunks of these types."""
3131

32-
collections: List[str]
32+
collections: Iterable[int]
3333
"""Only query documents in these collections."""
3434

3535
document_type: List[Literal["chat", "email", "generic", "transcript", "legal"]]

src/hyperspell/types/query_retrieve_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Union
5+
from typing import List, Union, Iterable
66
from datetime import datetime
77
from typing_extensions import Literal, Required, Annotated, TypedDict
88

@@ -29,7 +29,7 @@ class Filter(TypedDict, total=False):
2929
chunk_type: List[Literal["text", "markdown", "table", "image", "messages", "message"]]
3030
"""Only query chunks of these types."""
3131

32-
collections: List[str]
32+
collections: Iterable[int]
3333
"""Only query documents in these collections."""
3434

3535
document_type: List[Literal["chat", "email", "generic", "transcript", "legal"]]

tests/api_resources/test_documents.py

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ class TestDocuments:
2121
@parametrize
2222
def test_method_retrieve(self, client: Hyperspell) -> None:
2323
document = client.documents.retrieve(
24-
"document_id",
24+
0,
2525
)
2626
assert_matches_type(Document, document, path=["response"])
2727

2828
@parametrize
2929
def test_raw_response_retrieve(self, client: Hyperspell) -> None:
3030
response = client.documents.with_raw_response.retrieve(
31-
"document_id",
31+
0,
3232
)
3333

3434
assert response.is_closed is True
@@ -39,7 +39,7 @@ def test_raw_response_retrieve(self, client: Hyperspell) -> None:
3939
@parametrize
4040
def test_streaming_response_retrieve(self, client: Hyperspell) -> None:
4141
with client.documents.with_streaming_response.retrieve(
42-
"document_id",
42+
0,
4343
) as response:
4444
assert not response.is_closed
4545
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -49,27 +49,20 @@ def test_streaming_response_retrieve(self, client: Hyperspell) -> None:
4949

5050
assert cast(Any, response.is_closed) is True
5151

52-
@parametrize
53-
def test_path_params_retrieve(self, client: Hyperspell) -> None:
54-
with pytest.raises(ValueError, match=r"Expected a non-empty value for `document_id` but received ''"):
55-
client.documents.with_raw_response.retrieve(
56-
"",
57-
)
58-
5952
@parametrize
6053
def test_method_list(self, client: Hyperspell) -> None:
6154
document = client.documents.list(
62-
collections=["string"],
55+
collections=[0],
6356
)
6457
assert_matches_type(DocumentListResponse, document, path=["response"])
6558

6659
@parametrize
6760
def test_method_list_with_all_params(self, client: Hyperspell) -> None:
6861
document = client.documents.list(
69-
collections=["string"],
62+
collections=[0],
7063
filter={
7164
"chunk_type": ["text"],
72-
"collections": ["string"],
65+
"collections": [0],
7366
"document_type": ["chat"],
7467
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
7568
"provider": ["slack"],
@@ -83,7 +76,7 @@ def test_method_list_with_all_params(self, client: Hyperspell) -> None:
8376
@parametrize
8477
def test_raw_response_list(self, client: Hyperspell) -> None:
8578
response = client.documents.with_raw_response.list(
86-
collections=["string"],
79+
collections=[0],
8780
)
8881

8982
assert response.is_closed is True
@@ -94,7 +87,7 @@ def test_raw_response_list(self, client: Hyperspell) -> None:
9487
@parametrize
9588
def test_streaming_response_list(self, client: Hyperspell) -> None:
9689
with client.documents.with_streaming_response.list(
97-
collections=["string"],
90+
collections=[0],
9891
) as response:
9992
assert not response.is_closed
10093
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -111,14 +104,14 @@ class TestAsyncDocuments:
111104
@parametrize
112105
async def test_method_retrieve(self, async_client: AsyncHyperspell) -> None:
113106
document = await async_client.documents.retrieve(
114-
"document_id",
107+
0,
115108
)
116109
assert_matches_type(Document, document, path=["response"])
117110

118111
@parametrize
119112
async def test_raw_response_retrieve(self, async_client: AsyncHyperspell) -> None:
120113
response = await async_client.documents.with_raw_response.retrieve(
121-
"document_id",
114+
0,
122115
)
123116

124117
assert response.is_closed is True
@@ -129,7 +122,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncHyperspell) -> Non
129122
@parametrize
130123
async def test_streaming_response_retrieve(self, async_client: AsyncHyperspell) -> None:
131124
async with async_client.documents.with_streaming_response.retrieve(
132-
"document_id",
125+
0,
133126
) as response:
134127
assert not response.is_closed
135128
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -139,27 +132,20 @@ async def test_streaming_response_retrieve(self, async_client: AsyncHyperspell)
139132

140133
assert cast(Any, response.is_closed) is True
141134

142-
@parametrize
143-
async def test_path_params_retrieve(self, async_client: AsyncHyperspell) -> None:
144-
with pytest.raises(ValueError, match=r"Expected a non-empty value for `document_id` but received ''"):
145-
await async_client.documents.with_raw_response.retrieve(
146-
"",
147-
)
148-
149135
@parametrize
150136
async def test_method_list(self, async_client: AsyncHyperspell) -> None:
151137
document = await async_client.documents.list(
152-
collections=["string"],
138+
collections=[0],
153139
)
154140
assert_matches_type(DocumentListResponse, document, path=["response"])
155141

156142
@parametrize
157143
async def test_method_list_with_all_params(self, async_client: AsyncHyperspell) -> None:
158144
document = await async_client.documents.list(
159-
collections=["string"],
145+
collections=[0],
160146
filter={
161147
"chunk_type": ["text"],
162-
"collections": ["string"],
148+
"collections": [0],
163149
"document_type": ["chat"],
164150
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
165151
"provider": ["slack"],
@@ -173,7 +159,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncHyperspell)
173159
@parametrize
174160
async def test_raw_response_list(self, async_client: AsyncHyperspell) -> None:
175161
response = await async_client.documents.with_raw_response.list(
176-
collections=["string"],
162+
collections=[0],
177163
)
178164

179165
assert response.is_closed is True
@@ -184,7 +170,7 @@ async def test_raw_response_list(self, async_client: AsyncHyperspell) -> None:
184170
@parametrize
185171
async def test_streaming_response_list(self, async_client: AsyncHyperspell) -> None:
186172
async with async_client.documents.with_streaming_response.list(
187-
collections=["string"],
173+
collections=[0],
188174
) as response:
189175
assert not response.is_closed
190176
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

tests/api_resources/test_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_method_retrieve_with_all_params(self, client: Hyperspell) -> None:
3030
query="query",
3131
filter={
3232
"chunk_type": ["text"],
33-
"collections": ["string"],
33+
"collections": [0],
3434
"document_type": ["chat"],
3535
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
3636
"provider": ["slack"],
@@ -82,7 +82,7 @@ async def test_method_retrieve_with_all_params(self, async_client: AsyncHyperspe
8282
query="query",
8383
filter={
8484
"chunk_type": ["text"],
85-
"collections": ["string"],
85+
"collections": [0],
8686
"document_type": ["chat"],
8787
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
8888
"provider": ["slack"],

0 commit comments

Comments
 (0)