athena-intelligence 0.1.124__py3-none-any.whl → 0.1.125__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/client.py +35 -24
- athena/core/client_wrapper.py +1 -1
- {athena_intelligence-0.1.124.dist-info → athena_intelligence-0.1.125.dist-info}/METADATA +1 -1
- {athena_intelligence-0.1.124.dist-info → athena_intelligence-0.1.125.dist-info}/RECORD +5 -5
- {athena_intelligence-0.1.124.dist-info → athena_intelligence-0.1.125.dist-info}/WHEEL +0 -0
athena/client.py
CHANGED
@@ -7,7 +7,7 @@ import typing
|
|
7
7
|
import warnings
|
8
8
|
|
9
9
|
import httpx
|
10
|
-
from typing import cast, List, Union
|
10
|
+
from typing import cast, List, Tuple, Union
|
11
11
|
from typing_extensions import TypeVar, ParamSpec
|
12
12
|
|
13
13
|
from . import core
|
@@ -116,8 +116,8 @@ class WrappedToolsClient(ToolsClient):
|
|
116
116
|
client.tools.read_data_frame(asset_id="asset_id")
|
117
117
|
"""
|
118
118
|
_check_pandas_installed()
|
119
|
-
file_bytes = self.
|
120
|
-
return _to_pandas_df(file_bytes, *args, **kwargs)
|
119
|
+
file_bytes, media_type = self._get_file_and_media_type(asset_id=asset_id)
|
120
|
+
return _to_pandas_df(file_bytes, *args, media_type=media_type, **kwargs)
|
121
121
|
|
122
122
|
|
123
123
|
def save_asset( # type: ignore[override]
|
@@ -131,7 +131,7 @@ class WrappedToolsClient(ToolsClient):
|
|
131
131
|
"""
|
132
132
|
Parameters
|
133
133
|
----------
|
134
|
-
asset_object : pd.DataFrame | pd.Series | core.File
|
134
|
+
asset_object : pd.DataFrame | pd.Series | matplotlib.figure.Figure | core.File
|
135
135
|
A pandas data frame, series, matplotlib figure, or core.File
|
136
136
|
|
137
137
|
parent_folder_id : typing.Optional[str]
|
@@ -143,6 +143,8 @@ class WrappedToolsClient(ToolsClient):
|
|
143
143
|
request_options : typing.Optional[RequestOptions]
|
144
144
|
Request-specific configuration.
|
145
145
|
|
146
|
+
**kwargs : passed down to conversion methods
|
147
|
+
|
146
148
|
Returns
|
147
149
|
-------
|
148
150
|
SaveAssetRequestOut
|
@@ -155,27 +157,14 @@ class WrappedToolsClient(ToolsClient):
|
|
155
157
|
client = Athena(api_key="YOUR_API_KEY")
|
156
158
|
client.tools.save_asset(df)
|
157
159
|
"""
|
158
|
-
asset_object = _convert_asset_object(asset_object=asset_object, name=name)
|
160
|
+
asset_object = _convert_asset_object(asset_object=asset_object, name=name, **kwargs)
|
159
161
|
return super().save_asset(
|
160
|
-
file=asset_object, parent_folder_id=parent_folder_id
|
162
|
+
file=asset_object, parent_folder_id=parent_folder_id
|
161
163
|
)
|
162
164
|
|
163
|
-
def
|
165
|
+
def _get_file_and_media_type(self, asset_id: str) -> Tuple[io.BytesIO, str]:
|
164
166
|
"""
|
165
|
-
|
166
|
-
----------
|
167
|
-
asset_id : str
|
168
|
-
|
169
|
-
Returns
|
170
|
-
-------
|
171
|
-
pd.DataFrame or AthenaAsset
|
172
|
-
|
173
|
-
Examples
|
174
|
-
--------
|
175
|
-
from athena.client import Athena
|
176
|
-
|
177
|
-
client = Athena(api_key="YOUR_API_KEY")
|
178
|
-
client.tools.get_asset(asset_id="asset_id")
|
167
|
+
Gets the file togehter with media type returned by server
|
179
168
|
"""
|
180
169
|
# while we wait for https://github.com/fern-api/fern/issues/4316
|
181
170
|
result = self._client_wrapper.httpx_client.request(
|
@@ -196,6 +185,27 @@ class WrappedToolsClient(ToolsClient):
|
|
196
185
|
# fallback to `libmagic` inference
|
197
186
|
media_type = _infer_media_type(bytes_io=file_bytes)
|
198
187
|
|
188
|
+
return file_bytes, media_type
|
189
|
+
|
190
|
+
def get_asset(self, asset_id: str) -> Union["pd.DataFrame", AthenaAsset]:
|
191
|
+
"""
|
192
|
+
Parameters
|
193
|
+
----------
|
194
|
+
asset_id : str
|
195
|
+
|
196
|
+
Returns
|
197
|
+
-------
|
198
|
+
pd.DataFrame or AthenaAsset
|
199
|
+
|
200
|
+
Examples
|
201
|
+
--------
|
202
|
+
from athena.client import Athena
|
203
|
+
|
204
|
+
client = Athena(api_key="YOUR_API_KEY")
|
205
|
+
client.tools.get_asset(asset_id="asset_id")
|
206
|
+
"""
|
207
|
+
file_bytes, media_type = self._get_file_and_media_type(asset_id=asset_id)
|
208
|
+
|
199
209
|
media_type_aliases = {"image/jpg": "image/jpeg"}
|
200
210
|
media_type = media_type_aliases.get(media_type, media_type)
|
201
211
|
|
@@ -289,9 +299,9 @@ class WrappedAsyncToolsClient(AsyncToolsClient):
|
|
289
299
|
name: Union[str, None] = None,
|
290
300
|
**kwargs,
|
291
301
|
) -> SaveAssetRequestOut:
|
292
|
-
asset_object = _convert_asset_object(asset_object=asset_object, name=name)
|
302
|
+
asset_object = _convert_asset_object(asset_object=asset_object, name=name, **kwargs)
|
293
303
|
return await super().save_asset(
|
294
|
-
file=asset_object, parent_folder_id=parent_folder_id
|
304
|
+
file=asset_object, parent_folder_id=parent_folder_id
|
295
305
|
)
|
296
306
|
|
297
307
|
|
@@ -514,6 +524,7 @@ def _to_pandas_df(
|
|
514
524
|
def _convert_asset_object(
|
515
525
|
asset_object: Union["pd.DataFrame", "pd.Series", core.File],
|
516
526
|
name: Union[str, None] = None,
|
527
|
+
**kwargs
|
517
528
|
) -> core.File:
|
518
529
|
import pandas as pd
|
519
530
|
try:
|
@@ -526,7 +537,7 @@ def _convert_asset_object(
|
|
526
537
|
if isinstance(asset_object, pd.DataFrame):
|
527
538
|
return (
|
528
539
|
name or "Uploaded data frame",
|
529
|
-
asset_object.to_parquet(path=None),
|
540
|
+
asset_object.to_parquet(path=None, **kwargs),
|
530
541
|
"application/vnd.apache.parquet",
|
531
542
|
)
|
532
543
|
if format_display_data:
|
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.125",
|
21
21
|
}
|
22
22
|
headers["X-API-KEY"] = self.api_key
|
23
23
|
return headers
|
@@ -10,10 +10,10 @@ athena/agents/research/client.py,sha256=mo63cUvLw8AC9I29WI4Ym_jOsvRsco1wRqsNp0rt
|
|
10
10
|
athena/agents/sql/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
11
11
|
athena/agents/sql/client.py,sha256=1r2aT4JLxVCeL0FzEBeHmttwerdRmJOxVHim2_CHkvg,4767
|
12
12
|
athena/base_client.py,sha256=-kVdOlIibBz48lxWratdQAzT7fTvZsORvOMF3KoPDPw,5647
|
13
|
-
athena/client.py,sha256=
|
13
|
+
athena/client.py,sha256=5n5pOXAcMljMR2-MnI8fGvHY-TgqLzWmihDur0XrpM8,19503
|
14
14
|
athena/core/__init__.py,sha256=UFXpYzcGxWQUucU1TkjOQ9mGWN3A5JohluOIWVYKU4I,973
|
15
15
|
athena/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
|
16
|
-
athena/core/client_wrapper.py,sha256=
|
16
|
+
athena/core/client_wrapper.py,sha256=nziI1y3xFUHOGDnMU6SL8HlIHNCXDaJtpfCCe4o2tJ4,1806
|
17
17
|
athena/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
|
18
18
|
athena/core/file.py,sha256=sy1RUGZ3aJYuw998bZytxxo6QdgKmlnlgBaMvwEKCGg,1480
|
19
19
|
athena/core/http_client.py,sha256=Z4NuAsJD-51yqmoME17O5sxwx5orSp1wsnd6bPyKcgA,17768
|
@@ -81,6 +81,6 @@ athena/types/text_content.py,sha256=uG2poNIkM6o7tFgf-eKzZk9kZHYImY3JdI-NkYiqWgU,
|
|
81
81
|
athena/types/tool.py,sha256=6H2BFZiBgQOtYUAwSYBeGZKhwev17IEwnIjgmno6dZw,436
|
82
82
|
athena/types/type.py,sha256=JaUIt4ogmO4XxCQ9c56fqKN5qANKkrnpuZGmdqOCIow,581
|
83
83
|
athena/version.py,sha256=8aYAOJtVLaJLpRp6mTiEIhnl8gXA7yE0aDtZ-3mKQ4k,87
|
84
|
-
athena_intelligence-0.1.
|
85
|
-
athena_intelligence-0.1.
|
86
|
-
athena_intelligence-0.1.
|
84
|
+
athena_intelligence-0.1.125.dist-info/METADATA,sha256=YZtDUfJx8ZHA6L-it-tdB-28N1MR0T3LELbTW0bWDBs,5274
|
85
|
+
athena_intelligence-0.1.125.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
86
|
+
athena_intelligence-0.1.125.dist-info/RECORD,,
|
File without changes
|