Skip to content

Commit 4c43cb7

Browse files
feat(api): api update (#7)
1 parent fa47f9e commit 4c43cb7

File tree

7 files changed

+66
-60
lines changed

7 files changed

+66
-60
lines changed

.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-9ddaf348fc064ca71c4f5d6f792a3f3d823891ee1e158702c413714ae47fedf1.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-cd1b177729ee941af79bdb05ebf643029e9ac722bba0b43cf9941362bc1b601d.yml

src/hyperspell/resources/documents.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from __future__ import annotations
44

5+
from typing import List
6+
57
import httpx
68

79
from ..types import document_list_params
@@ -81,6 +83,7 @@ def retrieve(
8183
def list(
8284
self,
8385
*,
86+
collections: List[str],
8487
filter: document_list_params.Filter | NotGiven = NOT_GIVEN,
8588
limit: int | NotGiven = NOT_GIVEN,
8689
page: int | NotGiven = NOT_GIVEN,
@@ -97,6 +100,8 @@ def list(
97100
filter the documents by title, date, metadata, etc.
98101
99102
Args:
103+
collections: The collections to filter documents by.
104+
100105
filter: Filter the query results.
101106
102107
limit: Number of documents to return per page.
@@ -115,6 +120,7 @@ def list(
115120
"/documents/list",
116121
body=maybe_transform(
117122
{
123+
"collections": collections,
118124
"filter": filter,
119125
"limit": limit,
120126
"page": page,
@@ -184,6 +190,7 @@ async def retrieve(
184190
async def list(
185191
self,
186192
*,
193+
collections: List[str],
187194
filter: document_list_params.Filter | NotGiven = NOT_GIVEN,
188195
limit: int | NotGiven = NOT_GIVEN,
189196
page: int | NotGiven = NOT_GIVEN,
@@ -200,6 +207,8 @@ async def list(
200207
filter the documents by title, date, metadata, etc.
201208
202209
Args:
210+
collections: The collections to filter documents by.
211+
203212
filter: Filter the query results.
204213
205214
limit: Number of documents to return per page.
@@ -218,6 +227,7 @@ async def list(
218227
"/documents/list",
219228
body=await async_maybe_transform(
220229
{
230+
"collections": collections,
221231
"filter": filter,
222232
"limit": limit,
223233
"page": page,

src/hyperspell/types/document.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,44 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Dict, List, Optional
3+
from typing import List, Optional
44
from datetime import datetime
55
from typing_extensions import Literal
66

77
from .._models import BaseModel
88

9-
__all__ = ["Document", "Chunk"]
9+
__all__ = ["Document", "Section"]
1010

1111

12-
class Chunk(BaseModel):
13-
score: float
14-
15-
text: str
12+
class Section(BaseModel):
13+
content: str
1614

1715
type: Literal["text", "markdown", "table", "image", "messages", "message"]
1816

19-
metadata: Optional[Dict[str, str]] = None
17+
children_ids: Optional[List[str]] = None
2018

19+
document_id: Optional[str] = None
2120

22-
class Document(BaseModel):
23-
id: str
21+
metadata: Optional[object] = None
2422

25-
chunk_count: int
23+
parent_id: Optional[str] = None
2624

27-
ingested_at: datetime
2825

29-
chunk_ids: Optional[List[str]] = None
26+
class Document(BaseModel):
27+
collection: str
3028

31-
chunks: Optional[List[Chunk]] = None
29+
resource_id: str
30+
"""Along with service, uniquely identifies the source document"""
3231

33-
date: Optional[datetime] = None
32+
created_at: Optional[datetime] = None
3433

35-
metadata: Optional[Dict[str, str]] = None
34+
ingested_at: Optional[datetime] = None
3635

37-
org_id: Optional[str] = None
36+
metadata: Optional[object] = None
3837

39-
title: Optional[str] = None
38+
sections: Optional[List[Section]] = None
4039

41-
url: Optional[str] = None
40+
service: Optional[Literal["slack", "s3", "gmail", "notion", "google_docs", "api"]] = None
4241

43-
user_id: Optional[str] = None
42+
title: Optional[str] = None
4443

45-
visibility: Optional[Literal["user", "org", "app", "system"]] = None
44+
type: Optional[Literal["chat", "email", "generic", "transcript", "legal"]] = None

src/hyperspell/types/document_list_params.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22

33
from __future__ import annotations
44

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

99
from .._utils import PropertyInfo
1010

1111
__all__ = ["DocumentListParams", "Filter"]
1212

1313

1414
class DocumentListParams(TypedDict, total=False):
15+
collections: Required[List[str]]
16+
"""The collections to filter documents by."""
17+
1518
filter: Filter
1619
"""Filter the query results."""
1720

@@ -26,23 +29,17 @@ class Filter(TypedDict, total=False):
2629
chunk_type: List[Literal["text", "markdown", "table", "image", "messages", "message"]]
2730
"""Only query chunks of these types."""
2831

32+
collections: List[str]
33+
"""Only query documents in these collections."""
34+
2935
document_type: List[Literal["chat", "email", "generic", "transcript", "legal"]]
3036
"""Only query documents of these types."""
3137

3238
end_date: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
3339
"""Only query documents before this date."""
3440

35-
namespace: Optional[str]
36-
"""Only query documents in this namespace."""
37-
38-
org_id: Optional[str]
39-
"""Only query documents this organization has access to."""
40-
4141
provider: List[Literal["slack", "s3", "gmail", "notion", "google_docs", "api"]]
4242
"""Only query documents from these providers."""
4343

4444
start_date: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
4545
"""Only query documents on or after this date."""
46-
47-
user_id: Optional[str]
48-
"""Only query documents that this user has access to."""

src/hyperspell/types/query_retrieve_params.py

Lines changed: 4 additions & 10 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, Optional
5+
from typing import List, Union
66
from datetime import datetime
77
from typing_extensions import Literal, Required, Annotated, TypedDict
88

@@ -29,23 +29,17 @@ 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]
33+
"""Only query documents in these collections."""
34+
3235
document_type: List[Literal["chat", "email", "generic", "transcript", "legal"]]
3336
"""Only query documents of these types."""
3437

3538
end_date: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
3639
"""Only query documents before this date."""
3740

38-
namespace: Optional[str]
39-
"""Only query documents in this namespace."""
40-
41-
org_id: Optional[str]
42-
"""Only query documents this organization has access to."""
43-
4441
provider: List[Literal["slack", "s3", "gmail", "notion", "google_docs", "api"]]
4542
"""Only query documents from these providers."""
4643

4744
start_date: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
4845
"""Only query documents on or after this date."""
49-
50-
user_id: Optional[str]
51-
"""Only query documents that this user has access to."""

tests/api_resources/test_documents.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,22 @@ def test_path_params_retrieve(self, client: Hyperspell) -> None:
5858

5959
@parametrize
6060
def test_method_list(self, client: Hyperspell) -> None:
61-
document = client.documents.list()
61+
document = client.documents.list(
62+
collections=["string"],
63+
)
6264
assert_matches_type(DocumentListResponse, document, path=["response"])
6365

6466
@parametrize
6567
def test_method_list_with_all_params(self, client: Hyperspell) -> None:
6668
document = client.documents.list(
69+
collections=["string"],
6770
filter={
6871
"chunk_type": ["text"],
72+
"collections": ["string"],
6973
"document_type": ["chat"],
7074
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
71-
"namespace": "namespace",
72-
"org_id": "org_id",
7375
"provider": ["slack"],
7476
"start_date": parse_datetime("2019-12-27T18:11:19.117Z"),
75-
"user_id": "user_id",
7677
},
7778
limit=0,
7879
page=2,
@@ -81,7 +82,9 @@ def test_method_list_with_all_params(self, client: Hyperspell) -> None:
8182

8283
@parametrize
8384
def test_raw_response_list(self, client: Hyperspell) -> None:
84-
response = client.documents.with_raw_response.list()
85+
response = client.documents.with_raw_response.list(
86+
collections=["string"],
87+
)
8588

8689
assert response.is_closed is True
8790
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -90,7 +93,9 @@ def test_raw_response_list(self, client: Hyperspell) -> None:
9093

9194
@parametrize
9295
def test_streaming_response_list(self, client: Hyperspell) -> None:
93-
with client.documents.with_streaming_response.list() as response:
96+
with client.documents.with_streaming_response.list(
97+
collections=["string"],
98+
) as response:
9499
assert not response.is_closed
95100
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
96101

@@ -143,21 +148,22 @@ async def test_path_params_retrieve(self, async_client: AsyncHyperspell) -> None
143148

144149
@parametrize
145150
async def test_method_list(self, async_client: AsyncHyperspell) -> None:
146-
document = await async_client.documents.list()
151+
document = await async_client.documents.list(
152+
collections=["string"],
153+
)
147154
assert_matches_type(DocumentListResponse, document, path=["response"])
148155

149156
@parametrize
150157
async def test_method_list_with_all_params(self, async_client: AsyncHyperspell) -> None:
151158
document = await async_client.documents.list(
159+
collections=["string"],
152160
filter={
153161
"chunk_type": ["text"],
162+
"collections": ["string"],
154163
"document_type": ["chat"],
155164
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
156-
"namespace": "namespace",
157-
"org_id": "org_id",
158165
"provider": ["slack"],
159166
"start_date": parse_datetime("2019-12-27T18:11:19.117Z"),
160-
"user_id": "user_id",
161167
},
162168
limit=0,
163169
page=2,
@@ -166,7 +172,9 @@ async def test_method_list_with_all_params(self, async_client: AsyncHyperspell)
166172

167173
@parametrize
168174
async def test_raw_response_list(self, async_client: AsyncHyperspell) -> None:
169-
response = await async_client.documents.with_raw_response.list()
175+
response = await async_client.documents.with_raw_response.list(
176+
collections=["string"],
177+
)
170178

171179
assert response.is_closed is True
172180
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -175,7 +183,9 @@ async def test_raw_response_list(self, async_client: AsyncHyperspell) -> None:
175183

176184
@parametrize
177185
async def test_streaming_response_list(self, async_client: AsyncHyperspell) -> None:
178-
async with async_client.documents.with_streaming_response.list() as response:
186+
async with async_client.documents.with_streaming_response.list(
187+
collections=["string"],
188+
) as response:
179189
assert not response.is_closed
180190
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
181191

tests/api_resources/test_query.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ def test_method_retrieve_with_all_params(self, client: Hyperspell) -> None:
3030
query="query",
3131
filter={
3232
"chunk_type": ["text"],
33+
"collections": ["string"],
3334
"document_type": ["chat"],
3435
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
35-
"namespace": "namespace",
36-
"org_id": "org_id",
3736
"provider": ["slack"],
3837
"start_date": parse_datetime("2019-12-27T18:11:19.117Z"),
39-
"user_id": "user_id",
4038
},
4139
max_results=0,
4240
query_type="auto",
@@ -84,13 +82,11 @@ async def test_method_retrieve_with_all_params(self, async_client: AsyncHyperspe
8482
query="query",
8583
filter={
8684
"chunk_type": ["text"],
85+
"collections": ["string"],
8786
"document_type": ["chat"],
8887
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
89-
"namespace": "namespace",
90-
"org_id": "org_id",
9188
"provider": ["slack"],
9289
"start_date": parse_datetime("2019-12-27T18:11:19.117Z"),
93-
"user_id": "user_id",
9490
},
9591
max_results=0,
9692
query_type="auto",

0 commit comments

Comments
 (0)