isaacus 0.3.0__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. isaacus-0.3.2/.release-please-manifest.json +3 -0
  2. {isaacus-0.3.0 → isaacus-0.3.2}/CHANGELOG.md +16 -0
  3. {isaacus-0.3.0 → isaacus-0.3.2}/PKG-INFO +1 -1
  4. {isaacus-0.3.0 → isaacus-0.3.2}/api.md +12 -0
  5. {isaacus-0.3.0 → isaacus-0.3.2}/pyproject.toml +1 -1
  6. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_client.py +9 -0
  7. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_version.py +1 -1
  8. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/resources/__init__.py +14 -0
  9. isaacus-0.3.2/src/isaacus/resources/rerankings.py +285 -0
  10. isaacus-0.3.2/src/isaacus/types/__init__.py +6 -0
  11. isaacus-0.3.2/src/isaacus/types/reranking.py +37 -0
  12. isaacus-0.3.2/src/isaacus/types/reranking_create_params.py +75 -0
  13. isaacus-0.3.2/tests/api_resources/test_rerankings.py +186 -0
  14. {isaacus-0.3.0 → isaacus-0.3.2}/tests/test_client.py +1 -1
  15. isaacus-0.3.0/.release-please-manifest.json +0 -3
  16. isaacus-0.3.0/src/isaacus/types/__init__.py +0 -3
  17. {isaacus-0.3.0 → isaacus-0.3.2}/.gitignore +0 -0
  18. {isaacus-0.3.0 → isaacus-0.3.2}/CONTRIBUTING.md +0 -0
  19. {isaacus-0.3.0 → isaacus-0.3.2}/LICENSE +0 -0
  20. {isaacus-0.3.0 → isaacus-0.3.2}/README.md +0 -0
  21. {isaacus-0.3.0 → isaacus-0.3.2}/SECURITY.md +0 -0
  22. {isaacus-0.3.0 → isaacus-0.3.2}/bin/check-release-environment +0 -0
  23. {isaacus-0.3.0 → isaacus-0.3.2}/bin/publish-pypi +0 -0
  24. {isaacus-0.3.0 → isaacus-0.3.2}/examples/.keep +0 -0
  25. {isaacus-0.3.0 → isaacus-0.3.2}/mypy.ini +0 -0
  26. {isaacus-0.3.0 → isaacus-0.3.2}/noxfile.py +0 -0
  27. {isaacus-0.3.0 → isaacus-0.3.2}/release-please-config.json +0 -0
  28. {isaacus-0.3.0 → isaacus-0.3.2}/requirements-dev.lock +0 -0
  29. {isaacus-0.3.0 → isaacus-0.3.2}/requirements.lock +0 -0
  30. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/__init__.py +0 -0
  31. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_base_client.py +0 -0
  32. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_compat.py +0 -0
  33. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_constants.py +0 -0
  34. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_exceptions.py +0 -0
  35. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_files.py +0 -0
  36. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_models.py +0 -0
  37. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_qs.py +0 -0
  38. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_resource.py +0 -0
  39. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_response.py +0 -0
  40. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_streaming.py +0 -0
  41. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_types.py +0 -0
  42. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_utils/__init__.py +0 -0
  43. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_utils/_logs.py +0 -0
  44. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_utils/_proxy.py +0 -0
  45. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_utils/_reflection.py +0 -0
  46. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_utils/_streams.py +0 -0
  47. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_utils/_sync.py +0 -0
  48. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_utils/_transform.py +0 -0
  49. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_utils/_typing.py +0 -0
  50. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/_utils/_utils.py +0 -0
  51. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/lib/.keep +0 -0
  52. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/py.typed +0 -0
  53. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/resources/classifications/__init__.py +0 -0
  54. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/resources/classifications/classifications.py +0 -0
  55. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/resources/classifications/universal.py +0 -0
  56. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/types/classifications/__init__.py +0 -0
  57. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/types/classifications/universal_classification.py +0 -0
  58. {isaacus-0.3.0 → isaacus-0.3.2}/src/isaacus/types/classifications/universal_create_params.py +0 -0
  59. {isaacus-0.3.0 → isaacus-0.3.2}/tests/__init__.py +0 -0
  60. {isaacus-0.3.0 → isaacus-0.3.2}/tests/api_resources/__init__.py +0 -0
  61. {isaacus-0.3.0 → isaacus-0.3.2}/tests/api_resources/classifications/__init__.py +0 -0
  62. {isaacus-0.3.0 → isaacus-0.3.2}/tests/api_resources/classifications/test_universal.py +0 -0
  63. {isaacus-0.3.0 → isaacus-0.3.2}/tests/conftest.py +0 -0
  64. {isaacus-0.3.0 → isaacus-0.3.2}/tests/sample_file.txt +0 -0
  65. {isaacus-0.3.0 → isaacus-0.3.2}/tests/test_deepcopy.py +0 -0
  66. {isaacus-0.3.0 → isaacus-0.3.2}/tests/test_extract_files.py +0 -0
  67. {isaacus-0.3.0 → isaacus-0.3.2}/tests/test_files.py +0 -0
  68. {isaacus-0.3.0 → isaacus-0.3.2}/tests/test_models.py +0 -0
  69. {isaacus-0.3.0 → isaacus-0.3.2}/tests/test_qs.py +0 -0
  70. {isaacus-0.3.0 → isaacus-0.3.2}/tests/test_required_args.py +0 -0
  71. {isaacus-0.3.0 → isaacus-0.3.2}/tests/test_response.py +0 -0
  72. {isaacus-0.3.0 → isaacus-0.3.2}/tests/test_streaming.py +0 -0
  73. {isaacus-0.3.0 → isaacus-0.3.2}/tests/test_transform.py +0 -0
  74. {isaacus-0.3.0 → isaacus-0.3.2}/tests/test_utils/test_proxy.py +0 -0
  75. {isaacus-0.3.0 → isaacus-0.3.2}/tests/test_utils/test_typing.py +0 -0
  76. {isaacus-0.3.0 → isaacus-0.3.2}/tests/utils.py +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.3.2"
3
+ }
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.2 (2025-04-04)
4
+
5
+ Full Changelog: [v0.3.1...v0.3.2](https://github.com/isaacus-dev/isaacus-python/compare/v0.3.1...v0.3.2)
6
+
7
+ ### Chores
8
+
9
+ * **internal:** remove trailing character ([#53](https://github.com/isaacus-dev/isaacus-python/issues/53)) ([1074f1e](https://github.com/isaacus-dev/isaacus-python/commit/1074f1e6817381f31f4f6b7329f596be19b0e918))
10
+
11
+ ## 0.3.1 (2025-04-01)
12
+
13
+ Full Changelog: [v0.3.0...v0.3.1](https://github.com/isaacus-dev/isaacus-python/compare/v0.3.0...v0.3.1)
14
+
15
+ ### Bug Fixes
16
+
17
+ * **stainless:** added missing reranking endpoint to SDK API ([#50](https://github.com/isaacus-dev/isaacus-python/issues/50)) ([65bcc7c](https://github.com/isaacus-dev/isaacus-python/commit/65bcc7c274dc5609c1537e417c75e6b9942ac8fc))
18
+
3
19
  ## 0.3.0 (2025-04-01)
4
20
 
5
21
  Full Changelog: [v0.2.0...v0.3.0](https://github.com/isaacus-dev/isaacus-python/compare/v0.2.0...v0.3.0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: isaacus
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: The official Python library for the isaacus API
5
5
  Project-URL: Homepage, https://github.com/isaacus-dev/isaacus-python
6
6
  Project-URL: Repository, https://github.com/isaacus-dev/isaacus-python
@@ -11,3 +11,15 @@ from isaacus.types.classifications import UniversalClassification
11
11
  Methods:
12
12
 
13
13
  - <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>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "isaacus"
3
- version = "0.3.0"
3
+ version = "0.3.2"
4
4
  description = "The official Python library for the isaacus API"
5
5
  dynamic = ["readme"]
6
6
  license = "Apache-2.0"
@@ -24,6 +24,7 @@ from ._utils import (
24
24
  get_async_library,
25
25
  )
26
26
  from ._version import __version__
27
+ from .resources import rerankings
27
28
  from ._streaming import Stream as Stream, AsyncStream as AsyncStream
28
29
  from ._exceptions import IsaacusError, APIStatusError
29
30
  from ._base_client import (
@@ -38,6 +39,7 @@ __all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Isaacus",
38
39
 
39
40
  class Isaacus(SyncAPIClient):
40
41
  classifications: classifications.ClassificationsResource
42
+ rerankings: rerankings.RerankingsResource
41
43
  with_raw_response: IsaacusWithRawResponse
42
44
  with_streaming_response: IsaacusWithStreamedResponse
43
45
 
@@ -96,6 +98,7 @@ class Isaacus(SyncAPIClient):
96
98
  )
97
99
 
98
100
  self.classifications = classifications.ClassificationsResource(self)
101
+ self.rerankings = rerankings.RerankingsResource(self)
99
102
  self.with_raw_response = IsaacusWithRawResponse(self)
100
103
  self.with_streaming_response = IsaacusWithStreamedResponse(self)
101
104
 
@@ -206,6 +209,7 @@ class Isaacus(SyncAPIClient):
206
209
 
207
210
  class AsyncIsaacus(AsyncAPIClient):
208
211
  classifications: classifications.AsyncClassificationsResource
212
+ rerankings: rerankings.AsyncRerankingsResource
209
213
  with_raw_response: AsyncIsaacusWithRawResponse
210
214
  with_streaming_response: AsyncIsaacusWithStreamedResponse
211
215
 
@@ -264,6 +268,7 @@ class AsyncIsaacus(AsyncAPIClient):
264
268
  )
265
269
 
266
270
  self.classifications = classifications.AsyncClassificationsResource(self)
271
+ self.rerankings = rerankings.AsyncRerankingsResource(self)
267
272
  self.with_raw_response = AsyncIsaacusWithRawResponse(self)
268
273
  self.with_streaming_response = AsyncIsaacusWithStreamedResponse(self)
269
274
 
@@ -375,21 +380,25 @@ class AsyncIsaacus(AsyncAPIClient):
375
380
  class IsaacusWithRawResponse:
376
381
  def __init__(self, client: Isaacus) -> None:
377
382
  self.classifications = classifications.ClassificationsResourceWithRawResponse(client.classifications)
383
+ self.rerankings = rerankings.RerankingsResourceWithRawResponse(client.rerankings)
378
384
 
379
385
 
380
386
  class AsyncIsaacusWithRawResponse:
381
387
  def __init__(self, client: AsyncIsaacus) -> None:
382
388
  self.classifications = classifications.AsyncClassificationsResourceWithRawResponse(client.classifications)
389
+ self.rerankings = rerankings.AsyncRerankingsResourceWithRawResponse(client.rerankings)
383
390
 
384
391
 
385
392
  class IsaacusWithStreamedResponse:
386
393
  def __init__(self, client: Isaacus) -> None:
387
394
  self.classifications = classifications.ClassificationsResourceWithStreamingResponse(client.classifications)
395
+ self.rerankings = rerankings.RerankingsResourceWithStreamingResponse(client.rerankings)
388
396
 
389
397
 
390
398
  class AsyncIsaacusWithStreamedResponse:
391
399
  def __init__(self, client: AsyncIsaacus) -> None:
392
400
  self.classifications = classifications.AsyncClassificationsResourceWithStreamingResponse(client.classifications)
401
+ self.rerankings = rerankings.AsyncRerankingsResourceWithStreamingResponse(client.rerankings)
393
402
 
394
403
 
395
404
  Client = Isaacus
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "isaacus"
4
- __version__ = "0.3.0" # x-release-please-version
4
+ __version__ = "0.3.2" # x-release-please-version
@@ -1,5 +1,13 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
+ from .rerankings import (
4
+ RerankingsResource,
5
+ AsyncRerankingsResource,
6
+ RerankingsResourceWithRawResponse,
7
+ AsyncRerankingsResourceWithRawResponse,
8
+ RerankingsResourceWithStreamingResponse,
9
+ AsyncRerankingsResourceWithStreamingResponse,
10
+ )
3
11
  from .classifications import (
4
12
  ClassificationsResource,
5
13
  AsyncClassificationsResource,
@@ -16,4 +24,10 @@ __all__ = [
16
24
  "AsyncClassificationsResourceWithRawResponse",
17
25
  "ClassificationsResourceWithStreamingResponse",
18
26
  "AsyncClassificationsResourceWithStreamingResponse",
27
+ "RerankingsResource",
28
+ "AsyncRerankingsResource",
29
+ "RerankingsResourceWithRawResponse",
30
+ "AsyncRerankingsResourceWithRawResponse",
31
+ "RerankingsResourceWithStreamingResponse",
32
+ "AsyncRerankingsResourceWithStreamingResponse",
19
33
  ]
@@ -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,0 +1,6 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from .reranking import Reranking as Reranking
6
+ from .reranking_create_params import RerankingCreateParams as RerankingCreateParams
@@ -0,0 +1,37 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import List
4
+
5
+ from .._models import BaseModel
6
+
7
+ __all__ = ["Reranking", "Result", "Usage"]
8
+
9
+
10
+ class Result(BaseModel):
11
+ index: int
12
+ """
13
+ The index of the text in the input array of texts, starting from `0` (and,
14
+ therefore, ending at the number of texts minus `1`).
15
+ """
16
+
17
+ score: float
18
+ """
19
+ A score between `0` and `1`, inclusive, representing the relevance of the text
20
+ to the query.
21
+ """
22
+
23
+
24
+ class Usage(BaseModel):
25
+ input_tokens: int
26
+ """The number of tokens inputted to the model."""
27
+
28
+
29
+ class Reranking(BaseModel):
30
+ results: List[Result]
31
+ """
32
+ The rerankings of the texts, by relevance to the query, in order from highest to
33
+ lowest relevance score.
34
+ """
35
+
36
+ usage: Usage
37
+ """Statistics about the usage of resources in the process of reranking the texts."""
@@ -0,0 +1,75 @@
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, Required, TypedDict
7
+
8
+ __all__ = ["RerankingCreateParams", "ChunkingOptions"]
9
+
10
+
11
+ class RerankingCreateParams(TypedDict, total=False):
12
+ model: Required[Literal["kanon-universal-classifier", "kanon-universal-classifier-mini"]]
13
+ """
14
+ The ID of the [model](https://docs.isaacus.com/models#reranking) to use for
15
+ reranking.
16
+ """
17
+
18
+ query: Required[str]
19
+ """The query to evaluate the relevance of the texts to.
20
+
21
+ The query must contain at least one non-whitespace character.
22
+
23
+ Unlike the texts being reranked, the query cannot be so long that it exceeds the
24
+ maximum input length of the reranker.
25
+ """
26
+
27
+ texts: Required[List[str]]
28
+ """The texts to rerank.
29
+
30
+ There must be at least one text.
31
+
32
+ The texts must contain at least one non-whitespace character.
33
+ """
34
+
35
+ chunking_options: Optional[ChunkingOptions]
36
+ """Options for how to split text into smaller chunks."""
37
+
38
+ is_iql: bool
39
+ """
40
+ Whether the query should be interpreted as an
41
+ [Isaacus Query Language (IQL)](https://docs.isaacus.com/iql) query, which is not
42
+ the case by default.
43
+
44
+ If you allow untrusted users to construct their own queries, think carefully
45
+ before enabling IQL since queries can be crafted to consume an excessively large
46
+ amount of tokens.
47
+ """
48
+
49
+ scoring_method: Literal["auto", "chunk_max", "chunk_avg", "chunk_min"]
50
+ """The method to use for producing an overall relevance score for a text.
51
+
52
+ `auto` is the default scoring method and is recommended for most use cases.
53
+ Currently, it is equivalent to `chunk_max`. In the future, it will automatically
54
+ select the best method based on the model and inputs.
55
+
56
+ `chunk_max` uses the highest relevance score of all of a text's chunks.
57
+
58
+ `chunk_avg` averages the relevance scores of all of a text's chunks.
59
+
60
+ `chunk_min` uses the lowest relevance score of all of a text's chunks.
61
+ """
62
+
63
+ top_n: Optional[int]
64
+ """A whole number greater than or equal to 1."""
65
+
66
+
67
+ class ChunkingOptions(TypedDict, total=False):
68
+ overlap_ratio: Optional[float]
69
+ """A number greater than or equal to 0 and less than 1."""
70
+
71
+ overlap_tokens: Optional[int]
72
+ """A whole number greater than -1."""
73
+
74
+ size: Optional[int]
75
+ """A whole number greater than or equal to 1."""
@@ -0,0 +1,186 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from typing import Any, cast
7
+
8
+ import pytest
9
+
10
+ from isaacus import Isaacus, AsyncIsaacus
11
+ from tests.utils import assert_matches_type
12
+ from isaacus.types import Reranking
13
+
14
+ base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
15
+
16
+
17
+ class TestRerankings:
18
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
19
+
20
+ @pytest.mark.skip()
21
+ @parametrize
22
+ def test_method_create(self, client: Isaacus) -> None:
23
+ reranking = client.rerankings.create(
24
+ model="kanon-universal-classifier",
25
+ query="What are the essential elements required to establish a negligence claim?",
26
+ texts=[
27
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
28
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
29
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
30
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
31
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
32
+ ],
33
+ )
34
+ assert_matches_type(Reranking, reranking, path=["response"])
35
+
36
+ @pytest.mark.skip()
37
+ @parametrize
38
+ def test_method_create_with_all_params(self, client: Isaacus) -> None:
39
+ reranking = client.rerankings.create(
40
+ model="kanon-universal-classifier",
41
+ query="What are the essential elements required to establish a negligence claim?",
42
+ texts=[
43
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
44
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
45
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
46
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
47
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
48
+ ],
49
+ chunking_options={
50
+ "overlap_ratio": 0.1,
51
+ "overlap_tokens": 0,
52
+ "size": 512,
53
+ },
54
+ is_iql=False,
55
+ scoring_method="auto",
56
+ top_n=1,
57
+ )
58
+ assert_matches_type(Reranking, reranking, path=["response"])
59
+
60
+ @pytest.mark.skip()
61
+ @parametrize
62
+ def test_raw_response_create(self, client: Isaacus) -> None:
63
+ response = client.rerankings.with_raw_response.create(
64
+ model="kanon-universal-classifier",
65
+ query="What are the essential elements required to establish a negligence claim?",
66
+ texts=[
67
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
68
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
69
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
70
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
71
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
72
+ ],
73
+ )
74
+
75
+ assert response.is_closed is True
76
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
77
+ reranking = response.parse()
78
+ assert_matches_type(Reranking, reranking, path=["response"])
79
+
80
+ @pytest.mark.skip()
81
+ @parametrize
82
+ def test_streaming_response_create(self, client: Isaacus) -> None:
83
+ with client.rerankings.with_streaming_response.create(
84
+ model="kanon-universal-classifier",
85
+ query="What are the essential elements required to establish a negligence claim?",
86
+ texts=[
87
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
88
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
89
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
90
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
91
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
92
+ ],
93
+ ) as response:
94
+ assert not response.is_closed
95
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
96
+
97
+ reranking = response.parse()
98
+ assert_matches_type(Reranking, reranking, path=["response"])
99
+
100
+ assert cast(Any, response.is_closed) is True
101
+
102
+
103
+ class TestAsyncRerankings:
104
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
105
+
106
+ @pytest.mark.skip()
107
+ @parametrize
108
+ async def test_method_create(self, async_client: AsyncIsaacus) -> None:
109
+ reranking = await async_client.rerankings.create(
110
+ model="kanon-universal-classifier",
111
+ query="What are the essential elements required to establish a negligence claim?",
112
+ texts=[
113
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
114
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
115
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
116
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
117
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
118
+ ],
119
+ )
120
+ assert_matches_type(Reranking, reranking, path=["response"])
121
+
122
+ @pytest.mark.skip()
123
+ @parametrize
124
+ async def test_method_create_with_all_params(self, async_client: AsyncIsaacus) -> None:
125
+ reranking = await async_client.rerankings.create(
126
+ model="kanon-universal-classifier",
127
+ query="What are the essential elements required to establish a negligence claim?",
128
+ texts=[
129
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
130
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
131
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
132
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
133
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
134
+ ],
135
+ chunking_options={
136
+ "overlap_ratio": 0.1,
137
+ "overlap_tokens": 0,
138
+ "size": 512,
139
+ },
140
+ is_iql=False,
141
+ scoring_method="auto",
142
+ top_n=1,
143
+ )
144
+ assert_matches_type(Reranking, reranking, path=["response"])
145
+
146
+ @pytest.mark.skip()
147
+ @parametrize
148
+ async def test_raw_response_create(self, async_client: AsyncIsaacus) -> None:
149
+ response = await async_client.rerankings.with_raw_response.create(
150
+ model="kanon-universal-classifier",
151
+ query="What are the essential elements required to establish a negligence claim?",
152
+ texts=[
153
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
154
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
155
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
156
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
157
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
158
+ ],
159
+ )
160
+
161
+ assert response.is_closed is True
162
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
163
+ reranking = await response.parse()
164
+ assert_matches_type(Reranking, reranking, path=["response"])
165
+
166
+ @pytest.mark.skip()
167
+ @parametrize
168
+ async def test_streaming_response_create(self, async_client: AsyncIsaacus) -> None:
169
+ async with async_client.rerankings.with_streaming_response.create(
170
+ model="kanon-universal-classifier",
171
+ query="What are the essential elements required to establish a negligence claim?",
172
+ texts=[
173
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
174
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
175
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
176
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
177
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
178
+ ],
179
+ ) as response:
180
+ assert not response.is_closed
181
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
182
+
183
+ reranking = await response.parse()
184
+ assert_matches_type(Reranking, reranking, path=["response"])
185
+
186
+ assert cast(Any, response.is_closed) is True
@@ -1675,7 +1675,7 @@ class TestAsyncIsaacus:
1675
1675
  import threading
1676
1676
 
1677
1677
  from isaacus._utils import asyncify
1678
- from isaacus._base_client import get_platform
1678
+ from isaacus._base_client import get_platform
1679
1679
 
1680
1680
  async def test_main() -> None:
1681
1681
  result = await asyncify(get_platform)()
@@ -1,3 +0,0 @@
1
- {
2
- ".": "0.3.0"
3
- }
@@ -1,3 +0,0 @@
1
- # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- from __future__ import annotations
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes