Skip to content

Commit 90ab745

Browse files
feat(api): api update (#16)
1 parent dff71c6 commit 90ab745

File tree

7 files changed

+24
-61
lines changed

7 files changed

+24
-61
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-d13c18fcc9505d21806455beba52ba04b8da7b3b5cf5894f2d91ded6d08c2ff2.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-eaf9002b6b4dd01a0039562918f5b97dc62c8fdcc1cec310491a4e64a799620a.yml

src/hyperspell/resources/query.py

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

33
from __future__ import annotations
44

5+
from typing import List
56
from typing_extensions import Literal
67

78
import httpx
@@ -49,7 +50,7 @@ def retrieve(
4950
self,
5051
*,
5152
query: str,
52-
filter: query_retrieve_params.Filter | NotGiven = NOT_GIVEN,
53+
collections: List[str] | NotGiven = NOT_GIVEN,
5354
max_results: int | NotGiven = NOT_GIVEN,
5455
query_type: Literal["auto", "semantic", "keyword"] | NotGiven = NOT_GIVEN,
5556
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -65,7 +66,7 @@ def retrieve(
6566
Args:
6667
query: Query to run.
6768
68-
filter: Filter the query results.
69+
collections: Only query documents in these collections.
6970
7071
max_results: Maximum number of results to return.
7172
@@ -84,7 +85,7 @@ def retrieve(
8485
body=maybe_transform(
8586
{
8687
"query": query,
87-
"filter": filter,
88+
"collections": collections,
8889
"max_results": max_results,
8990
"query_type": query_type,
9091
},
@@ -121,7 +122,7 @@ async def retrieve(
121122
self,
122123
*,
123124
query: str,
124-
filter: query_retrieve_params.Filter | NotGiven = NOT_GIVEN,
125+
collections: List[str] | NotGiven = NOT_GIVEN,
125126
max_results: int | NotGiven = NOT_GIVEN,
126127
query_type: Literal["auto", "semantic", "keyword"] | NotGiven = NOT_GIVEN,
127128
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -137,7 +138,7 @@ async def retrieve(
137138
Args:
138139
query: Query to run.
139140
140-
filter: Filter the query results.
141+
collections: Only query documents in these collections.
141142
142143
max_results: Maximum number of results to return.
143144
@@ -156,7 +157,7 @@ async def retrieve(
156157
body=await async_maybe_transform(
157158
{
158159
"query": query,
159-
"filter": filter,
160+
"collections": collections,
160161
"max_results": max_results,
161162
"query_type": query_type,
162163
},

src/hyperspell/types/document.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@ class Section(BaseModel):
1414

1515
document_id: int
1616

17-
type: Literal["text", "markdown", "table", "image", "messages", "message"]
17+
id: Optional[int] = None
18+
19+
embedding_e5_large: Optional[List[float]] = None
1820

19-
children_ids: Optional[List[int]] = None
21+
fts: Optional[List[float]] = None
2022

2123
metadata: Optional[object] = None
2224

23-
parent_id: Optional[int] = None
25+
type: Optional[Literal["text", "markdown", "table", "image", "messages", "message"]] = None
26+
"""Type of the section"""
2427

2528

2629
class Document(BaseModel):
2730
collection_id: int
2831

29-
resource_id: int
32+
resource_id: str
3033
"""Along with service, uniquely identifies the source document"""
3134

3235
id: Optional[int] = None
@@ -41,6 +44,8 @@ class Document(BaseModel):
4144

4245
service: Optional[Literal["slack", "s3", "gmail", "notion", "google_docs", "api"]] = None
4346

47+
status: Optional[Literal["pending", "processing", "completed", "failed"]] = None
48+
4449
title: Optional[str] = None
4550

4651
type: Optional[Literal["chat", "email", "generic", "transcript", "legal"]] = None

src/hyperspell/types/document_list_params.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ 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: Iterable[int]
33-
"""Only query documents in these collections."""
34-
3532
document_type: List[Literal["chat", "email", "generic", "transcript", "legal"]]
3633
"""Only query documents of these types."""
3734

src/hyperspell/types/query_retrieve_params.py

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,21 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Union, Iterable
6-
from datetime import datetime
7-
from typing_extensions import Literal, Required, Annotated, TypedDict
5+
from typing import List
6+
from typing_extensions import Literal, Required, TypedDict
87

9-
from .._utils import PropertyInfo
10-
11-
__all__ = ["QueryRetrieveParams", "Filter"]
8+
__all__ = ["QueryRetrieveParams"]
129

1310

1411
class QueryRetrieveParams(TypedDict, total=False):
1512
query: Required[str]
1613
"""Query to run."""
1714

18-
filter: Filter
19-
"""Filter the query results."""
15+
collections: List[str]
16+
"""Only query documents in these collections."""
2017

2118
max_results: int
2219
"""Maximum number of results to return."""
2320

2421
query_type: Literal["auto", "semantic", "keyword"]
2522
"""Type of query to run."""
26-
27-
28-
class Filter(TypedDict, total=False):
29-
chunk_type: List[Literal["text", "markdown", "table", "image", "messages", "message"]]
30-
"""Only query chunks of these types."""
31-
32-
collections: Iterable[int]
33-
"""Only query documents in these collections."""
34-
35-
document_type: List[Literal["chat", "email", "generic", "transcript", "legal"]]
36-
"""Only query documents of these types."""
37-
38-
end_date: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
39-
"""Only query documents before this date."""
40-
41-
provider: List[Literal["slack", "s3", "gmail", "notion", "google_docs", "api"]]
42-
"""Only query documents from these providers."""
43-
44-
start_date: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
45-
"""Only query documents on or after this date."""

tests/api_resources/test_documents.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def test_method_list_with_all_params(self, client: Hyperspell) -> None:
6262
collections=[0],
6363
filter={
6464
"chunk_type": ["text"],
65-
"collections": [0],
6665
"document_type": ["chat"],
6766
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
6867
"provider": ["slack"],
@@ -145,7 +144,6 @@ async def test_method_list_with_all_params(self, async_client: AsyncHyperspell)
145144
collections=[0],
146145
filter={
147146
"chunk_type": ["text"],
148-
"collections": [0],
149147
"document_type": ["chat"],
150148
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
151149
"provider": ["slack"],

tests/api_resources/test_query.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from hyperspell import Hyperspell, AsyncHyperspell
1111
from tests.utils import assert_matches_type
12-
from hyperspell._utils import parse_datetime
1312

1413
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
1514

@@ -28,14 +27,7 @@ def test_method_retrieve(self, client: Hyperspell) -> None:
2827
def test_method_retrieve_with_all_params(self, client: Hyperspell) -> None:
2928
query = client.query.retrieve(
3029
query="query",
31-
filter={
32-
"chunk_type": ["text"],
33-
"collections": [0],
34-
"document_type": ["chat"],
35-
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
36-
"provider": ["slack"],
37-
"start_date": parse_datetime("2019-12-27T18:11:19.117Z"),
38-
},
30+
collections=["string"],
3931
max_results=0,
4032
query_type="auto",
4133
)
@@ -80,14 +72,7 @@ async def test_method_retrieve(self, async_client: AsyncHyperspell) -> None:
8072
async def test_method_retrieve_with_all_params(self, async_client: AsyncHyperspell) -> None:
8173
query = await async_client.query.retrieve(
8274
query="query",
83-
filter={
84-
"chunk_type": ["text"],
85-
"collections": [0],
86-
"document_type": ["chat"],
87-
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
88-
"provider": ["slack"],
89-
"start_date": parse_datetime("2019-12-27T18:11:19.117Z"),
90-
},
75+
collections=["string"],
9176
max_results=0,
9277
query_type="auto",
9378
)

0 commit comments

Comments
 (0)