isaacus 0.5.0__py3-none-any.whl → 0.6.0__py3-none-any.whl
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.
- isaacus/_base_client.py +175 -239
- isaacus/_client.py +10 -4
- isaacus/_models.py +2 -2
- isaacus/_response.py +1 -1
- isaacus/_utils/_utils.py +9 -1
- isaacus/_version.py +1 -1
- isaacus/resources/__init__.py +14 -0
- isaacus/resources/classifications/universal.py +3 -6
- isaacus/resources/extractions/__init__.py +33 -0
- isaacus/resources/extractions/extractions.py +102 -0
- isaacus/resources/extractions/qa.py +258 -0
- isaacus/resources/rerankings.py +3 -6
- isaacus/types/classifications/universal_create_params.py +1 -1
- isaacus/types/extractions/__init__.py +6 -0
- isaacus/types/extractions/answer_extraction.py +71 -0
- isaacus/types/extractions/qa_create_params.py +64 -0
- isaacus/types/reranking_create_params.py +1 -1
- {isaacus-0.5.0.dist-info → isaacus-0.6.0.dist-info}/METADATA +1 -1
- {isaacus-0.5.0.dist-info → isaacus-0.6.0.dist-info}/RECORD +21 -15
- {isaacus-0.5.0.dist-info → isaacus-0.6.0.dist-info}/WHEEL +0 -0
- {isaacus-0.5.0.dist-info → isaacus-0.6.0.dist-info}/licenses/LICENSE +0 -0
isaacus/resources/__init__.py
CHANGED
@@ -8,6 +8,14 @@ from .rerankings import (
|
|
8
8
|
RerankingsResourceWithStreamingResponse,
|
9
9
|
AsyncRerankingsResourceWithStreamingResponse,
|
10
10
|
)
|
11
|
+
from .extractions import (
|
12
|
+
ExtractionsResource,
|
13
|
+
AsyncExtractionsResource,
|
14
|
+
ExtractionsResourceWithRawResponse,
|
15
|
+
AsyncExtractionsResourceWithRawResponse,
|
16
|
+
ExtractionsResourceWithStreamingResponse,
|
17
|
+
AsyncExtractionsResourceWithStreamingResponse,
|
18
|
+
)
|
11
19
|
from .classifications import (
|
12
20
|
ClassificationsResource,
|
13
21
|
AsyncClassificationsResource,
|
@@ -30,4 +38,10 @@ __all__ = [
|
|
30
38
|
"AsyncRerankingsResourceWithRawResponse",
|
31
39
|
"RerankingsResourceWithStreamingResponse",
|
32
40
|
"AsyncRerankingsResourceWithStreamingResponse",
|
41
|
+
"ExtractionsResource",
|
42
|
+
"AsyncExtractionsResource",
|
43
|
+
"ExtractionsResourceWithRawResponse",
|
44
|
+
"AsyncExtractionsResourceWithRawResponse",
|
45
|
+
"ExtractionsResourceWithStreamingResponse",
|
46
|
+
"AsyncExtractionsResourceWithStreamingResponse",
|
33
47
|
]
|
@@ -8,10 +8,7 @@ from typing_extensions import Literal
|
|
8
8
|
import httpx
|
9
9
|
|
10
10
|
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
11
|
-
from ..._utils import
|
12
|
-
maybe_transform,
|
13
|
-
async_maybe_transform,
|
14
|
-
)
|
11
|
+
from ..._utils import maybe_transform, async_maybe_transform
|
15
12
|
from ..._compat import cached_property
|
16
13
|
from ..._resource import SyncAPIResource, AsyncAPIResource
|
17
14
|
from ..._response import (
|
@@ -81,7 +78,7 @@ class UniversalResource(SyncAPIResource):
|
|
81
78
|
|
82
79
|
texts: The texts to classify.
|
83
80
|
|
84
|
-
|
81
|
+
Each text must contain at least one non-whitespace character.
|
85
82
|
|
86
83
|
chunking_options: Options for how to split text into smaller chunks.
|
87
84
|
|
@@ -182,7 +179,7 @@ class AsyncUniversalResource(AsyncAPIResource):
|
|
182
179
|
|
183
180
|
texts: The texts to classify.
|
184
181
|
|
185
|
-
|
182
|
+
Each text must contain at least one non-whitespace character.
|
186
183
|
|
187
184
|
chunking_options: Options for how to split text into smaller chunks.
|
188
185
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from .qa import (
|
4
|
+
QaResource,
|
5
|
+
AsyncQaResource,
|
6
|
+
QaResourceWithRawResponse,
|
7
|
+
AsyncQaResourceWithRawResponse,
|
8
|
+
QaResourceWithStreamingResponse,
|
9
|
+
AsyncQaResourceWithStreamingResponse,
|
10
|
+
)
|
11
|
+
from .extractions import (
|
12
|
+
ExtractionsResource,
|
13
|
+
AsyncExtractionsResource,
|
14
|
+
ExtractionsResourceWithRawResponse,
|
15
|
+
AsyncExtractionsResourceWithRawResponse,
|
16
|
+
ExtractionsResourceWithStreamingResponse,
|
17
|
+
AsyncExtractionsResourceWithStreamingResponse,
|
18
|
+
)
|
19
|
+
|
20
|
+
__all__ = [
|
21
|
+
"QaResource",
|
22
|
+
"AsyncQaResource",
|
23
|
+
"QaResourceWithRawResponse",
|
24
|
+
"AsyncQaResourceWithRawResponse",
|
25
|
+
"QaResourceWithStreamingResponse",
|
26
|
+
"AsyncQaResourceWithStreamingResponse",
|
27
|
+
"ExtractionsResource",
|
28
|
+
"AsyncExtractionsResource",
|
29
|
+
"ExtractionsResourceWithRawResponse",
|
30
|
+
"AsyncExtractionsResourceWithRawResponse",
|
31
|
+
"ExtractionsResourceWithStreamingResponse",
|
32
|
+
"AsyncExtractionsResourceWithStreamingResponse",
|
33
|
+
]
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
from .qa import (
|
6
|
+
QaResource,
|
7
|
+
AsyncQaResource,
|
8
|
+
QaResourceWithRawResponse,
|
9
|
+
AsyncQaResourceWithRawResponse,
|
10
|
+
QaResourceWithStreamingResponse,
|
11
|
+
AsyncQaResourceWithStreamingResponse,
|
12
|
+
)
|
13
|
+
from ..._compat import cached_property
|
14
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
15
|
+
|
16
|
+
__all__ = ["ExtractionsResource", "AsyncExtractionsResource"]
|
17
|
+
|
18
|
+
|
19
|
+
class ExtractionsResource(SyncAPIResource):
|
20
|
+
@cached_property
|
21
|
+
def qa(self) -> QaResource:
|
22
|
+
return QaResource(self._client)
|
23
|
+
|
24
|
+
@cached_property
|
25
|
+
def with_raw_response(self) -> ExtractionsResourceWithRawResponse:
|
26
|
+
"""
|
27
|
+
This property can be used as a prefix for any HTTP method call to return
|
28
|
+
the raw response object instead of the parsed content.
|
29
|
+
|
30
|
+
For more information, see https://www.github.com/isaacus-dev/isaacus-python#accessing-raw-response-data-eg-headers
|
31
|
+
"""
|
32
|
+
return ExtractionsResourceWithRawResponse(self)
|
33
|
+
|
34
|
+
@cached_property
|
35
|
+
def with_streaming_response(self) -> ExtractionsResourceWithStreamingResponse:
|
36
|
+
"""
|
37
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
38
|
+
|
39
|
+
For more information, see https://www.github.com/isaacus-dev/isaacus-python#with_streaming_response
|
40
|
+
"""
|
41
|
+
return ExtractionsResourceWithStreamingResponse(self)
|
42
|
+
|
43
|
+
|
44
|
+
class AsyncExtractionsResource(AsyncAPIResource):
|
45
|
+
@cached_property
|
46
|
+
def qa(self) -> AsyncQaResource:
|
47
|
+
return AsyncQaResource(self._client)
|
48
|
+
|
49
|
+
@cached_property
|
50
|
+
def with_raw_response(self) -> AsyncExtractionsResourceWithRawResponse:
|
51
|
+
"""
|
52
|
+
This property can be used as a prefix for any HTTP method call to return
|
53
|
+
the raw response object instead of the parsed content.
|
54
|
+
|
55
|
+
For more information, see https://www.github.com/isaacus-dev/isaacus-python#accessing-raw-response-data-eg-headers
|
56
|
+
"""
|
57
|
+
return AsyncExtractionsResourceWithRawResponse(self)
|
58
|
+
|
59
|
+
@cached_property
|
60
|
+
def with_streaming_response(self) -> AsyncExtractionsResourceWithStreamingResponse:
|
61
|
+
"""
|
62
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
63
|
+
|
64
|
+
For more information, see https://www.github.com/isaacus-dev/isaacus-python#with_streaming_response
|
65
|
+
"""
|
66
|
+
return AsyncExtractionsResourceWithStreamingResponse(self)
|
67
|
+
|
68
|
+
|
69
|
+
class ExtractionsResourceWithRawResponse:
|
70
|
+
def __init__(self, extractions: ExtractionsResource) -> None:
|
71
|
+
self._extractions = extractions
|
72
|
+
|
73
|
+
@cached_property
|
74
|
+
def qa(self) -> QaResourceWithRawResponse:
|
75
|
+
return QaResourceWithRawResponse(self._extractions.qa)
|
76
|
+
|
77
|
+
|
78
|
+
class AsyncExtractionsResourceWithRawResponse:
|
79
|
+
def __init__(self, extractions: AsyncExtractionsResource) -> None:
|
80
|
+
self._extractions = extractions
|
81
|
+
|
82
|
+
@cached_property
|
83
|
+
def qa(self) -> AsyncQaResourceWithRawResponse:
|
84
|
+
return AsyncQaResourceWithRawResponse(self._extractions.qa)
|
85
|
+
|
86
|
+
|
87
|
+
class ExtractionsResourceWithStreamingResponse:
|
88
|
+
def __init__(self, extractions: ExtractionsResource) -> None:
|
89
|
+
self._extractions = extractions
|
90
|
+
|
91
|
+
@cached_property
|
92
|
+
def qa(self) -> QaResourceWithStreamingResponse:
|
93
|
+
return QaResourceWithStreamingResponse(self._extractions.qa)
|
94
|
+
|
95
|
+
|
96
|
+
class AsyncExtractionsResourceWithStreamingResponse:
|
97
|
+
def __init__(self, extractions: AsyncExtractionsResource) -> None:
|
98
|
+
self._extractions = extractions
|
99
|
+
|
100
|
+
@cached_property
|
101
|
+
def qa(self) -> AsyncQaResourceWithStreamingResponse:
|
102
|
+
return AsyncQaResourceWithStreamingResponse(self._extractions.qa)
|
@@ -0,0 +1,258 @@
|
|
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 NOT_GIVEN, Body, Query, Headers, NotGiven
|
11
|
+
from ..._utils import maybe_transform, async_maybe_transform
|
12
|
+
from ..._compat import cached_property
|
13
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
14
|
+
from ..._response import (
|
15
|
+
to_raw_response_wrapper,
|
16
|
+
to_streamed_response_wrapper,
|
17
|
+
async_to_raw_response_wrapper,
|
18
|
+
async_to_streamed_response_wrapper,
|
19
|
+
)
|
20
|
+
from ..._base_client import make_request_options
|
21
|
+
from ...types.extractions import qa_create_params
|
22
|
+
from ...types.extractions.answer_extraction import AnswerExtraction
|
23
|
+
|
24
|
+
__all__ = ["QaResource", "AsyncQaResource"]
|
25
|
+
|
26
|
+
|
27
|
+
class QaResource(SyncAPIResource):
|
28
|
+
@cached_property
|
29
|
+
def with_raw_response(self) -> QaResourceWithRawResponse:
|
30
|
+
"""
|
31
|
+
This property can be used as a prefix for any HTTP method call to return
|
32
|
+
the raw response object instead of the parsed content.
|
33
|
+
|
34
|
+
For more information, see https://www.github.com/isaacus-dev/isaacus-python#accessing-raw-response-data-eg-headers
|
35
|
+
"""
|
36
|
+
return QaResourceWithRawResponse(self)
|
37
|
+
|
38
|
+
@cached_property
|
39
|
+
def with_streaming_response(self) -> QaResourceWithStreamingResponse:
|
40
|
+
"""
|
41
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
42
|
+
|
43
|
+
For more information, see https://www.github.com/isaacus-dev/isaacus-python#with_streaming_response
|
44
|
+
"""
|
45
|
+
return QaResourceWithStreamingResponse(self)
|
46
|
+
|
47
|
+
def create(
|
48
|
+
self,
|
49
|
+
*,
|
50
|
+
model: Literal["kanon-answer-extractor", "kanon-answer-extractor-mini"],
|
51
|
+
query: str,
|
52
|
+
texts: List[str],
|
53
|
+
chunking_options: Optional[qa_create_params.ChunkingOptions] | NotGiven = NOT_GIVEN,
|
54
|
+
ignore_inextractability: bool | NotGiven = NOT_GIVEN,
|
55
|
+
top_k: int | NotGiven = NOT_GIVEN,
|
56
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
57
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
58
|
+
extra_headers: Headers | None = None,
|
59
|
+
extra_query: Query | None = None,
|
60
|
+
extra_body: Body | None = None,
|
61
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
62
|
+
) -> AnswerExtraction:
|
63
|
+
"""
|
64
|
+
Extract answers to questions from legal documents with an Isaacus legal AI
|
65
|
+
answer extractor.
|
66
|
+
|
67
|
+
Args:
|
68
|
+
model: The ID of the [model](https://docs.isaacus.com/models#extractive-qa) to use for
|
69
|
+
extractive question answering.
|
70
|
+
|
71
|
+
query: The query to extract the answer to.
|
72
|
+
|
73
|
+
The query must contain at least one non-whitespace character.
|
74
|
+
|
75
|
+
Unlike the texts from which the answer will be extracted, the query cannot be so
|
76
|
+
long that it exceeds the maximum input length of the model.
|
77
|
+
|
78
|
+
texts: The texts to search for the answer in and extract the answer from.
|
79
|
+
|
80
|
+
There must be at least one text.
|
81
|
+
|
82
|
+
Each text must contain at least one non-whitespace character.
|
83
|
+
|
84
|
+
chunking_options: Options for how to split text into smaller chunks.
|
85
|
+
|
86
|
+
ignore_inextractability: Whether to, if the model's score of the likelihood that an answer can not be
|
87
|
+
extracted from a text is greater than the highest score of all possible answers,
|
88
|
+
still return the highest scoring answers for that text.
|
89
|
+
|
90
|
+
If you have already determined that the texts answer the query, for example, by
|
91
|
+
using one of our classification or reranker models, then you should set this to
|
92
|
+
`true`.
|
93
|
+
|
94
|
+
top_k: The number of highest scoring answers to return.
|
95
|
+
|
96
|
+
If `null`, which is the default, all answers will be returned.
|
97
|
+
|
98
|
+
extra_headers: Send extra headers
|
99
|
+
|
100
|
+
extra_query: Add additional query parameters to the request
|
101
|
+
|
102
|
+
extra_body: Add additional JSON properties to the request
|
103
|
+
|
104
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
105
|
+
"""
|
106
|
+
return self._post(
|
107
|
+
"/extractions/qa",
|
108
|
+
body=maybe_transform(
|
109
|
+
{
|
110
|
+
"model": model,
|
111
|
+
"query": query,
|
112
|
+
"texts": texts,
|
113
|
+
"chunking_options": chunking_options,
|
114
|
+
"ignore_inextractability": ignore_inextractability,
|
115
|
+
"top_k": top_k,
|
116
|
+
},
|
117
|
+
qa_create_params.QaCreateParams,
|
118
|
+
),
|
119
|
+
options=make_request_options(
|
120
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
121
|
+
),
|
122
|
+
cast_to=AnswerExtraction,
|
123
|
+
)
|
124
|
+
|
125
|
+
|
126
|
+
class AsyncQaResource(AsyncAPIResource):
|
127
|
+
@cached_property
|
128
|
+
def with_raw_response(self) -> AsyncQaResourceWithRawResponse:
|
129
|
+
"""
|
130
|
+
This property can be used as a prefix for any HTTP method call to return
|
131
|
+
the raw response object instead of the parsed content.
|
132
|
+
|
133
|
+
For more information, see https://www.github.com/isaacus-dev/isaacus-python#accessing-raw-response-data-eg-headers
|
134
|
+
"""
|
135
|
+
return AsyncQaResourceWithRawResponse(self)
|
136
|
+
|
137
|
+
@cached_property
|
138
|
+
def with_streaming_response(self) -> AsyncQaResourceWithStreamingResponse:
|
139
|
+
"""
|
140
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
141
|
+
|
142
|
+
For more information, see https://www.github.com/isaacus-dev/isaacus-python#with_streaming_response
|
143
|
+
"""
|
144
|
+
return AsyncQaResourceWithStreamingResponse(self)
|
145
|
+
|
146
|
+
async def create(
|
147
|
+
self,
|
148
|
+
*,
|
149
|
+
model: Literal["kanon-answer-extractor", "kanon-answer-extractor-mini"],
|
150
|
+
query: str,
|
151
|
+
texts: List[str],
|
152
|
+
chunking_options: Optional[qa_create_params.ChunkingOptions] | NotGiven = NOT_GIVEN,
|
153
|
+
ignore_inextractability: bool | NotGiven = NOT_GIVEN,
|
154
|
+
top_k: int | NotGiven = NOT_GIVEN,
|
155
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
156
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
157
|
+
extra_headers: Headers | None = None,
|
158
|
+
extra_query: Query | None = None,
|
159
|
+
extra_body: Body | None = None,
|
160
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
161
|
+
) -> AnswerExtraction:
|
162
|
+
"""
|
163
|
+
Extract answers to questions from legal documents with an Isaacus legal AI
|
164
|
+
answer extractor.
|
165
|
+
|
166
|
+
Args:
|
167
|
+
model: The ID of the [model](https://docs.isaacus.com/models#extractive-qa) to use for
|
168
|
+
extractive question answering.
|
169
|
+
|
170
|
+
query: The query to extract the answer to.
|
171
|
+
|
172
|
+
The query must contain at least one non-whitespace character.
|
173
|
+
|
174
|
+
Unlike the texts from which the answer will be extracted, the query cannot be so
|
175
|
+
long that it exceeds the maximum input length of the model.
|
176
|
+
|
177
|
+
texts: The texts to search for the answer in and extract the answer from.
|
178
|
+
|
179
|
+
There must be at least one text.
|
180
|
+
|
181
|
+
Each text must contain at least one non-whitespace character.
|
182
|
+
|
183
|
+
chunking_options: Options for how to split text into smaller chunks.
|
184
|
+
|
185
|
+
ignore_inextractability: Whether to, if the model's score of the likelihood that an answer can not be
|
186
|
+
extracted from a text is greater than the highest score of all possible answers,
|
187
|
+
still return the highest scoring answers for that text.
|
188
|
+
|
189
|
+
If you have already determined that the texts answer the query, for example, by
|
190
|
+
using one of our classification or reranker models, then you should set this to
|
191
|
+
`true`.
|
192
|
+
|
193
|
+
top_k: The number of highest scoring answers to return.
|
194
|
+
|
195
|
+
If `null`, which is the default, all answers will be returned.
|
196
|
+
|
197
|
+
extra_headers: Send extra headers
|
198
|
+
|
199
|
+
extra_query: Add additional query parameters to the request
|
200
|
+
|
201
|
+
extra_body: Add additional JSON properties to the request
|
202
|
+
|
203
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
204
|
+
"""
|
205
|
+
return await self._post(
|
206
|
+
"/extractions/qa",
|
207
|
+
body=await async_maybe_transform(
|
208
|
+
{
|
209
|
+
"model": model,
|
210
|
+
"query": query,
|
211
|
+
"texts": texts,
|
212
|
+
"chunking_options": chunking_options,
|
213
|
+
"ignore_inextractability": ignore_inextractability,
|
214
|
+
"top_k": top_k,
|
215
|
+
},
|
216
|
+
qa_create_params.QaCreateParams,
|
217
|
+
),
|
218
|
+
options=make_request_options(
|
219
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
220
|
+
),
|
221
|
+
cast_to=AnswerExtraction,
|
222
|
+
)
|
223
|
+
|
224
|
+
|
225
|
+
class QaResourceWithRawResponse:
|
226
|
+
def __init__(self, qa: QaResource) -> None:
|
227
|
+
self._qa = qa
|
228
|
+
|
229
|
+
self.create = to_raw_response_wrapper(
|
230
|
+
qa.create,
|
231
|
+
)
|
232
|
+
|
233
|
+
|
234
|
+
class AsyncQaResourceWithRawResponse:
|
235
|
+
def __init__(self, qa: AsyncQaResource) -> None:
|
236
|
+
self._qa = qa
|
237
|
+
|
238
|
+
self.create = async_to_raw_response_wrapper(
|
239
|
+
qa.create,
|
240
|
+
)
|
241
|
+
|
242
|
+
|
243
|
+
class QaResourceWithStreamingResponse:
|
244
|
+
def __init__(self, qa: QaResource) -> None:
|
245
|
+
self._qa = qa
|
246
|
+
|
247
|
+
self.create = to_streamed_response_wrapper(
|
248
|
+
qa.create,
|
249
|
+
)
|
250
|
+
|
251
|
+
|
252
|
+
class AsyncQaResourceWithStreamingResponse:
|
253
|
+
def __init__(self, qa: AsyncQaResource) -> None:
|
254
|
+
self._qa = qa
|
255
|
+
|
256
|
+
self.create = async_to_streamed_response_wrapper(
|
257
|
+
qa.create,
|
258
|
+
)
|
isaacus/resources/rerankings.py
CHANGED
@@ -9,10 +9,7 @@ import httpx
|
|
9
9
|
|
10
10
|
from ..types import reranking_create_params
|
11
11
|
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
12
|
-
from .._utils import
|
13
|
-
maybe_transform,
|
14
|
-
async_maybe_transform,
|
15
|
-
)
|
12
|
+
from .._utils import maybe_transform, async_maybe_transform
|
16
13
|
from .._compat import cached_property
|
17
14
|
from .._resource import SyncAPIResource, AsyncAPIResource
|
18
15
|
from .._response import (
|
@@ -83,7 +80,7 @@ class RerankingsResource(SyncAPIResource):
|
|
83
80
|
|
84
81
|
There must be at least one text.
|
85
82
|
|
86
|
-
|
83
|
+
Each text must contain at least one non-whitespace character.
|
87
84
|
|
88
85
|
chunking_options: Options for how to split text into smaller chunks.
|
89
86
|
|
@@ -194,7 +191,7 @@ class AsyncRerankingsResource(AsyncAPIResource):
|
|
194
191
|
|
195
192
|
There must be at least one text.
|
196
193
|
|
197
|
-
|
194
|
+
Each text must contain at least one non-whitespace character.
|
198
195
|
|
199
196
|
chunking_options: Options for how to split text into smaller chunks.
|
200
197
|
|
@@ -29,7 +29,7 @@ class UniversalCreateParams(TypedDict, total=False):
|
|
29
29
|
texts: Required[List[str]]
|
30
30
|
"""The texts to classify.
|
31
31
|
|
32
|
-
|
32
|
+
Each text must contain at least one non-whitespace character.
|
33
33
|
"""
|
34
34
|
|
35
35
|
chunking_options: Optional[ChunkingOptions]
|
@@ -0,0 +1,71 @@
|
|
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__ = ["AnswerExtraction", "Extraction", "ExtractionAnswer", "Usage"]
|
8
|
+
|
9
|
+
|
10
|
+
class ExtractionAnswer(BaseModel):
|
11
|
+
end: int
|
12
|
+
"""
|
13
|
+
The index of the character immediately after the last character of the answer in
|
14
|
+
the text, starting from `0` (such that, in Python, the answer is equivalent to
|
15
|
+
`text[start:end]`).
|
16
|
+
"""
|
17
|
+
|
18
|
+
score: float
|
19
|
+
"""
|
20
|
+
A score between `0` and `1`, inclusive, representing the strength of the answer.
|
21
|
+
"""
|
22
|
+
|
23
|
+
start: int
|
24
|
+
"""
|
25
|
+
The index of the first character of the answer in the text, starting from `0`
|
26
|
+
(and, therefore, ending at the number of characters in the text minus `1`).
|
27
|
+
"""
|
28
|
+
|
29
|
+
text: str
|
30
|
+
"""The text of the answer."""
|
31
|
+
|
32
|
+
|
33
|
+
class Extraction(BaseModel):
|
34
|
+
answers: List[ExtractionAnswer]
|
35
|
+
"""Answers extracted from the text, ordered from highest to lowest score."""
|
36
|
+
|
37
|
+
index: int
|
38
|
+
"""
|
39
|
+
The index of the text in the input array of texts that this result represents,
|
40
|
+
starting from `0` (and, therefore, ending at the number of texts minus `1`).
|
41
|
+
"""
|
42
|
+
|
43
|
+
inextractability_score: float
|
44
|
+
"""
|
45
|
+
A score between `0` and `1`, inclusive, representing the likelihood that an
|
46
|
+
answer can not be extracted from the text.
|
47
|
+
|
48
|
+
Where this score is greater than the highest score of all possible answers, the
|
49
|
+
text should be regarded as not having an extractable answer to the query. If
|
50
|
+
that is the case and `ignore_inextractability` is `false`, no answers will be
|
51
|
+
returned.
|
52
|
+
"""
|
53
|
+
|
54
|
+
|
55
|
+
class Usage(BaseModel):
|
56
|
+
input_tokens: int
|
57
|
+
"""The number of tokens inputted to the model."""
|
58
|
+
|
59
|
+
|
60
|
+
class AnswerExtraction(BaseModel):
|
61
|
+
extractions: List[Extraction]
|
62
|
+
"""
|
63
|
+
The results of extracting answers from the texts, ordered from highest to lowest
|
64
|
+
inextractability score.
|
65
|
+
"""
|
66
|
+
|
67
|
+
usage: Usage
|
68
|
+
"""
|
69
|
+
Statistics about the usage of resources in the process of extracting answers
|
70
|
+
from the texts.
|
71
|
+
"""
|
@@ -0,0 +1,64 @@
|
|
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__ = ["QaCreateParams", "ChunkingOptions"]
|
9
|
+
|
10
|
+
|
11
|
+
class QaCreateParams(TypedDict, total=False):
|
12
|
+
model: Required[Literal["kanon-answer-extractor", "kanon-answer-extractor-mini"]]
|
13
|
+
"""
|
14
|
+
The ID of the [model](https://docs.isaacus.com/models#extractive-qa) to use for
|
15
|
+
extractive question answering.
|
16
|
+
"""
|
17
|
+
|
18
|
+
query: Required[str]
|
19
|
+
"""The query to extract the answer to.
|
20
|
+
|
21
|
+
The query must contain at least one non-whitespace character.
|
22
|
+
|
23
|
+
Unlike the texts from which the answer will be extracted, the query cannot be so
|
24
|
+
long that it exceeds the maximum input length of the model.
|
25
|
+
"""
|
26
|
+
|
27
|
+
texts: Required[List[str]]
|
28
|
+
"""The texts to search for the answer in and extract the answer from.
|
29
|
+
|
30
|
+
There must be at least one text.
|
31
|
+
|
32
|
+
Each text 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
|
+
ignore_inextractability: bool
|
39
|
+
"""
|
40
|
+
Whether to, if the model's score of the likelihood that an answer can not be
|
41
|
+
extracted from a text is greater than the highest score of all possible answers,
|
42
|
+
still return the highest scoring answers for that text.
|
43
|
+
|
44
|
+
If you have already determined that the texts answer the query, for example, by
|
45
|
+
using one of our classification or reranker models, then you should set this to
|
46
|
+
`true`.
|
47
|
+
"""
|
48
|
+
|
49
|
+
top_k: int
|
50
|
+
"""The number of highest scoring answers to return.
|
51
|
+
|
52
|
+
If `null`, which is the default, all answers will be returned.
|
53
|
+
"""
|
54
|
+
|
55
|
+
|
56
|
+
class ChunkingOptions(TypedDict, total=False):
|
57
|
+
overlap_ratio: Optional[float]
|
58
|
+
"""A number greater than or equal to 0 and less than 1."""
|
59
|
+
|
60
|
+
overlap_tokens: Optional[int]
|
61
|
+
"""A whole number greater than -1."""
|
62
|
+
|
63
|
+
size: Optional[int]
|
64
|
+
"""A whole number greater than or equal to 1."""
|
@@ -29,7 +29,7 @@ class RerankingCreateParams(TypedDict, total=False):
|
|
29
29
|
|
30
30
|
There must be at least one text.
|
31
31
|
|
32
|
-
|
32
|
+
Each text must contain at least one non-whitespace character.
|
33
33
|
"""
|
34
34
|
|
35
35
|
chunking_options: Optional[ChunkingOptions]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: isaacus
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.6.0
|
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
|