Skip to content

Commit 743c857

Browse files
feat(api): update via SDK Studio
1 parent b6dd141 commit 743c857

File tree

7 files changed

+233
-5
lines changed

7 files changed

+233
-5
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 17
1+
configured_endpoints: 18
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-d2e76b9698a2b33ab32291eac7ffa9671fe0a65646e6ba53170beee2dd643123.yml
33
openapi_spec_hash: e4c39d8acf6435ae67ae263becf8dc47
4-
config_hash: 88c2e8730c1f7a63483c6bfbc6e49e1c
4+
config_hash: 0a4df55eb1dea18b7b6832b1f5a957e9

api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ Methods:
6363
Types:
6464

6565
```python
66-
from hyperspell.types import Query, EvaluateScoreQueryResponse
66+
from hyperspell.types import Query, EvaluateScoreHighlightResponse, EvaluateScoreQueryResponse
6767
```
6868

6969
Methods:
7070

7171
- <code title="get /memories/query/{query_id}">client.evaluate.<a href="./src/hyperspell/resources/evaluate.py">get_query</a>(query_id) -> <a href="./src/hyperspell/types/query.py">Query</a></code>
72+
- <code title="post /memories/highlights/feedback">client.evaluate.<a href="./src/hyperspell/resources/evaluate.py">score_highlight</a>(\*\*<a href="src/hyperspell/types/evaluate_score_highlight_params.py">params</a>) -> <a href="./src/hyperspell/types/evaluate_score_highlight_response.py">EvaluateScoreHighlightResponse</a></code>
7273
- <code title="post /memories/query/feedback">client.evaluate.<a href="./src/hyperspell/resources/evaluate.py">score_query</a>(\*\*<a href="src/hyperspell/types/evaluate_score_query_params.py">params</a>) -> <a href="./src/hyperspell/types/evaluate_score_query_response.py">EvaluateScoreQueryResponse</a></code>
7374

7475
# Vaults

src/hyperspell/resources/evaluate.py

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
from __future__ import annotations
44

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

7-
from ..types import evaluate_score_query_params
9+
from ..types import evaluate_score_query_params, evaluate_score_highlight_params
810
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
911
from .._utils import maybe_transform, async_maybe_transform
1012
from .._compat import cached_property
@@ -18,6 +20,7 @@
1820
from ..types.query import Query
1921
from .._base_client import make_request_options
2022
from ..types.evaluate_score_query_response import EvaluateScoreQueryResponse
23+
from ..types.evaluate_score_highlight_response import EvaluateScoreHighlightResponse
2124

2225
__all__ = ["EvaluateResource", "AsyncEvaluateResource"]
2326

@@ -75,6 +78,53 @@ def get_query(
7578
cast_to=Query,
7679
)
7780

81+
def score_highlight(
82+
self,
83+
*,
84+
highlight_id: str,
85+
comment: Optional[str] | Omit = omit,
86+
score: float | Omit = omit,
87+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
88+
# The extra values given here take precedence over values defined on the client or passed to this method.
89+
extra_headers: Headers | None = None,
90+
extra_query: Query | None = None,
91+
extra_body: Body | None = None,
92+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
93+
) -> EvaluateScoreHighlightResponse:
94+
"""
95+
Provide feedback on a query result.
96+
97+
Args:
98+
highlight_id: The ID of the chunk to provide feedback on.
99+
100+
comment: Comment on the chunk
101+
102+
score: Rating of the chunk from -1 (bad) to +1 (good).
103+
104+
extra_headers: Send extra headers
105+
106+
extra_query: Add additional query parameters to the request
107+
108+
extra_body: Add additional JSON properties to the request
109+
110+
timeout: Override the client-level default timeout for this request, in seconds
111+
"""
112+
return self._post(
113+
"/memories/highlights/feedback",
114+
body=maybe_transform(
115+
{
116+
"highlight_id": highlight_id,
117+
"comment": comment,
118+
"score": score,
119+
},
120+
evaluate_score_highlight_params.EvaluateScoreHighlightParams,
121+
),
122+
options=make_request_options(
123+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
124+
),
125+
cast_to=EvaluateScoreHighlightResponse,
126+
)
127+
78128
def score_query(
79129
self,
80130
*,
@@ -172,6 +222,53 @@ async def get_query(
172222
cast_to=Query,
173223
)
174224

225+
async def score_highlight(
226+
self,
227+
*,
228+
highlight_id: str,
229+
comment: Optional[str] | Omit = omit,
230+
score: float | Omit = omit,
231+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
232+
# The extra values given here take precedence over values defined on the client or passed to this method.
233+
extra_headers: Headers | None = None,
234+
extra_query: Query | None = None,
235+
extra_body: Body | None = None,
236+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
237+
) -> EvaluateScoreHighlightResponse:
238+
"""
239+
Provide feedback on a query result.
240+
241+
Args:
242+
highlight_id: The ID of the chunk to provide feedback on.
243+
244+
comment: Comment on the chunk
245+
246+
score: Rating of the chunk from -1 (bad) to +1 (good).
247+
248+
extra_headers: Send extra headers
249+
250+
extra_query: Add additional query parameters to the request
251+
252+
extra_body: Add additional JSON properties to the request
253+
254+
timeout: Override the client-level default timeout for this request, in seconds
255+
"""
256+
return await self._post(
257+
"/memories/highlights/feedback",
258+
body=await async_maybe_transform(
259+
{
260+
"highlight_id": highlight_id,
261+
"comment": comment,
262+
"score": score,
263+
},
264+
evaluate_score_highlight_params.EvaluateScoreHighlightParams,
265+
),
266+
options=make_request_options(
267+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
268+
),
269+
cast_to=EvaluateScoreHighlightResponse,
270+
)
271+
175272
async def score_query(
176273
self,
177274
*,
@@ -223,6 +320,9 @@ def __init__(self, evaluate: EvaluateResource) -> None:
223320
self.get_query = to_raw_response_wrapper(
224321
evaluate.get_query,
225322
)
323+
self.score_highlight = to_raw_response_wrapper(
324+
evaluate.score_highlight,
325+
)
226326
self.score_query = to_raw_response_wrapper(
227327
evaluate.score_query,
228328
)
@@ -235,6 +335,9 @@ def __init__(self, evaluate: AsyncEvaluateResource) -> None:
235335
self.get_query = async_to_raw_response_wrapper(
236336
evaluate.get_query,
237337
)
338+
self.score_highlight = async_to_raw_response_wrapper(
339+
evaluate.score_highlight,
340+
)
238341
self.score_query = async_to_raw_response_wrapper(
239342
evaluate.score_query,
240343
)
@@ -247,6 +350,9 @@ def __init__(self, evaluate: EvaluateResource) -> None:
247350
self.get_query = to_streamed_response_wrapper(
248351
evaluate.get_query,
249352
)
353+
self.score_highlight = to_streamed_response_wrapper(
354+
evaluate.score_highlight,
355+
)
250356
self.score_query = to_streamed_response_wrapper(
251357
evaluate.score_query,
252358
)
@@ -259,6 +365,9 @@ def __init__(self, evaluate: AsyncEvaluateResource) -> None:
259365
self.get_query = async_to_streamed_response_wrapper(
260366
evaluate.get_query,
261367
)
368+
self.score_highlight = async_to_streamed_response_wrapper(
369+
evaluate.score_highlight,
370+
)
262371
self.score_query = async_to_streamed_response_wrapper(
263372
evaluate.score_query,
264373
)

src/hyperspell/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@
2020
from .evaluate_score_query_params import EvaluateScoreQueryParams as EvaluateScoreQueryParams
2121
from .integration_revoke_response import IntegrationRevokeResponse as IntegrationRevokeResponse
2222
from .evaluate_score_query_response import EvaluateScoreQueryResponse as EvaluateScoreQueryResponse
23+
from .evaluate_score_highlight_params import EvaluateScoreHighlightParams as EvaluateScoreHighlightParams
24+
from .evaluate_score_highlight_response import EvaluateScoreHighlightResponse as EvaluateScoreHighlightResponse
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Optional
6+
from typing_extensions import Required, TypedDict
7+
8+
__all__ = ["EvaluateScoreHighlightParams"]
9+
10+
11+
class EvaluateScoreHighlightParams(TypedDict, total=False):
12+
highlight_id: Required[str]
13+
"""The ID of the chunk to provide feedback on."""
14+
15+
comment: Optional[str]
16+
"""Comment on the chunk"""
17+
18+
score: float
19+
"""Rating of the chunk from -1 (bad) to +1 (good)."""
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from .._models import BaseModel
4+
5+
__all__ = ["EvaluateScoreHighlightResponse"]
6+
7+
8+
class EvaluateScoreHighlightResponse(BaseModel):
9+
message: str
10+
"""A message describing the result."""
11+
12+
success: bool
13+
"""Whether the feedback was successfully saved."""

tests/api_resources/test_evaluate.py

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
from hyperspell import Hyperspell, AsyncHyperspell
1111
from tests.utils import assert_matches_type
12-
from hyperspell.types import Query, EvaluateScoreQueryResponse
12+
from hyperspell.types import (
13+
Query,
14+
EvaluateScoreQueryResponse,
15+
EvaluateScoreHighlightResponse,
16+
)
1317

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

@@ -55,6 +59,46 @@ def test_path_params_get_query(self, client: Hyperspell) -> None:
5559
"",
5660
)
5761

62+
@parametrize
63+
def test_method_score_highlight(self, client: Hyperspell) -> None:
64+
evaluate = client.evaluate.score_highlight(
65+
highlight_id="highlight_id",
66+
)
67+
assert_matches_type(EvaluateScoreHighlightResponse, evaluate, path=["response"])
68+
69+
@parametrize
70+
def test_method_score_highlight_with_all_params(self, client: Hyperspell) -> None:
71+
evaluate = client.evaluate.score_highlight(
72+
highlight_id="highlight_id",
73+
comment="comment",
74+
score=-1,
75+
)
76+
assert_matches_type(EvaluateScoreHighlightResponse, evaluate, path=["response"])
77+
78+
@parametrize
79+
def test_raw_response_score_highlight(self, client: Hyperspell) -> None:
80+
response = client.evaluate.with_raw_response.score_highlight(
81+
highlight_id="highlight_id",
82+
)
83+
84+
assert response.is_closed is True
85+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
86+
evaluate = response.parse()
87+
assert_matches_type(EvaluateScoreHighlightResponse, evaluate, path=["response"])
88+
89+
@parametrize
90+
def test_streaming_response_score_highlight(self, client: Hyperspell) -> None:
91+
with client.evaluate.with_streaming_response.score_highlight(
92+
highlight_id="highlight_id",
93+
) as response:
94+
assert not response.is_closed
95+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
96+
97+
evaluate = response.parse()
98+
assert_matches_type(EvaluateScoreHighlightResponse, evaluate, path=["response"])
99+
100+
assert cast(Any, response.is_closed) is True
101+
58102
@parametrize
59103
def test_method_score_query(self, client: Hyperspell) -> None:
60104
evaluate = client.evaluate.score_query(
@@ -138,6 +182,46 @@ async def test_path_params_get_query(self, async_client: AsyncHyperspell) -> Non
138182
"",
139183
)
140184

185+
@parametrize
186+
async def test_method_score_highlight(self, async_client: AsyncHyperspell) -> None:
187+
evaluate = await async_client.evaluate.score_highlight(
188+
highlight_id="highlight_id",
189+
)
190+
assert_matches_type(EvaluateScoreHighlightResponse, evaluate, path=["response"])
191+
192+
@parametrize
193+
async def test_method_score_highlight_with_all_params(self, async_client: AsyncHyperspell) -> None:
194+
evaluate = await async_client.evaluate.score_highlight(
195+
highlight_id="highlight_id",
196+
comment="comment",
197+
score=-1,
198+
)
199+
assert_matches_type(EvaluateScoreHighlightResponse, evaluate, path=["response"])
200+
201+
@parametrize
202+
async def test_raw_response_score_highlight(self, async_client: AsyncHyperspell) -> None:
203+
response = await async_client.evaluate.with_raw_response.score_highlight(
204+
highlight_id="highlight_id",
205+
)
206+
207+
assert response.is_closed is True
208+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
209+
evaluate = await response.parse()
210+
assert_matches_type(EvaluateScoreHighlightResponse, evaluate, path=["response"])
211+
212+
@parametrize
213+
async def test_streaming_response_score_highlight(self, async_client: AsyncHyperspell) -> None:
214+
async with async_client.evaluate.with_streaming_response.score_highlight(
215+
highlight_id="highlight_id",
216+
) as response:
217+
assert not response.is_closed
218+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
219+
220+
evaluate = await response.parse()
221+
assert_matches_type(EvaluateScoreHighlightResponse, evaluate, path=["response"])
222+
223+
assert cast(Any, response.is_closed) is True
224+
141225
@parametrize
142226
async def test_method_score_query(self, async_client: AsyncHyperspell) -> None:
143227
evaluate = await async_client.evaluate.score_query(

0 commit comments

Comments
 (0)