Skip to content

Commit 98ba9ee

Browse files
feat(api): api update
1 parent 757a2dd commit 98ba9ee

File tree

7 files changed

+228
-18
lines changed

7 files changed

+228
-18
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 10
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-a42ab3266371bea46298692272db5e311bf49946cd28e7e4bdf0527d288658df.yml
3-
openapi_spec_hash: 6d223d997f43267608753795b549ba4a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-44a245bb64f5523b9131e1a29ff310617ffad1734c31403068704d3a87ddd4c8.yml
3+
openapi_spec_hash: b241a953df25988afd3063a8e873a638
44
config_hash: 63e7969fd7c560b6105e1de79148b568

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,39 @@ response = client.query.search(
164164
filter={
165165
"after": datetime.fromisoformat("2019-12-27T18:11:19.117"),
166166
"before": datetime.fromisoformat("2019-12-27T18:11:19.117"),
167-
"collections": "string",
167+
"collections": {
168+
"after": datetime.fromisoformat("2019-12-27T18:11:19.117"),
169+
"before": datetime.fromisoformat("2019-12-27T18:11:19.117"),
170+
"collections": ["string"],
171+
},
172+
"google_calendar": {
173+
"after": datetime.fromisoformat("2019-12-27T18:11:19.117"),
174+
"before": datetime.fromisoformat("2019-12-27T18:11:19.117"),
175+
"calendar_id": "calendar_id",
176+
},
177+
"notion": {
178+
"after": datetime.fromisoformat("2019-12-27T18:11:19.117"),
179+
"before": datetime.fromisoformat("2019-12-27T18:11:19.117"),
180+
"notion_page_ids": ["string"],
181+
},
182+
"reddit": {
183+
"after": datetime.fromisoformat("2019-12-27T18:11:19.117"),
184+
"before": datetime.fromisoformat("2019-12-27T18:11:19.117"),
185+
"period": "hour",
186+
"sort": "relevance",
187+
"subreddit": "subreddit",
188+
},
189+
"slack": {
190+
"after": datetime.fromisoformat("2019-12-27T18:11:19.117"),
191+
"before": datetime.fromisoformat("2019-12-27T18:11:19.117"),
192+
"channels": ["string"],
193+
},
194+
"web_crawler": {
195+
"after": datetime.fromisoformat("2019-12-27T18:11:19.117"),
196+
"before": datetime.fromisoformat("2019-12-27T18:11:19.117"),
197+
"max_depth": 0,
198+
"url": "string",
199+
},
168200
},
169201
)
170202
print(response.filter)

src/hyperspell/resources/query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def search(
5454
answer: bool | NotGiven = NOT_GIVEN,
5555
filter: query_search_params.Filter | NotGiven = NOT_GIVEN,
5656
max_results: int | NotGiven = NOT_GIVEN,
57-
sources: List[Literal["collections", "notion", "slack", "hubspot", "google-calendar", "reddit"]]
57+
sources: List[Literal["collections", "notion", "slack", "hubspot", "google_calendar", "reddit", "web_crawler"]]
5858
| NotGiven = NOT_GIVEN,
5959
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6060
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -131,7 +131,7 @@ async def search(
131131
answer: bool | NotGiven = NOT_GIVEN,
132132
filter: query_search_params.Filter | NotGiven = NOT_GIVEN,
133133
max_results: int | NotGiven = NOT_GIVEN,
134-
sources: List[Literal["collections", "notion", "slack", "hubspot", "google-calendar", "reddit"]]
134+
sources: List[Literal["collections", "notion", "slack", "hubspot", "google_calendar", "reddit", "web_crawler"]]
135135
| NotGiven = NOT_GIVEN,
136136
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
137137
# The extra values given here take precedence over values defined on the client or passed to this method.

src/hyperspell/types/document_list_response.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ class DocumentListResponse(BaseModel):
6262

6363
sections_count: Optional[int] = None
6464

65-
source: Optional[Literal["collections", "notion", "slack", "hubspot", "google-calendar", "reddit"]] = None
65+
source: Optional[
66+
Literal["collections", "notion", "slack", "hubspot", "google_calendar", "reddit", "web_crawler"]
67+
] = None
6668

6769
status: Optional[Literal["pending", "processing", "completed", "failed"]] = None
6870

src/hyperspell/types/query_search_params.py

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

33
from __future__ import annotations
44

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

99
from .._utils import PropertyInfo
1010

11-
__all__ = ["QuerySearchParams", "Filter"]
11+
__all__ = [
12+
"QuerySearchParams",
13+
"Filter",
14+
"FilterCollections",
15+
"FilterGoogleCalendar",
16+
"FilterNotion",
17+
"FilterReddit",
18+
"FilterSlack",
19+
"FilterWebCrawler",
20+
]
1221

1322

1423
class QuerySearchParams(TypedDict, total=False):
@@ -24,19 +33,122 @@ class QuerySearchParams(TypedDict, total=False):
2433
max_results: int
2534
"""Maximum number of results to return."""
2635

27-
sources: List[Literal["collections", "notion", "slack", "hubspot", "google-calendar", "reddit"]]
36+
sources: List[Literal["collections", "notion", "slack", "hubspot", "google_calendar", "reddit", "web_crawler"]]
2837
"""Only query documents from these sources."""
2938

3039

31-
class Filter(TypedDict, total=False):
40+
class FilterCollections(TypedDict, total=False):
41+
after: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
42+
"""Only query documents created on or after this date."""
43+
44+
before: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
45+
"""Only query documents created before this date."""
46+
47+
collections: Optional[List[str]]
48+
"""List of collections to search.
49+
50+
If not provided, only the user's default collection will be searched.
51+
"""
52+
53+
54+
class FilterGoogleCalendar(TypedDict, total=False):
55+
after: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
56+
"""Only query documents created on or after this date."""
57+
58+
before: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
59+
"""Only query documents created before this date."""
60+
61+
calendar_id: Optional[str]
62+
"""The ID of the calendar to search.
63+
64+
If not provided, it will use the ID of the default calendar. You can get the
65+
list of calendars with the `/integrations/google_calendar/list` endpoint.
66+
"""
67+
68+
69+
class FilterNotion(TypedDict, total=False):
70+
after: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
71+
"""Only query documents created on or after this date."""
72+
73+
before: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
74+
"""Only query documents created before this date."""
75+
76+
notion_page_ids: List[str]
77+
"""List of Notion page IDs to search.
78+
79+
If not provided, all pages in the workspace will be searched.
80+
"""
81+
82+
83+
class FilterReddit(TypedDict, total=False):
84+
after: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
85+
"""Only query documents created on or after this date."""
86+
87+
before: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
88+
"""Only query documents created before this date."""
89+
90+
period: Literal["hour", "day", "week", "month", "year", "all"]
91+
"""The time period to search. Defaults to 'month'."""
92+
93+
sort: Literal["relevance", "new", "hot", "top", "comments"]
94+
"""The sort order of the posts. Defaults to 'relevance'."""
95+
96+
subreddit: Optional[str]
97+
"""The subreddit to search.
98+
99+
If not provided, the query will be searched for in all subreddits.
100+
"""
101+
102+
103+
class FilterSlack(TypedDict, total=False):
32104
after: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
33-
"""Only query documents on or after this date."""
105+
"""Only query documents created on or after this date."""
34106

35107
before: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
36-
"""Only query documents before this date."""
108+
"""Only query documents created before this date."""
37109

38-
collections: Union[str, List[str], None]
39-
"""If querying collections: Only query documents in these collections.
110+
channels: List[str]
111+
"""List of Slack channels to search.
40112
41-
If not given, will query the user's default collection
113+
If not provided, all channels in the workspace will be searched.
42114
"""
115+
116+
117+
class FilterWebCrawler(TypedDict, total=False):
118+
after: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
119+
"""Only query documents created on or after this date."""
120+
121+
before: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
122+
"""Only query documents created before this date."""
123+
124+
max_depth: int
125+
"""Maximum depth to crawl from the starting URL"""
126+
127+
url: Union[str, object]
128+
"""The URL to crawl"""
129+
130+
131+
class Filter(TypedDict, total=False):
132+
after: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
133+
"""Only query documents created on or after this date."""
134+
135+
before: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
136+
"""Only query documents created before this date."""
137+
138+
collections: FilterCollections
139+
"""Search options for Collections"""
140+
141+
google_calendar: FilterGoogleCalendar
142+
"""Search options for Google Calendar"""
143+
144+
notion: FilterNotion
145+
"""Search options for Notion"""
146+
147+
reddit: FilterReddit
148+
"""Search options for Reddit"""
149+
150+
slack: FilterSlack
151+
"""Search options for Slack"""
152+
153+
web_crawler: FilterWebCrawler
154+
"""Search options for Web Crawler"""

src/hyperspell/types/query_search_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __getattr__(self, attr: str) -> object: ...
2626
class Document(BaseModel):
2727
resource_id: str
2828

29-
source: Literal["collections", "notion", "slack", "hubspot", "google-calendar", "reddit"]
29+
source: Literal["collections", "notion", "slack", "hubspot", "google_calendar", "reddit", "web_crawler"]
3030

3131
metadata: Optional[DocumentMetadata] = None
3232

tests/api_resources/test_query.py

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,39 @@ def test_method_search_with_all_params(self, client: Hyperspell) -> None:
3333
filter={
3434
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
3535
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
36-
"collections": "string",
36+
"collections": {
37+
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
38+
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
39+
"collections": ["string"],
40+
},
41+
"google_calendar": {
42+
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
43+
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
44+
"calendar_id": "calendar_id",
45+
},
46+
"notion": {
47+
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
48+
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
49+
"notion_page_ids": ["string"],
50+
},
51+
"reddit": {
52+
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
53+
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
54+
"period": "hour",
55+
"sort": "relevance",
56+
"subreddit": "subreddit",
57+
},
58+
"slack": {
59+
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
60+
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
61+
"channels": ["string"],
62+
},
63+
"web_crawler": {
64+
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
65+
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
66+
"max_depth": 0,
67+
"url": "string",
68+
},
3769
},
3870
max_results=0,
3971
sources=["collections"],
@@ -83,7 +115,39 @@ async def test_method_search_with_all_params(self, async_client: AsyncHyperspell
83115
filter={
84116
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
85117
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
86-
"collections": "string",
118+
"collections": {
119+
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
120+
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
121+
"collections": ["string"],
122+
},
123+
"google_calendar": {
124+
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
125+
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
126+
"calendar_id": "calendar_id",
127+
},
128+
"notion": {
129+
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
130+
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
131+
"notion_page_ids": ["string"],
132+
},
133+
"reddit": {
134+
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
135+
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
136+
"period": "hour",
137+
"sort": "relevance",
138+
"subreddit": "subreddit",
139+
},
140+
"slack": {
141+
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
142+
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
143+
"channels": ["string"],
144+
},
145+
"web_crawler": {
146+
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
147+
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
148+
"max_depth": 0,
149+
"url": "string",
150+
},
87151
},
88152
max_results=0,
89153
sources=["collections"],

0 commit comments

Comments
 (0)