Skip to content

Commit 65bcc7c

Browse files
fix(stainless): added missing reranking endpoint to SDK API (#50)
1 parent 5ef5f65 commit 65bcc7c

File tree

9 files changed

+623
-2
lines changed

9 files changed

+623
-2
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: 1
1+
configured_endpoints: 2
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/isaacus%2Fisaacus-861e8a85f0fb73cf4b7fc6c2b27722072ff33109459e90c17be24af15dfcbd0c.yml
33
openapi_spec_hash: 644a0383600633ee604bb1e5b9ca025d
4-
config_hash: 8a781867f31df68b9c6fba04c165c647
4+
config_hash: 2bc262108dc3b065c16da5bb85c1e282

api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@ from isaacus.types.classifications import UniversalClassification
1111
Methods:
1212

1313
- <code title="post /classifications/universal">client.classifications.universal.<a href="./src/isaacus/resources/classifications/universal.py">create</a>(\*\*<a href="src/isaacus/types/classifications/universal_create_params.py">params</a>) -> <a href="./src/isaacus/types/classifications/universal_classification.py">UniversalClassification</a></code>
14+
15+
# Rerankings
16+
17+
Types:
18+
19+
```python
20+
from isaacus.types import Reranking
21+
```
22+
23+
Methods:
24+
25+
- <code title="post /rerankings">client.rerankings.<a href="./src/isaacus/resources/rerankings.py">create</a>(\*\*<a href="src/isaacus/types/reranking_create_params.py">params</a>) -> <a href="./src/isaacus/types/reranking.py">Reranking</a></code>

src/isaacus/_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
get_async_library,
2525
)
2626
from ._version import __version__
27+
from .resources import rerankings
2728
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
2829
from ._exceptions import IsaacusError, APIStatusError
2930
from ._base_client import (
@@ -38,6 +39,7 @@
3839

3940
class Isaacus(SyncAPIClient):
4041
classifications: classifications.ClassificationsResource
42+
rerankings: rerankings.RerankingsResource
4143
with_raw_response: IsaacusWithRawResponse
4244
with_streaming_response: IsaacusWithStreamedResponse
4345

@@ -96,6 +98,7 @@ def __init__(
9698
)
9799

98100
self.classifications = classifications.ClassificationsResource(self)
101+
self.rerankings = rerankings.RerankingsResource(self)
99102
self.with_raw_response = IsaacusWithRawResponse(self)
100103
self.with_streaming_response = IsaacusWithStreamedResponse(self)
101104

@@ -206,6 +209,7 @@ def _make_status_error(
206209

207210
class AsyncIsaacus(AsyncAPIClient):
208211
classifications: classifications.AsyncClassificationsResource
212+
rerankings: rerankings.AsyncRerankingsResource
209213
with_raw_response: AsyncIsaacusWithRawResponse
210214
with_streaming_response: AsyncIsaacusWithStreamedResponse
211215

@@ -264,6 +268,7 @@ def __init__(
264268
)
265269

266270
self.classifications = classifications.AsyncClassificationsResource(self)
271+
self.rerankings = rerankings.AsyncRerankingsResource(self)
267272
self.with_raw_response = AsyncIsaacusWithRawResponse(self)
268273
self.with_streaming_response = AsyncIsaacusWithStreamedResponse(self)
269274

@@ -375,21 +380,25 @@ def _make_status_error(
375380
class IsaacusWithRawResponse:
376381
def __init__(self, client: Isaacus) -> None:
377382
self.classifications = classifications.ClassificationsResourceWithRawResponse(client.classifications)
383+
self.rerankings = rerankings.RerankingsResourceWithRawResponse(client.rerankings)
378384

379385

380386
class AsyncIsaacusWithRawResponse:
381387
def __init__(self, client: AsyncIsaacus) -> None:
382388
self.classifications = classifications.AsyncClassificationsResourceWithRawResponse(client.classifications)
389+
self.rerankings = rerankings.AsyncRerankingsResourceWithRawResponse(client.rerankings)
383390

384391

385392
class IsaacusWithStreamedResponse:
386393
def __init__(self, client: Isaacus) -> None:
387394
self.classifications = classifications.ClassificationsResourceWithStreamingResponse(client.classifications)
395+
self.rerankings = rerankings.RerankingsResourceWithStreamingResponse(client.rerankings)
388396

389397

390398
class AsyncIsaacusWithStreamedResponse:
391399
def __init__(self, client: AsyncIsaacus) -> None:
392400
self.classifications = classifications.AsyncClassificationsResourceWithStreamingResponse(client.classifications)
401+
self.rerankings = rerankings.AsyncRerankingsResourceWithStreamingResponse(client.rerankings)
393402

394403

395404
Client = Isaacus

src/isaacus/resources/__init__.py

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

3+
from .rerankings import (
4+
RerankingsResource,
5+
AsyncRerankingsResource,
6+
RerankingsResourceWithRawResponse,
7+
AsyncRerankingsResourceWithRawResponse,
8+
RerankingsResourceWithStreamingResponse,
9+
AsyncRerankingsResourceWithStreamingResponse,
10+
)
311
from .classifications import (
412
ClassificationsResource,
513
AsyncClassificationsResource,
@@ -16,4 +24,10 @@
1624
"AsyncClassificationsResourceWithRawResponse",
1725
"ClassificationsResourceWithStreamingResponse",
1826
"AsyncClassificationsResourceWithStreamingResponse",
27+
"RerankingsResource",
28+
"AsyncRerankingsResource",
29+
"RerankingsResourceWithRawResponse",
30+
"AsyncRerankingsResourceWithRawResponse",
31+
"RerankingsResourceWithStreamingResponse",
32+
"AsyncRerankingsResourceWithStreamingResponse",
1933
]
Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
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 List, Optional
6+
from typing_extensions import Literal
7+
8+
import httpx
9+
10+
from ..types import reranking_create_params
11+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
12+
from .._utils import (
13+
maybe_transform,
14+
async_maybe_transform,
15+
)
16+
from .._compat import cached_property
17+
from .._resource import SyncAPIResource, AsyncAPIResource
18+
from .._response import (
19+
to_raw_response_wrapper,
20+
to_streamed_response_wrapper,
21+
async_to_raw_response_wrapper,
22+
async_to_streamed_response_wrapper,
23+
)
24+
from .._base_client import make_request_options
25+
from ..types.reranking import Reranking
26+
27+
__all__ = ["RerankingsResource", "AsyncRerankingsResource"]
28+
29+
30+
class RerankingsResource(SyncAPIResource):
31+
@cached_property
32+
def with_raw_response(self) -> RerankingsResourceWithRawResponse:
33+
"""
34+
This property can be used as a prefix for any HTTP method call to return
35+
the raw response object instead of the parsed content.
36+
37+
For more information, see https://www.github.com/isaacus-dev/isaacus-python#accessing-raw-response-data-eg-headers
38+
"""
39+
return RerankingsResourceWithRawResponse(self)
40+
41+
@cached_property
42+
def with_streaming_response(self) -> RerankingsResourceWithStreamingResponse:
43+
"""
44+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
45+
46+
For more information, see https://www.github.com/isaacus-dev/isaacus-python#with_streaming_response
47+
"""
48+
return RerankingsResourceWithStreamingResponse(self)
49+
50+
def create(
51+
self,
52+
*,
53+
model: Literal["kanon-universal-classifier", "kanon-universal-classifier-mini"],
54+
query: str,
55+
texts: List[str],
56+
chunking_options: Optional[reranking_create_params.ChunkingOptions] | NotGiven = NOT_GIVEN,
57+
is_iql: bool | NotGiven = NOT_GIVEN,
58+
scoring_method: Literal["auto", "chunk_max", "chunk_avg", "chunk_min"] | NotGiven = NOT_GIVEN,
59+
top_n: Optional[int] | NotGiven = NOT_GIVEN,
60+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
61+
# The extra values given here take precedence over values defined on the client or passed to this method.
62+
extra_headers: Headers | None = None,
63+
extra_query: Query | None = None,
64+
extra_body: Body | None = None,
65+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
66+
) -> Reranking:
67+
"""
68+
Rerank legal documents by their relevance to a query with an Isaacus legal AI
69+
reranker.
70+
71+
Args:
72+
model: The ID of the [model](https://docs.isaacus.com/models#reranking) to use for
73+
reranking.
74+
75+
query: The query to evaluate the relevance of the texts to.
76+
77+
The query must contain at least one non-whitespace character.
78+
79+
Unlike the texts being reranked, the query cannot be so long that it exceeds the
80+
maximum input length of the reranker.
81+
82+
texts: The texts to rerank.
83+
84+
There must be at least one text.
85+
86+
The texts must contain at least one non-whitespace character.
87+
88+
chunking_options: Options for how to split text into smaller chunks.
89+
90+
is_iql: Whether the query should be interpreted as an
91+
[Isaacus Query Language (IQL)](https://docs.isaacus.com/iql) query, which is not
92+
the case by default.
93+
94+
If you allow untrusted users to construct their own queries, think carefully
95+
before enabling IQL since queries can be crafted to consume an excessively large
96+
amount of tokens.
97+
98+
scoring_method: The method to use for producing an overall relevance score for a text.
99+
100+
`auto` is the default scoring method and is recommended for most use cases.
101+
Currently, it is equivalent to `chunk_max`. In the future, it will automatically
102+
select the best method based on the model and inputs.
103+
104+
`chunk_max` uses the highest relevance score of all of a text's chunks.
105+
106+
`chunk_avg` averages the relevance scores of all of a text's chunks.
107+
108+
`chunk_min` uses the lowest relevance score of all of a text's chunks.
109+
110+
top_n: A whole number greater than or equal to 1.
111+
112+
extra_headers: Send extra headers
113+
114+
extra_query: Add additional query parameters to the request
115+
116+
extra_body: Add additional JSON properties to the request
117+
118+
timeout: Override the client-level default timeout for this request, in seconds
119+
"""
120+
return self._post(
121+
"/rerankings",
122+
body=maybe_transform(
123+
{
124+
"model": model,
125+
"query": query,
126+
"texts": texts,
127+
"chunking_options": chunking_options,
128+
"is_iql": is_iql,
129+
"scoring_method": scoring_method,
130+
"top_n": top_n,
131+
},
132+
reranking_create_params.RerankingCreateParams,
133+
),
134+
options=make_request_options(
135+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
136+
),
137+
cast_to=Reranking,
138+
)
139+
140+
141+
class AsyncRerankingsResource(AsyncAPIResource):
142+
@cached_property
143+
def with_raw_response(self) -> AsyncRerankingsResourceWithRawResponse:
144+
"""
145+
This property can be used as a prefix for any HTTP method call to return
146+
the raw response object instead of the parsed content.
147+
148+
For more information, see https://www.github.com/isaacus-dev/isaacus-python#accessing-raw-response-data-eg-headers
149+
"""
150+
return AsyncRerankingsResourceWithRawResponse(self)
151+
152+
@cached_property
153+
def with_streaming_response(self) -> AsyncRerankingsResourceWithStreamingResponse:
154+
"""
155+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
156+
157+
For more information, see https://www.github.com/isaacus-dev/isaacus-python#with_streaming_response
158+
"""
159+
return AsyncRerankingsResourceWithStreamingResponse(self)
160+
161+
async def create(
162+
self,
163+
*,
164+
model: Literal["kanon-universal-classifier", "kanon-universal-classifier-mini"],
165+
query: str,
166+
texts: List[str],
167+
chunking_options: Optional[reranking_create_params.ChunkingOptions] | NotGiven = NOT_GIVEN,
168+
is_iql: bool | NotGiven = NOT_GIVEN,
169+
scoring_method: Literal["auto", "chunk_max", "chunk_avg", "chunk_min"] | NotGiven = NOT_GIVEN,
170+
top_n: Optional[int] | NotGiven = NOT_GIVEN,
171+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
172+
# The extra values given here take precedence over values defined on the client or passed to this method.
173+
extra_headers: Headers | None = None,
174+
extra_query: Query | None = None,
175+
extra_body: Body | None = None,
176+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
177+
) -> Reranking:
178+
"""
179+
Rerank legal documents by their relevance to a query with an Isaacus legal AI
180+
reranker.
181+
182+
Args:
183+
model: The ID of the [model](https://docs.isaacus.com/models#reranking) to use for
184+
reranking.
185+
186+
query: The query to evaluate the relevance of the texts to.
187+
188+
The query must contain at least one non-whitespace character.
189+
190+
Unlike the texts being reranked, the query cannot be so long that it exceeds the
191+
maximum input length of the reranker.
192+
193+
texts: The texts to rerank.
194+
195+
There must be at least one text.
196+
197+
The texts must contain at least one non-whitespace character.
198+
199+
chunking_options: Options for how to split text into smaller chunks.
200+
201+
is_iql: Whether the query should be interpreted as an
202+
[Isaacus Query Language (IQL)](https://docs.isaacus.com/iql) query, which is not
203+
the case by default.
204+
205+
If you allow untrusted users to construct their own queries, think carefully
206+
before enabling IQL since queries can be crafted to consume an excessively large
207+
amount of tokens.
208+
209+
scoring_method: The method to use for producing an overall relevance score for a text.
210+
211+
`auto` is the default scoring method and is recommended for most use cases.
212+
Currently, it is equivalent to `chunk_max`. In the future, it will automatically
213+
select the best method based on the model and inputs.
214+
215+
`chunk_max` uses the highest relevance score of all of a text's chunks.
216+
217+
`chunk_avg` averages the relevance scores of all of a text's chunks.
218+
219+
`chunk_min` uses the lowest relevance score of all of a text's chunks.
220+
221+
top_n: A whole number greater than or equal to 1.
222+
223+
extra_headers: Send extra headers
224+
225+
extra_query: Add additional query parameters to the request
226+
227+
extra_body: Add additional JSON properties to the request
228+
229+
timeout: Override the client-level default timeout for this request, in seconds
230+
"""
231+
return await self._post(
232+
"/rerankings",
233+
body=await async_maybe_transform(
234+
{
235+
"model": model,
236+
"query": query,
237+
"texts": texts,
238+
"chunking_options": chunking_options,
239+
"is_iql": is_iql,
240+
"scoring_method": scoring_method,
241+
"top_n": top_n,
242+
},
243+
reranking_create_params.RerankingCreateParams,
244+
),
245+
options=make_request_options(
246+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
247+
),
248+
cast_to=Reranking,
249+
)
250+
251+
252+
class RerankingsResourceWithRawResponse:
253+
def __init__(self, rerankings: RerankingsResource) -> None:
254+
self._rerankings = rerankings
255+
256+
self.create = to_raw_response_wrapper(
257+
rerankings.create,
258+
)
259+
260+
261+
class AsyncRerankingsResourceWithRawResponse:
262+
def __init__(self, rerankings: AsyncRerankingsResource) -> None:
263+
self._rerankings = rerankings
264+
265+
self.create = async_to_raw_response_wrapper(
266+
rerankings.create,
267+
)
268+
269+
270+
class RerankingsResourceWithStreamingResponse:
271+
def __init__(self, rerankings: RerankingsResource) -> None:
272+
self._rerankings = rerankings
273+
274+
self.create = to_streamed_response_wrapper(
275+
rerankings.create,
276+
)
277+
278+
279+
class AsyncRerankingsResourceWithStreamingResponse:
280+
def __init__(self, rerankings: AsyncRerankingsResource) -> None:
281+
self._rerankings = rerankings
282+
283+
self.create = async_to_streamed_response_wrapper(
284+
rerankings.create,
285+
)

0 commit comments

Comments
 (0)