athena-intelligence 0.1.87__py3-none-any.whl → 0.1.89__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 +126 -23
- 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.89.dist-info}/METADATA +1 -1
- {athena_intelligence-0.1.87.dist-info → athena_intelligence-0.1.89.dist-info}/RECORD +18 -18
- {athena_intelligence-0.1.87.dist-info → athena_intelligence-0.1.89.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
|
|
@@ -20,42 +21,103 @@ T = TypeVar("T")
|
|
20
21
|
U = TypeVar('U')
|
21
22
|
|
22
23
|
|
23
|
-
def
|
24
|
-
|
24
|
+
def _inherit_signature_and_doc(
|
25
|
+
f: typing.Callable[P, T],
|
26
|
+
replace_in_doc: typing.Dict[str, str]
|
27
|
+
) -> typing.Callable[..., typing.Callable[P, U]]:
|
28
|
+
def decorator(decorated):
|
29
|
+
for old, new in replace_in_doc.items():
|
30
|
+
assert old in f.__doc__
|
31
|
+
decorated.__doc__ = f.__doc__.replace(old, new)
|
32
|
+
return decorated
|
33
|
+
return decorator
|
25
34
|
|
26
35
|
|
27
36
|
class WrappedToolsClient(ToolsClient):
|
28
37
|
|
29
38
|
def get_file(self, document_id: str) -> io.BytesIO:
|
39
|
+
"""
|
40
|
+
Parameters
|
41
|
+
----------
|
42
|
+
document_id : str
|
43
|
+
|
44
|
+
Returns
|
45
|
+
-------
|
46
|
+
io.BytesIO
|
47
|
+
|
48
|
+
Examples
|
49
|
+
--------
|
50
|
+
import polars as pl
|
51
|
+
from athena.client import Athena
|
52
|
+
|
53
|
+
client = Athena(api_key="YOUR_API_KEY")
|
54
|
+
file_io = client.tools.get_file(document_id="document_id")
|
55
|
+
pl.read_csv(file_io)
|
56
|
+
"""
|
30
57
|
file_bytes = b''.join(self.raw_data(document_id=document_id))
|
31
58
|
bytes_io = io.BytesIO(file_bytes)
|
32
59
|
return bytes_io
|
33
60
|
|
34
|
-
@
|
61
|
+
@_inherit_signature_and_doc(ToolsClient.data_frame, {'DataFrameRequestOut': 'pd.DataFrame'})
|
35
62
|
def data_frame(self, *, document_id: str, **kwargs) -> 'pd.DataFrame':
|
36
63
|
_check_pandas_installed()
|
37
64
|
model = super().data_frame(document_id=document_id, **kwargs)
|
38
65
|
return _read_json_frame(model)
|
39
66
|
|
40
67
|
def read_data_frame(self, document_id: str, *args, **kwargs) -> 'pd.DataFrame':
|
68
|
+
"""
|
69
|
+
Parameters
|
70
|
+
----------
|
71
|
+
document_id : str
|
72
|
+
|
73
|
+
**kwargs : dict
|
74
|
+
keyword arguments passed to pandas `read_csv` or `read_excel` function,
|
75
|
+
depending on the file type of the document identified by `document_id`.
|
76
|
+
|
77
|
+
Returns
|
78
|
+
-------
|
79
|
+
pd.DataFrame
|
80
|
+
|
81
|
+
Examples
|
82
|
+
--------
|
83
|
+
from athena.client import Athena
|
84
|
+
|
85
|
+
client = Athena(api_key="YOUR_API_KEY")
|
86
|
+
client.tools.read_data_frame(document_id="document_id")
|
87
|
+
"""
|
41
88
|
_check_pandas_installed()
|
42
89
|
file_bytes = self.get_file(document_id)
|
43
90
|
return _to_pandas_df(file_bytes, *args, **kwargs)
|
44
91
|
|
45
92
|
|
93
|
+
def _add_docs_for_async_variant(obj):
|
94
|
+
def decorator(decorated):
|
95
|
+
doc = obj.__doc__
|
96
|
+
name = obj.__name__
|
97
|
+
decorated.__doc__ = (
|
98
|
+
doc
|
99
|
+
.replace('client = Athena', 'client = AsyncAthena')
|
100
|
+
.replace(f'client.tools.{name}', f'await client.tools.{name}')
|
101
|
+
)
|
102
|
+
return decorated
|
103
|
+
return decorator
|
104
|
+
|
105
|
+
|
46
106
|
class WrappedAsyncToolsClient(AsyncToolsClient):
|
47
107
|
|
108
|
+
@_add_docs_for_async_variant(WrappedToolsClient.get_file)
|
48
109
|
async def get_file(self, document_id: str) -> io.BytesIO:
|
49
110
|
file_bytes = b''.join([gen async for gen in self.raw_data(document_id=document_id)])
|
50
111
|
bytes_io = io.BytesIO(file_bytes)
|
51
112
|
return bytes_io
|
52
113
|
|
53
|
-
@
|
114
|
+
@_inherit_signature_and_doc(AsyncToolsClient.data_frame, {'DataFrameRequestOut': 'pd.DataFrame'})
|
54
115
|
async def data_frame(self, *, document_id: str, **kwargs) -> 'pd.DataFrame':
|
55
116
|
_check_pandas_installed()
|
56
117
|
model = await super().data_frame(document_id=document_id, **kwargs)
|
57
118
|
return _read_json_frame(model)
|
58
119
|
|
120
|
+
@_add_docs_for_async_variant(WrappedToolsClient.read_data_frame)
|
59
121
|
async def read_data_frame(self, document_id: str, *args, **kwargs) -> 'pd.DataFrame':
|
60
122
|
_check_pandas_installed()
|
61
123
|
file_bytes = await self.get_file(document_id)
|
@@ -66,19 +128,29 @@ class Athena(BaseAthena):
|
|
66
128
|
"""
|
67
129
|
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
130
|
|
69
|
-
Parameters
|
70
|
-
|
131
|
+
Parameters
|
132
|
+
----------
|
133
|
+
base_url : typing.Optional[str]
|
134
|
+
The base url to use for requests from the client.
|
135
|
+
|
136
|
+
environment : AthenaEnvironment
|
137
|
+
The environment to use for requests from the client. from .environment import AthenaEnvironment
|
71
138
|
|
72
|
-
- environment: AthenaEnvironment. The environment to use for requests from the client. from .environment import AthenaEnvironment
|
73
139
|
|
74
|
-
Defaults to AthenaEnvironment.DEFAULT
|
75
140
|
|
76
|
-
|
141
|
+
Defaults to AthenaEnvironment.DEFAULT
|
77
142
|
|
78
|
-
- timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds.
|
79
143
|
|
80
|
-
|
81
|
-
|
144
|
+
|
145
|
+
api_key: typing.Optional[str]. The API key. Required when used outside of the athena notebook environment.
|
146
|
+
timeout : typing.Optional[float]
|
147
|
+
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.
|
148
|
+
|
149
|
+
httpx_client : typing.Optional[httpx.Client]
|
150
|
+
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.
|
151
|
+
|
152
|
+
Examples
|
153
|
+
--------
|
82
154
|
from athena.client import Athena
|
83
155
|
|
84
156
|
client = Athena(
|
@@ -86,15 +158,25 @@ class Athena(BaseAthena):
|
|
86
158
|
)
|
87
159
|
"""
|
88
160
|
|
161
|
+
tools: WrappedToolsClient
|
162
|
+
|
89
163
|
def __init__(
|
90
164
|
self,
|
91
165
|
*,
|
92
166
|
base_url: typing.Optional[str] = None,
|
93
167
|
environment: AthenaEnvironment = AthenaEnvironment.DEFAULT,
|
94
|
-
api_key: str,
|
168
|
+
api_key: typing.Optional[str] = None,
|
95
169
|
timeout: typing.Optional[float] = 60,
|
96
170
|
httpx_client: typing.Optional[httpx.Client] = None
|
97
171
|
):
|
172
|
+
if api_key is None:
|
173
|
+
try:
|
174
|
+
api_key = os.environ['ATHENA_API_KEY']
|
175
|
+
except KeyError:
|
176
|
+
raise TypeError(
|
177
|
+
"Athena() missing 1 required keyword-only argument: 'api_key'"
|
178
|
+
' (ATHENA_API_KEY environment variable not found)'
|
179
|
+
)
|
98
180
|
super().__init__(
|
99
181
|
base_url=base_url,
|
100
182
|
environment=environment,
|
@@ -109,21 +191,32 @@ class Athena(BaseAthena):
|
|
109
191
|
|
110
192
|
class AsyncAthena(AsyncBaseAthena):
|
111
193
|
"""
|
112
|
-
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will
|
194
|
+
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.
|
195
|
+
|
196
|
+
|
197
|
+
Parameters
|
198
|
+
----------
|
199
|
+
base_url : typing.Optional[str]
|
200
|
+
The base url to use for requests from the client.
|
201
|
+
|
202
|
+
environment : AthenaEnvironment
|
203
|
+
The environment to use for requests from the client. from .environment import AthenaEnvironment
|
113
204
|
|
114
|
-
Parameters:
|
115
|
-
- base_url: typing.Optional[str]. The base url to use for requests from the client.
|
116
205
|
|
117
|
-
- environment: AthenaEnvironment. The environment to use for requests from the client. from .environment import AthenaEnvironment
|
118
206
|
|
119
|
-
|
207
|
+
Defaults to AthenaEnvironment.DEFAULT
|
120
208
|
|
121
|
-
- api_key: str.
|
122
209
|
|
123
|
-
- timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds.
|
124
210
|
|
125
|
-
|
126
|
-
|
211
|
+
api_key: typing.Optional[str]. The API key. Required when used outside of the athena notebook environment.
|
212
|
+
timeout : typing.Optional[float]
|
213
|
+
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.
|
214
|
+
|
215
|
+
httpx_client : typing.Optional[httpx.AsyncClient]
|
216
|
+
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.
|
217
|
+
|
218
|
+
Examples
|
219
|
+
--------
|
127
220
|
from athena.client import AsyncAthena
|
128
221
|
|
129
222
|
client = AsyncAthena(
|
@@ -131,15 +224,25 @@ class AsyncAthena(AsyncBaseAthena):
|
|
131
224
|
)
|
132
225
|
"""
|
133
226
|
|
227
|
+
tools: WrappedAsyncToolsClient
|
228
|
+
|
134
229
|
def __init__(
|
135
230
|
self,
|
136
231
|
*,
|
137
232
|
base_url: typing.Optional[str] = None,
|
138
233
|
environment: AthenaEnvironment = AthenaEnvironment.DEFAULT,
|
139
|
-
api_key: str,
|
234
|
+
api_key: typing.Optional[str] = None,
|
140
235
|
timeout: typing.Optional[float] = 60,
|
141
236
|
httpx_client: typing.Optional[httpx.AsyncClient] = None
|
142
237
|
):
|
238
|
+
if api_key is None:
|
239
|
+
try:
|
240
|
+
api_key = os.environ['ATHENA_API_KEY']
|
241
|
+
except KeyError:
|
242
|
+
raise TypeError(
|
243
|
+
"AsyncAthena() missing 1 required keyword-only argument: 'api_key'"
|
244
|
+
' (ATHENA_API_KEY environment variable not found)'
|
245
|
+
)
|
143
246
|
super().__init__(
|
144
247
|
base_url=base_url,
|
145
248
|
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.89",
|
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
|
+
)
|