Skip to content

Commit 693304c

Browse files
feat(api): api update (#44)
1 parent 7c8ccc6 commit 693304c

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
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: 10
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-ba6c4db7ea12bd505fe5cfe650ef7372c17dbe083875afea40d5de959dbba9e1.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-e2730102bf18b9b31baab9d5f3a0545acdcaec16f74b2b64831c5a99230ab847.yml

src/hyperspell/resources/query.py

Lines changed: 9 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 List, Union
66
from typing_extensions import Literal
77

88
import httpx
@@ -50,8 +50,8 @@ def with_streaming_response(self) -> QueryResourceWithStreamingResponse:
5050
def search(
5151
self,
5252
*,
53+
collections: Union[str, List[str]],
5354
query: str,
54-
collections: List[str] | NotGiven = NOT_GIVEN,
5555
filter: query_search_params.Filter | NotGiven = NOT_GIVEN,
5656
include_elements: bool | NotGiven = NOT_GIVEN,
5757
max_results: int | NotGiven = NOT_GIVEN,
@@ -67,10 +67,10 @@ def search(
6767
Retrieves documents matching the query.
6868
6969
Args:
70-
query: Query to run.
71-
7270
collections: Only query documents in these collections.
7371
72+
query: Query to run.
73+
7474
filter: Filter the query results.
7575
7676
include_elements: Include the elements of a section in the results.
@@ -91,8 +91,8 @@ def search(
9191
"/query",
9292
body=maybe_transform(
9393
{
94-
"query": query,
9594
"collections": collections,
95+
"query": query,
9696
"filter": filter,
9797
"include_elements": include_elements,
9898
"max_results": max_results,
@@ -130,8 +130,8 @@ def with_streaming_response(self) -> AsyncQueryResourceWithStreamingResponse:
130130
async def search(
131131
self,
132132
*,
133+
collections: Union[str, List[str]],
133134
query: str,
134-
collections: List[str] | NotGiven = NOT_GIVEN,
135135
filter: query_search_params.Filter | NotGiven = NOT_GIVEN,
136136
include_elements: bool | NotGiven = NOT_GIVEN,
137137
max_results: int | NotGiven = NOT_GIVEN,
@@ -147,10 +147,10 @@ async def search(
147147
Retrieves documents matching the query.
148148
149149
Args:
150-
query: Query to run.
151-
152150
collections: Only query documents in these collections.
153151
152+
query: Query to run.
153+
154154
filter: Filter the query results.
155155
156156
include_elements: Include the elements of a section in the results.
@@ -171,8 +171,8 @@ async def search(
171171
"/query",
172172
body=await async_maybe_transform(
173173
{
174-
"query": query,
175174
"collections": collections,
175+
"query": query,
176176
"filter": filter,
177177
"include_elements": include_elements,
178178
"max_results": max_results,

src/hyperspell/types/query_search_params.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313

1414
class QuerySearchParams(TypedDict, total=False):
15+
collections: Required[Union[str, List[str]]]
16+
"""Only query documents in these collections."""
17+
1518
query: Required[str]
1619
"""Query to run."""
1720

18-
collections: List[str]
19-
"""Only query documents in these collections."""
20-
2121
filter: Filter
2222
"""Filter the query results."""
2323

tests/api_resources/test_query.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ class TestQuery:
2121
@parametrize
2222
def test_method_search(self, client: Hyperspell) -> None:
2323
query = client.query.search(
24+
collections="string",
2425
query="query",
2526
)
2627
assert_matches_type(QuerySearchResponse, query, path=["response"])
2728

2829
@parametrize
2930
def test_method_search_with_all_params(self, client: Hyperspell) -> None:
3031
query = client.query.search(
32+
collections="string",
3133
query="query",
32-
collections=["string"],
3334
filter={
3435
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
3536
"source": ["generic"],
@@ -44,6 +45,7 @@ def test_method_search_with_all_params(self, client: Hyperspell) -> None:
4445
@parametrize
4546
def test_raw_response_search(self, client: Hyperspell) -> None:
4647
response = client.query.with_raw_response.search(
48+
collections="string",
4749
query="query",
4850
)
4951

@@ -55,6 +57,7 @@ def test_raw_response_search(self, client: Hyperspell) -> None:
5557
@parametrize
5658
def test_streaming_response_search(self, client: Hyperspell) -> None:
5759
with client.query.with_streaming_response.search(
60+
collections="string",
5861
query="query",
5962
) as response:
6063
assert not response.is_closed
@@ -72,15 +75,16 @@ class TestAsyncQuery:
7275
@parametrize
7376
async def test_method_search(self, async_client: AsyncHyperspell) -> None:
7477
query = await async_client.query.search(
78+
collections="string",
7579
query="query",
7680
)
7781
assert_matches_type(QuerySearchResponse, query, path=["response"])
7882

7983
@parametrize
8084
async def test_method_search_with_all_params(self, async_client: AsyncHyperspell) -> None:
8185
query = await async_client.query.search(
86+
collections="string",
8287
query="query",
83-
collections=["string"],
8488
filter={
8589
"end_date": parse_datetime("2019-12-27T18:11:19.117Z"),
8690
"source": ["generic"],
@@ -95,6 +99,7 @@ async def test_method_search_with_all_params(self, async_client: AsyncHyperspell
9599
@parametrize
96100
async def test_raw_response_search(self, async_client: AsyncHyperspell) -> None:
97101
response = await async_client.query.with_raw_response.search(
102+
collections="string",
98103
query="query",
99104
)
100105

@@ -106,6 +111,7 @@ async def test_raw_response_search(self, async_client: AsyncHyperspell) -> None:
106111
@parametrize
107112
async def test_streaming_response_search(self, async_client: AsyncHyperspell) -> None:
108113
async with async_client.query.with_streaming_response.search(
114+
collections="string",
109115
query="query",
110116
) as response:
111117
assert not response.is_closed

0 commit comments

Comments
 (0)