athena-intelligence 0.1.87__py3-none-any.whl → 0.1.88__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.
- athena/base_client.py +4 -4
- athena/chain/client.py +30 -138
- athena/client.py +57 -19
- athena/core/client_wrapper.py +13 -3
- athena/core/http_client.py +333 -20
- athena/core/remove_none_from_dict.py +2 -2
- athena/dataset/client.py +8 -64
- athena/message/client.py +20 -113
- athena/query/client.py +8 -54
- athena/report/client.py +10 -66
- athena/search/client.py +22 -68
- athena/snippet/client.py +10 -116
- athena/tools/client.py +112 -542
- athena/upload/client.py +2 -58
- athena/workflow/client.py +8 -54
- {athena_intelligence-0.1.87.dist-info → athena_intelligence-0.1.88.dist-info}/METADATA +1 -1
- {athena_intelligence-0.1.87.dist-info → athena_intelligence-0.1.88.dist-info}/RECORD +18 -18
- {athena_intelligence-0.1.87.dist-info → athena_intelligence-0.1.88.dist-info}/WHEEL +0 -0
athena/base_client.py
CHANGED
@@ -20,7 +20,7 @@ from .workflow.client import AsyncWorkflowClient, WorkflowClient
|
|
20
20
|
|
21
21
|
class BaseAthena:
|
22
22
|
"""
|
23
|
-
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will
|
23
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
24
24
|
|
25
25
|
Parameters
|
26
26
|
----------
|
@@ -38,7 +38,7 @@ class BaseAthena:
|
|
38
38
|
|
39
39
|
api_key : str
|
40
40
|
timeout : typing.Optional[float]
|
41
|
-
The timeout to be used, in seconds, for requests
|
41
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
42
42
|
|
43
43
|
follow_redirects : typing.Optional[bool]
|
44
44
|
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
@@ -90,7 +90,7 @@ class BaseAthena:
|
|
90
90
|
|
91
91
|
class AsyncBaseAthena:
|
92
92
|
"""
|
93
|
-
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will
|
93
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
94
94
|
|
95
95
|
Parameters
|
96
96
|
----------
|
@@ -108,7 +108,7 @@ class AsyncBaseAthena:
|
|
108
108
|
|
109
109
|
api_key : str
|
110
110
|
timeout : typing.Optional[float]
|
111
|
-
The timeout to be used, in seconds, for requests
|
111
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
112
112
|
|
113
113
|
follow_redirects : typing.Optional[bool]
|
114
114
|
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
athena/chain/client.py
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
3
|
import typing
|
4
|
-
import urllib.parse
|
5
4
|
from json.decoder import JSONDecodeError
|
6
5
|
|
7
6
|
from ..core.api_error import ApiError
|
8
7
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
9
|
-
from ..core.jsonable_encoder import jsonable_encoder
|
10
8
|
from ..core.pydantic_utilities import pydantic_v1
|
11
|
-
from ..core.query_encoder import encode_query
|
12
|
-
from ..core.remove_none_from_dict import remove_none_from_dict
|
13
9
|
from ..core.request_options import RequestOptions
|
14
10
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
15
11
|
from ..types.document import Document
|
@@ -32,7 +28,7 @@ class ChainClient:
|
|
32
28
|
text_input: str,
|
33
29
|
custom_type_dict: typing.Dict[str, typing.Any],
|
34
30
|
model: LlmModel,
|
35
|
-
request_options: typing.Optional[RequestOptions] = None
|
31
|
+
request_options: typing.Optional[RequestOptions] = None
|
36
32
|
) -> StructuredParseResult:
|
37
33
|
"""
|
38
34
|
Parameters
|
@@ -68,32 +64,11 @@ class ChainClient:
|
|
68
64
|
)
|
69
65
|
"""
|
70
66
|
_response = self._client_wrapper.httpx_client.request(
|
67
|
+
"api/v0/structured-parse",
|
71
68
|
method="POST",
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
request_options.get("additional_query_parameters") if request_options is not None else None
|
76
|
-
)
|
77
|
-
),
|
78
|
-
json=jsonable_encoder({"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model})
|
79
|
-
if request_options is None or request_options.get("additional_body_parameters") is None
|
80
|
-
else {
|
81
|
-
**jsonable_encoder({"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model}),
|
82
|
-
**(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
|
83
|
-
},
|
84
|
-
headers=jsonable_encoder(
|
85
|
-
remove_none_from_dict(
|
86
|
-
{
|
87
|
-
**self._client_wrapper.get_headers(),
|
88
|
-
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
89
|
-
}
|
90
|
-
)
|
91
|
-
),
|
92
|
-
timeout=request_options.get("timeout_in_seconds")
|
93
|
-
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
94
|
-
else self._client_wrapper.get_timeout(),
|
95
|
-
retries=0,
|
96
|
-
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
69
|
+
json={"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model},
|
70
|
+
request_options=request_options,
|
71
|
+
omit=OMIT,
|
97
72
|
)
|
98
73
|
if 200 <= _response.status_code < 300:
|
99
74
|
return pydantic_v1.parse_obj_as(StructuredParseResult, _response.json()) # type: ignore
|
@@ -115,7 +90,7 @@ class ChainClient:
|
|
115
90
|
operator_prompt: str,
|
116
91
|
reducer_prompt: str,
|
117
92
|
input: str,
|
118
|
-
request_options: typing.Optional[RequestOptions] = None
|
93
|
+
request_options: typing.Optional[RequestOptions] = None
|
119
94
|
) -> MapReduceChainOut:
|
120
95
|
"""
|
121
96
|
Parameters
|
@@ -160,48 +135,17 @@ class ChainClient:
|
|
160
135
|
)
|
161
136
|
"""
|
162
137
|
_response = self._client_wrapper.httpx_client.request(
|
138
|
+
"api/v0/tools/map-reduce",
|
163
139
|
method="POST",
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
json=jsonable_encoder(
|
171
|
-
{
|
172
|
-
"documents": documents,
|
173
|
-
"model": model,
|
174
|
-
"operator_prompt": operator_prompt,
|
175
|
-
"reducer_prompt": reducer_prompt,
|
176
|
-
"input": input,
|
177
|
-
}
|
178
|
-
)
|
179
|
-
if request_options is None or request_options.get("additional_body_parameters") is None
|
180
|
-
else {
|
181
|
-
**jsonable_encoder(
|
182
|
-
{
|
183
|
-
"documents": documents,
|
184
|
-
"model": model,
|
185
|
-
"operator_prompt": operator_prompt,
|
186
|
-
"reducer_prompt": reducer_prompt,
|
187
|
-
"input": input,
|
188
|
-
}
|
189
|
-
),
|
190
|
-
**(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
|
140
|
+
json={
|
141
|
+
"documents": documents,
|
142
|
+
"model": model,
|
143
|
+
"operator_prompt": operator_prompt,
|
144
|
+
"reducer_prompt": reducer_prompt,
|
145
|
+
"input": input,
|
191
146
|
},
|
192
|
-
|
193
|
-
|
194
|
-
{
|
195
|
-
**self._client_wrapper.get_headers(),
|
196
|
-
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
197
|
-
}
|
198
|
-
)
|
199
|
-
),
|
200
|
-
timeout=request_options.get("timeout_in_seconds")
|
201
|
-
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
202
|
-
else self._client_wrapper.get_timeout(),
|
203
|
-
retries=0,
|
204
|
-
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
147
|
+
request_options=request_options,
|
148
|
+
omit=OMIT,
|
205
149
|
)
|
206
150
|
if 200 <= _response.status_code < 300:
|
207
151
|
return pydantic_v1.parse_obj_as(MapReduceChainOut, _response.json()) # type: ignore
|
@@ -226,7 +170,7 @@ class AsyncChainClient:
|
|
226
170
|
text_input: str,
|
227
171
|
custom_type_dict: typing.Dict[str, typing.Any],
|
228
172
|
model: LlmModel,
|
229
|
-
request_options: typing.Optional[RequestOptions] = None
|
173
|
+
request_options: typing.Optional[RequestOptions] = None
|
230
174
|
) -> StructuredParseResult:
|
231
175
|
"""
|
232
176
|
Parameters
|
@@ -262,32 +206,11 @@ class AsyncChainClient:
|
|
262
206
|
)
|
263
207
|
"""
|
264
208
|
_response = await self._client_wrapper.httpx_client.request(
|
209
|
+
"api/v0/structured-parse",
|
265
210
|
method="POST",
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
request_options.get("additional_query_parameters") if request_options is not None else None
|
270
|
-
)
|
271
|
-
),
|
272
|
-
json=jsonable_encoder({"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model})
|
273
|
-
if request_options is None or request_options.get("additional_body_parameters") is None
|
274
|
-
else {
|
275
|
-
**jsonable_encoder({"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model}),
|
276
|
-
**(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
|
277
|
-
},
|
278
|
-
headers=jsonable_encoder(
|
279
|
-
remove_none_from_dict(
|
280
|
-
{
|
281
|
-
**self._client_wrapper.get_headers(),
|
282
|
-
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
283
|
-
}
|
284
|
-
)
|
285
|
-
),
|
286
|
-
timeout=request_options.get("timeout_in_seconds")
|
287
|
-
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
288
|
-
else self._client_wrapper.get_timeout(),
|
289
|
-
retries=0,
|
290
|
-
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
211
|
+
json={"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model},
|
212
|
+
request_options=request_options,
|
213
|
+
omit=OMIT,
|
291
214
|
)
|
292
215
|
if 200 <= _response.status_code < 300:
|
293
216
|
return pydantic_v1.parse_obj_as(StructuredParseResult, _response.json()) # type: ignore
|
@@ -309,7 +232,7 @@ class AsyncChainClient:
|
|
309
232
|
operator_prompt: str,
|
310
233
|
reducer_prompt: str,
|
311
234
|
input: str,
|
312
|
-
request_options: typing.Optional[RequestOptions] = None
|
235
|
+
request_options: typing.Optional[RequestOptions] = None
|
313
236
|
) -> MapReduceChainOut:
|
314
237
|
"""
|
315
238
|
Parameters
|
@@ -354,48 +277,17 @@ class AsyncChainClient:
|
|
354
277
|
)
|
355
278
|
"""
|
356
279
|
_response = await self._client_wrapper.httpx_client.request(
|
280
|
+
"api/v0/tools/map-reduce",
|
357
281
|
method="POST",
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
json=jsonable_encoder(
|
365
|
-
{
|
366
|
-
"documents": documents,
|
367
|
-
"model": model,
|
368
|
-
"operator_prompt": operator_prompt,
|
369
|
-
"reducer_prompt": reducer_prompt,
|
370
|
-
"input": input,
|
371
|
-
}
|
372
|
-
)
|
373
|
-
if request_options is None or request_options.get("additional_body_parameters") is None
|
374
|
-
else {
|
375
|
-
**jsonable_encoder(
|
376
|
-
{
|
377
|
-
"documents": documents,
|
378
|
-
"model": model,
|
379
|
-
"operator_prompt": operator_prompt,
|
380
|
-
"reducer_prompt": reducer_prompt,
|
381
|
-
"input": input,
|
382
|
-
}
|
383
|
-
),
|
384
|
-
**(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
|
282
|
+
json={
|
283
|
+
"documents": documents,
|
284
|
+
"model": model,
|
285
|
+
"operator_prompt": operator_prompt,
|
286
|
+
"reducer_prompt": reducer_prompt,
|
287
|
+
"input": input,
|
385
288
|
},
|
386
|
-
|
387
|
-
|
388
|
-
{
|
389
|
-
**self._client_wrapper.get_headers(),
|
390
|
-
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
391
|
-
}
|
392
|
-
)
|
393
|
-
),
|
394
|
-
timeout=request_options.get("timeout_in_seconds")
|
395
|
-
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
396
|
-
else self._client_wrapper.get_timeout(),
|
397
|
-
retries=0,
|
398
|
-
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
289
|
+
request_options=request_options,
|
290
|
+
omit=OMIT,
|
399
291
|
)
|
400
292
|
if 200 <= _response.status_code < 300:
|
401
293
|
return pydantic_v1.parse_obj_as(MapReduceChainOut, _response.json()) # type: ignore
|
athena/client.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import io
|
2
|
+
import os
|
2
3
|
import typing
|
3
4
|
import warnings
|
4
5
|
|
@@ -66,19 +67,29 @@ class Athena(BaseAthena):
|
|
66
67
|
"""
|
67
68
|
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions.
|
68
69
|
|
69
|
-
Parameters
|
70
|
-
|
70
|
+
Parameters
|
71
|
+
----------
|
72
|
+
base_url : typing.Optional[str]
|
73
|
+
The base url to use for requests from the client.
|
71
74
|
|
72
|
-
|
75
|
+
environment : AthenaEnvironment
|
76
|
+
The environment to use for requests from the client. from .environment import AthenaEnvironment
|
73
77
|
|
74
|
-
Defaults to AthenaEnvironment.DEFAULT
|
75
78
|
|
76
|
-
- api_key: str.
|
77
79
|
|
78
|
-
|
80
|
+
Defaults to AthenaEnvironment.DEFAULT
|
79
81
|
|
80
|
-
|
81
|
-
|
82
|
+
|
83
|
+
|
84
|
+
api_key: typing.Optional[str]. The API key. Required when used outside of the athena notebook environment.
|
85
|
+
timeout : typing.Optional[float]
|
86
|
+
The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set.
|
87
|
+
|
88
|
+
httpx_client : typing.Optional[httpx.Client]
|
89
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
90
|
+
|
91
|
+
Examples
|
92
|
+
--------
|
82
93
|
from athena.client import Athena
|
83
94
|
|
84
95
|
client = Athena(
|
@@ -91,10 +102,18 @@ class Athena(BaseAthena):
|
|
91
102
|
*,
|
92
103
|
base_url: typing.Optional[str] = None,
|
93
104
|
environment: AthenaEnvironment = AthenaEnvironment.DEFAULT,
|
94
|
-
api_key: str,
|
105
|
+
api_key: typing.Optional[str] = None,
|
95
106
|
timeout: typing.Optional[float] = 60,
|
96
107
|
httpx_client: typing.Optional[httpx.Client] = None
|
97
108
|
):
|
109
|
+
if api_key is None:
|
110
|
+
try:
|
111
|
+
api_key = os.environ['ATHENA_API_KEY']
|
112
|
+
except KeyError:
|
113
|
+
raise TypeError(
|
114
|
+
"Athena() missing 1 required keyword-only argument: 'api_key'"
|
115
|
+
' (ATHENA_API_KEY environment variable not found)'
|
116
|
+
)
|
98
117
|
super().__init__(
|
99
118
|
base_url=base_url,
|
100
119
|
environment=environment,
|
@@ -109,21 +128,32 @@ class Athena(BaseAthena):
|
|
109
128
|
|
110
129
|
class AsyncAthena(AsyncBaseAthena):
|
111
130
|
"""
|
112
|
-
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will
|
131
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
132
|
+
|
133
|
+
|
134
|
+
Parameters
|
135
|
+
----------
|
136
|
+
base_url : typing.Optional[str]
|
137
|
+
The base url to use for requests from the client.
|
138
|
+
|
139
|
+
environment : AthenaEnvironment
|
140
|
+
The environment to use for requests from the client. from .environment import AthenaEnvironment
|
141
|
+
|
142
|
+
|
113
143
|
|
114
|
-
|
115
|
-
- base_url: typing.Optional[str]. The base url to use for requests from the client.
|
144
|
+
Defaults to AthenaEnvironment.DEFAULT
|
116
145
|
|
117
|
-
- environment: AthenaEnvironment. The environment to use for requests from the client. from .environment import AthenaEnvironment
|
118
146
|
|
119
|
-
Defaults to AthenaEnvironment.DEFAULT
|
120
147
|
|
121
|
-
|
148
|
+
api_key: typing.Optional[str]. The API key. Required when used outside of the athena notebook environment.
|
149
|
+
timeout : typing.Optional[float]
|
150
|
+
The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set.
|
122
151
|
|
123
|
-
|
152
|
+
httpx_client : typing.Optional[httpx.AsyncClient]
|
153
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
124
154
|
|
125
|
-
|
126
|
-
|
155
|
+
Examples
|
156
|
+
--------
|
127
157
|
from athena.client import AsyncAthena
|
128
158
|
|
129
159
|
client = AsyncAthena(
|
@@ -136,10 +166,18 @@ class AsyncAthena(AsyncBaseAthena):
|
|
136
166
|
*,
|
137
167
|
base_url: typing.Optional[str] = None,
|
138
168
|
environment: AthenaEnvironment = AthenaEnvironment.DEFAULT,
|
139
|
-
api_key: str,
|
169
|
+
api_key: typing.Optional[str] = None,
|
140
170
|
timeout: typing.Optional[float] = 60,
|
141
171
|
httpx_client: typing.Optional[httpx.AsyncClient] = None
|
142
172
|
):
|
173
|
+
if api_key is None:
|
174
|
+
try:
|
175
|
+
api_key = os.environ['ATHENA_API_KEY']
|
176
|
+
except KeyError:
|
177
|
+
raise TypeError(
|
178
|
+
"AsyncAthena() missing 1 required keyword-only argument: 'api_key'"
|
179
|
+
' (ATHENA_API_KEY environment variable not found)'
|
180
|
+
)
|
143
181
|
super().__init__(
|
144
182
|
base_url=base_url,
|
145
183
|
environment=environment,
|
athena/core/client_wrapper.py
CHANGED
@@ -17,7 +17,7 @@ class BaseClientWrapper:
|
|
17
17
|
headers: typing.Dict[str, str] = {
|
18
18
|
"X-Fern-Language": "Python",
|
19
19
|
"X-Fern-SDK-Name": "athena-intelligence",
|
20
|
-
"X-Fern-SDK-Version": "0.1.
|
20
|
+
"X-Fern-SDK-Version": "0.1.88",
|
21
21
|
}
|
22
22
|
headers["X-API-KEY"] = self.api_key
|
23
23
|
return headers
|
@@ -34,7 +34,12 @@ class SyncClientWrapper(BaseClientWrapper):
|
|
34
34
|
self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.Client
|
35
35
|
):
|
36
36
|
super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
|
37
|
-
self.httpx_client = HttpClient(
|
37
|
+
self.httpx_client = HttpClient(
|
38
|
+
httpx_client=httpx_client,
|
39
|
+
base_headers=self.get_headers(),
|
40
|
+
base_timeout=self.get_timeout(),
|
41
|
+
base_url=self.get_base_url(),
|
42
|
+
)
|
38
43
|
|
39
44
|
|
40
45
|
class AsyncClientWrapper(BaseClientWrapper):
|
@@ -42,4 +47,9 @@ class AsyncClientWrapper(BaseClientWrapper):
|
|
42
47
|
self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient
|
43
48
|
):
|
44
49
|
super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
|
45
|
-
self.httpx_client = AsyncHttpClient(
|
50
|
+
self.httpx_client = AsyncHttpClient(
|
51
|
+
httpx_client=httpx_client,
|
52
|
+
base_headers=self.get_headers(),
|
53
|
+
base_timeout=self.get_timeout(),
|
54
|
+
base_url=self.get_base_url(),
|
55
|
+
)
|