athena-intelligence 0.1.83__tar.gz → 0.1.84__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.
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/PKG-INFO +12 -2
- athena_intelligence-0.1.84/pyproject.toml +60 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/chain/client.py +17 -8
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/client.py +91 -4
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/core/__init__.py +4 -1
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/core/client_wrapper.py +1 -1
- athena_intelligence-0.1.84/src/athena/core/pydantic_utilities.py +28 -0
- athena_intelligence-0.1.84/src/athena/core/query_encoder.py +33 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/dataset/client.py +27 -22
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/message/client.py +17 -8
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/query/client.py +9 -4
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/report/client.py +9 -4
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/search/client.py +9 -4
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/snippet/client.py +35 -26
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/tools/client.py +107 -74
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/convert_pdf_to_sheet_out.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/data_frame_parsing_error.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/data_frame_request_out.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/data_frame_unknown_format_error.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/dataset.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/document.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/excecute_tool_first_workflow_out.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/file_data_response.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/file_fetch_error.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/filter_model.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/firecrawl_scrape_url_data_reponse_dto.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/firecrawl_scrape_url_metadata.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/get_datasets_response.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/get_snippet_out.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/get_snippets_response.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/http_validation_error.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/langchain_documents_request_out.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/map_reduce_chain_out.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/message_out.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/message_out_dto.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/publish_formats.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/query_model.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/report.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/researcher_out.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/semantic_query_out.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/snippet.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/sql_results.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/structured_parse_result.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/time_dimension_model.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/upload_documents_out.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/url_result.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/validation_error.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/workflow_status_out.py +7 -3
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/upload/client.py +9 -4
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/workflow/client.py +9 -4
- athena_intelligence-0.1.83/pyproject.toml +0 -36
- athena_intelligence-0.1.83/src/athena/core/pydantic_utilities.py +0 -12
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/README.md +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/base_client.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/chain/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/core/api_error.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/core/datetime_utils.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/core/file.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/core/http_client.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/core/jsonable_encoder.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/core/remove_none_from_dict.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/core/request_options.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/dataset/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/environment.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/errors/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/errors/internal_server_error.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/errors/not_found_error.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/errors/unprocessable_entity_error.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/errors/unsupported_media_type_error.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/message/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/polling_message_client.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/py.typed +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/query/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/report/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/search/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/snippet/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/tools/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/tools/types/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/tools/types/tools_data_frame_request_columns_item.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/data_frame_request_out_columns_item.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/data_frame_request_out_data_item_item.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/data_frame_request_out_index_item.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/filter_operator.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/llm_model.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/model.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/status_enum.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/tools.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/types/validation_error_loc_item.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/upload/__init__.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/version.py +0 -0
- {athena_intelligence-0.1.83 → athena_intelligence-0.1.84}/src/athena/workflow/__init__.py +0 -0
@@ -1,13 +1,23 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: athena-intelligence
|
3
|
-
Version: 0.1.
|
4
|
-
Summary:
|
3
|
+
Version: 0.1.84
|
4
|
+
Summary: Athena Intelligence Python Library
|
5
5
|
Requires-Python: >=3.8,<4.0
|
6
|
+
Classifier: Intended Audience :: Developers
|
7
|
+
Classifier: Operating System :: MacOS
|
8
|
+
Classifier: Operating System :: Microsoft :: Windows
|
9
|
+
Classifier: Operating System :: OS Independent
|
10
|
+
Classifier: Operating System :: POSIX
|
11
|
+
Classifier: Operating System :: POSIX :: Linux
|
12
|
+
Classifier: Programming Language :: Python
|
6
13
|
Classifier: Programming Language :: Python :: 3
|
7
14
|
Classifier: Programming Language :: Python :: 3.8
|
8
15
|
Classifier: Programming Language :: Python :: 3.9
|
9
16
|
Classifier: Programming Language :: Python :: 3.10
|
10
17
|
Classifier: Programming Language :: Python :: 3.11
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
20
|
+
Classifier: Typing :: Typed
|
11
21
|
Requires-Dist: httpx (>=0.21.2)
|
12
22
|
Requires-Dist: pydantic (>=1.9.2)
|
13
23
|
Requires-Dist: python-magic (==0.4.27)
|
@@ -0,0 +1,60 @@
|
|
1
|
+
[tool.poetry]
|
2
|
+
name = "athena-intelligence"
|
3
|
+
version = "0.1.84"
|
4
|
+
description = "Athena Intelligence Python Library"
|
5
|
+
readme = "README.md"
|
6
|
+
authors = []
|
7
|
+
keywords = []
|
8
|
+
|
9
|
+
classifiers = [
|
10
|
+
"Intended Audience :: Developers",
|
11
|
+
"Programming Language :: Python",
|
12
|
+
"Programming Language :: Python :: 3",
|
13
|
+
"Programming Language :: Python :: 3.8",
|
14
|
+
"Programming Language :: Python :: 3.9",
|
15
|
+
"Programming Language :: Python :: 3.10",
|
16
|
+
"Programming Language :: Python :: 3.11",
|
17
|
+
"Programming Language :: Python :: 3.12",
|
18
|
+
"Operating System :: OS Independent",
|
19
|
+
"Operating System :: POSIX",
|
20
|
+
"Operating System :: MacOS",
|
21
|
+
"Operating System :: POSIX :: Linux",
|
22
|
+
"Operating System :: Microsoft :: Windows",
|
23
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
24
|
+
"Typing :: Typed"
|
25
|
+
]
|
26
|
+
packages = [
|
27
|
+
{ include = "athena", from = "src"}
|
28
|
+
]
|
29
|
+
|
30
|
+
[project.urls]
|
31
|
+
Documentation = 'https://docs.athenaintelligence.ai/'
|
32
|
+
Homepage = 'https://www.athenaintelligence.ai/'
|
33
|
+
Repository = 'https://github.com/Athena-Intel/athena-python'
|
34
|
+
|
35
|
+
[tool.poetry.dependencies]
|
36
|
+
python = "^3.8"
|
37
|
+
httpx = ">=0.21.2"
|
38
|
+
pydantic = ">= 1.9.2"
|
39
|
+
python-magic = "0.4.27"
|
40
|
+
typing_extensions = ">= 4.0.0"
|
41
|
+
|
42
|
+
[tool.poetry.dev-dependencies]
|
43
|
+
mypy = "1.9.0"
|
44
|
+
pytest = "^7.4.0"
|
45
|
+
pytest-asyncio = "^0.23.5"
|
46
|
+
python-dateutil = "^2.9.0"
|
47
|
+
pandas = ">= 1.5.3"
|
48
|
+
pandas-stubs = ">= 1.5.3"
|
49
|
+
|
50
|
+
[tool.pytest.ini_options]
|
51
|
+
testpaths = [ "tests" ]
|
52
|
+
asyncio_mode = "auto"
|
53
|
+
|
54
|
+
[tool.mypy]
|
55
|
+
plugins = ["pydantic.mypy"]
|
56
|
+
|
57
|
+
|
58
|
+
[build-system]
|
59
|
+
requires = ["poetry-core"]
|
60
|
+
build-backend = "poetry.core.masonry.api"
|
@@ -8,6 +8,7 @@ from ..core.api_error import ApiError
|
|
8
8
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
9
9
|
from ..core.jsonable_encoder import jsonable_encoder
|
10
10
|
from ..core.pydantic_utilities import pydantic_v1
|
11
|
+
from ..core.query_encoder import encode_query
|
11
12
|
from ..core.remove_none_from_dict import remove_none_from_dict
|
12
13
|
from ..core.request_options import RequestOptions
|
13
14
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
@@ -69,8 +70,10 @@ class ChainClient:
|
|
69
70
|
_response = self._client_wrapper.httpx_client.request(
|
70
71
|
method="POST",
|
71
72
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/structured-parse"),
|
72
|
-
params=
|
73
|
-
|
73
|
+
params=encode_query(
|
74
|
+
jsonable_encoder(
|
75
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
76
|
+
)
|
74
77
|
),
|
75
78
|
json=jsonable_encoder({"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model})
|
76
79
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -159,8 +162,10 @@ class ChainClient:
|
|
159
162
|
_response = self._client_wrapper.httpx_client.request(
|
160
163
|
method="POST",
|
161
164
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/map-reduce"),
|
162
|
-
params=
|
163
|
-
|
165
|
+
params=encode_query(
|
166
|
+
jsonable_encoder(
|
167
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
168
|
+
)
|
164
169
|
),
|
165
170
|
json=jsonable_encoder(
|
166
171
|
{
|
@@ -259,8 +264,10 @@ class AsyncChainClient:
|
|
259
264
|
_response = await self._client_wrapper.httpx_client.request(
|
260
265
|
method="POST",
|
261
266
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/structured-parse"),
|
262
|
-
params=
|
263
|
-
|
267
|
+
params=encode_query(
|
268
|
+
jsonable_encoder(
|
269
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
270
|
+
)
|
264
271
|
),
|
265
272
|
json=jsonable_encoder({"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model})
|
266
273
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -349,8 +356,10 @@ class AsyncChainClient:
|
|
349
356
|
_response = await self._client_wrapper.httpx_client.request(
|
350
357
|
method="POST",
|
351
358
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/map-reduce"),
|
352
|
-
params=
|
353
|
-
|
359
|
+
params=encode_query(
|
360
|
+
jsonable_encoder(
|
361
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
362
|
+
)
|
354
363
|
),
|
355
364
|
json=jsonable_encoder(
|
356
365
|
{
|
@@ -1,13 +1,65 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import io
|
3
2
|
import typing
|
3
|
+
import warnings
|
4
4
|
|
5
5
|
import httpx
|
6
|
+
from typing_extensions import TypeVar, ParamSpec
|
6
7
|
|
7
8
|
from .base_client import BaseAthena, AsyncBaseAthena
|
8
9
|
from .environment import AthenaEnvironment
|
9
|
-
from .polling_message_client import
|
10
|
-
|
10
|
+
from .polling_message_client import MessagePollingClient, AsyncMessagePollingClient
|
11
|
+
from .tools.client import AsyncToolsClient, ToolsClient
|
12
|
+
from .types.data_frame_request_out import DataFrameRequestOut
|
13
|
+
|
14
|
+
if typing.TYPE_CHECKING:
|
15
|
+
import pandas as pd
|
16
|
+
|
17
|
+
|
18
|
+
P = ParamSpec("P")
|
19
|
+
T = TypeVar("T")
|
20
|
+
U = TypeVar('U')
|
21
|
+
|
22
|
+
|
23
|
+
def _inherit_signature(f: typing.Callable[P, T]) -> typing.Callable[..., typing.Callable[P, U]]:
|
24
|
+
return lambda x: x
|
25
|
+
|
26
|
+
|
27
|
+
class WrappedToolsClient(ToolsClient):
|
28
|
+
|
29
|
+
def get_file(self, document_id: str) -> io.BytesIO:
|
30
|
+
file_bytes = b''.join(self.raw_data(document_id=document_id))
|
31
|
+
bytes_io = io.BytesIO(file_bytes)
|
32
|
+
return bytes_io
|
33
|
+
|
34
|
+
@_inherit_signature(ToolsClient.data_frame)
|
35
|
+
def data_frame(self, *, document_id: str, **kwargs) -> 'pd.DataFrame':
|
36
|
+
_check_pandas_installed()
|
37
|
+
model = super().data_frame(document_id=document_id, **kwargs)
|
38
|
+
return _read_json_frame(model)
|
39
|
+
|
40
|
+
def read_data_frame(self, document_id: str, *args, **kwargs) -> 'pd.DataFrame':
|
41
|
+
_check_pandas_installed()
|
42
|
+
file_bytes = self.get_file(document_id)
|
43
|
+
return _to_pandas_df(file_bytes, *args, **kwargs)
|
44
|
+
|
45
|
+
|
46
|
+
class WrappedAsyncToolsClient(AsyncToolsClient):
|
47
|
+
|
48
|
+
async def get_file(self, document_id: str) -> io.BytesIO:
|
49
|
+
file_bytes = b''.join([gen async for gen in self.raw_data(document_id=document_id)])
|
50
|
+
bytes_io = io.BytesIO(file_bytes)
|
51
|
+
return bytes_io
|
52
|
+
|
53
|
+
@_inherit_signature(ToolsClient.data_frame)
|
54
|
+
async def data_frame(self, *, document_id: str, **kwargs) -> 'pd.DataFrame':
|
55
|
+
_check_pandas_installed()
|
56
|
+
model = await super().data_frame(document_id=document_id, **kwargs)
|
57
|
+
return _read_json_frame(model)
|
58
|
+
|
59
|
+
async def read_data_frame(self, document_id: str, *args, **kwargs) -> 'pd.DataFrame':
|
60
|
+
_check_pandas_installed()
|
61
|
+
file_bytes = await self.get_file(document_id)
|
62
|
+
return _to_pandas_df(file_bytes, *args, **kwargs)
|
11
63
|
|
12
64
|
|
13
65
|
class Athena(BaseAthena):
|
@@ -52,6 +104,7 @@ class Athena(BaseAthena):
|
|
52
104
|
)
|
53
105
|
self.message = MessagePollingClient(
|
54
106
|
client_wrapper=self._client_wrapper)
|
107
|
+
self.tools = WrappedToolsClient(client_wrapper=self._client_wrapper)
|
55
108
|
|
56
109
|
|
57
110
|
class AsyncAthena(AsyncBaseAthena):
|
@@ -96,4 +149,38 @@ class AsyncAthena(AsyncBaseAthena):
|
|
96
149
|
)
|
97
150
|
self.message = AsyncMessagePollingClient(
|
98
151
|
client_wrapper=self._client_wrapper)
|
152
|
+
self.tools = WrappedAsyncToolsClient(client_wrapper=self._client_wrapper)
|
153
|
+
|
154
|
+
|
155
|
+
def _read_json_frame(model: DataFrameRequestOut) -> 'pd.DataFrame':
|
156
|
+
import pandas as pd
|
157
|
+
|
158
|
+
string_io = io.StringIO(model.json())
|
159
|
+
|
160
|
+
with warnings.catch_warnings():
|
161
|
+
# Filter warnings due to https://github.com/pandas-dev/pandas/issues/59511
|
162
|
+
warnings.simplefilter(action='ignore', category=FutureWarning)
|
163
|
+
return pd.read_json(string_io, orient='split')
|
164
|
+
|
165
|
+
|
166
|
+
def _check_pandas_installed():
|
167
|
+
import pandas
|
168
|
+
assert pandas
|
169
|
+
|
170
|
+
|
171
|
+
def _to_pandas_df(bytes_io: io.BytesIO, *args, **kwargs):
|
172
|
+
import pandas as pd
|
173
|
+
import magic
|
174
|
+
|
175
|
+
# ideally this would be read from response header, but fern SDK for Python hides this info from us
|
176
|
+
media_type = magic.from_buffer(bytes_io.read(2048), mime=True)
|
177
|
+
bytes_io.seek(0)
|
99
178
|
|
179
|
+
if media_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
|
180
|
+
return pd.read_excel(bytes_io, *args, engine='openpyxl', **kwargs)
|
181
|
+
elif media_type == 'application/vnd.ms-excel':
|
182
|
+
return pd.read_excel(bytes_io, *args, **kwargs)
|
183
|
+
elif media_type == 'text/csv':
|
184
|
+
return pd.read_csv(bytes_io, *args, **kwargs)
|
185
|
+
else:
|
186
|
+
raise Exception("Unknown media type")
|
@@ -6,7 +6,8 @@ from .datetime_utils import serialize_datetime
|
|
6
6
|
from .file import File, convert_file_dict_to_httpx_tuples
|
7
7
|
from .http_client import AsyncHttpClient, HttpClient
|
8
8
|
from .jsonable_encoder import jsonable_encoder
|
9
|
-
from .pydantic_utilities import pydantic_v1
|
9
|
+
from .pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
10
|
+
from .query_encoder import encode_query
|
10
11
|
from .remove_none_from_dict import remove_none_from_dict
|
11
12
|
from .request_options import RequestOptions
|
12
13
|
|
@@ -20,6 +21,8 @@ __all__ = [
|
|
20
21
|
"RequestOptions",
|
21
22
|
"SyncClientWrapper",
|
22
23
|
"convert_file_dict_to_httpx_tuples",
|
24
|
+
"deep_union_pydantic_dicts",
|
25
|
+
"encode_query",
|
23
26
|
"jsonable_encoder",
|
24
27
|
"pydantic_v1",
|
25
28
|
"remove_none_from_dict",
|
@@ -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.84",
|
21
21
|
}
|
22
22
|
headers["X-API-KEY"] = self.api_key
|
23
23
|
return headers
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import typing
|
4
|
+
|
5
|
+
import pydantic
|
6
|
+
|
7
|
+
IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.")
|
8
|
+
|
9
|
+
if IS_PYDANTIC_V2:
|
10
|
+
import pydantic.v1 as pydantic_v1 # type: ignore # nopycln: import
|
11
|
+
else:
|
12
|
+
import pydantic as pydantic_v1 # type: ignore # nopycln: import
|
13
|
+
|
14
|
+
|
15
|
+
def deep_union_pydantic_dicts(
|
16
|
+
source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any]
|
17
|
+
) -> typing.Dict[str, typing.Any]:
|
18
|
+
for key, value in source.items():
|
19
|
+
if isinstance(value, dict):
|
20
|
+
node = destination.setdefault(key, {})
|
21
|
+
deep_union_pydantic_dicts(value, node)
|
22
|
+
else:
|
23
|
+
destination[key] = value
|
24
|
+
|
25
|
+
return destination
|
26
|
+
|
27
|
+
|
28
|
+
__all__ = ["pydantic_v1"]
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
from collections import ChainMap
|
4
|
+
from typing import Any, Dict, Optional
|
5
|
+
|
6
|
+
from .pydantic_utilities import pydantic_v1
|
7
|
+
|
8
|
+
|
9
|
+
# Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict
|
10
|
+
def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]:
|
11
|
+
result = {}
|
12
|
+
for k, v in dict_flat.items():
|
13
|
+
key = f"{key_prefix}[{k}]" if key_prefix is not None else k
|
14
|
+
if isinstance(v, dict):
|
15
|
+
result.update(traverse_query_dict(v, key))
|
16
|
+
else:
|
17
|
+
result[key] = v
|
18
|
+
return result
|
19
|
+
|
20
|
+
|
21
|
+
def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]:
|
22
|
+
if isinstance(query_value, pydantic_v1.BaseModel) or isinstance(query_value, dict):
|
23
|
+
if isinstance(query_value, pydantic_v1.BaseModel):
|
24
|
+
obj_dict = query_value.dict(by_alias=True)
|
25
|
+
else:
|
26
|
+
obj_dict = query_value
|
27
|
+
return traverse_query_dict(obj_dict, query_key)
|
28
|
+
|
29
|
+
return {query_key: query_value}
|
30
|
+
|
31
|
+
|
32
|
+
def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]:
|
33
|
+
return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None
|
@@ -8,6 +8,7 @@ from ..core.api_error import ApiError
|
|
8
8
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
9
9
|
from ..core.jsonable_encoder import jsonable_encoder
|
10
10
|
from ..core.pydantic_utilities import pydantic_v1
|
11
|
+
from ..core.query_encoder import encode_query
|
11
12
|
from ..core.remove_none_from_dict import remove_none_from_dict
|
12
13
|
from ..core.request_options import RequestOptions
|
13
14
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
@@ -55,17 +56,19 @@ class DatasetClient:
|
|
55
56
|
_response = self._client_wrapper.httpx_client.request(
|
56
57
|
method="GET",
|
57
58
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/datasets"),
|
58
|
-
params=
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
59
|
+
params=encode_query(
|
60
|
+
jsonable_encoder(
|
61
|
+
remove_none_from_dict(
|
62
|
+
{
|
63
|
+
"page": page,
|
64
|
+
"page_size": page_size,
|
65
|
+
**(
|
66
|
+
request_options.get("additional_query_parameters", {})
|
67
|
+
if request_options is not None
|
68
|
+
else {}
|
69
|
+
),
|
70
|
+
}
|
71
|
+
)
|
69
72
|
)
|
70
73
|
),
|
71
74
|
headers=jsonable_encoder(
|
@@ -135,17 +138,19 @@ class AsyncDatasetClient:
|
|
135
138
|
_response = await self._client_wrapper.httpx_client.request(
|
136
139
|
method="GET",
|
137
140
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/datasets"),
|
138
|
-
params=
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
141
|
+
params=encode_query(
|
142
|
+
jsonable_encoder(
|
143
|
+
remove_none_from_dict(
|
144
|
+
{
|
145
|
+
"page": page,
|
146
|
+
"page_size": page_size,
|
147
|
+
**(
|
148
|
+
request_options.get("additional_query_parameters", {})
|
149
|
+
if request_options is not None
|
150
|
+
else {}
|
151
|
+
),
|
152
|
+
}
|
153
|
+
)
|
149
154
|
)
|
150
155
|
),
|
151
156
|
headers=jsonable_encoder(
|
@@ -8,6 +8,7 @@ from ..core.api_error import ApiError
|
|
8
8
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
9
9
|
from ..core.jsonable_encoder import jsonable_encoder
|
10
10
|
from ..core.pydantic_utilities import pydantic_v1
|
11
|
+
from ..core.query_encoder import encode_query
|
11
12
|
from ..core.remove_none_from_dict import remove_none_from_dict
|
12
13
|
from ..core.request_options import RequestOptions
|
13
14
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
@@ -82,8 +83,10 @@ class MessageClient:
|
|
82
83
|
_response = self._client_wrapper.httpx_client.request(
|
83
84
|
method="POST",
|
84
85
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/message"),
|
85
|
-
params=
|
86
|
-
|
86
|
+
params=encode_query(
|
87
|
+
jsonable_encoder(
|
88
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
89
|
+
)
|
87
90
|
),
|
88
91
|
json=jsonable_encoder(_request)
|
89
92
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -147,8 +150,10 @@ class MessageClient:
|
|
147
150
|
url=urllib.parse.urljoin(
|
148
151
|
f"{self._client_wrapper.get_base_url()}/", f"api/v0/message/{jsonable_encoder(id)}"
|
149
152
|
),
|
150
|
-
params=
|
151
|
-
|
153
|
+
params=encode_query(
|
154
|
+
jsonable_encoder(
|
155
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
156
|
+
)
|
152
157
|
),
|
153
158
|
headers=jsonable_encoder(
|
154
159
|
remove_none_from_dict(
|
@@ -238,8 +243,10 @@ class AsyncMessageClient:
|
|
238
243
|
_response = await self._client_wrapper.httpx_client.request(
|
239
244
|
method="POST",
|
240
245
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/message"),
|
241
|
-
params=
|
242
|
-
|
246
|
+
params=encode_query(
|
247
|
+
jsonable_encoder(
|
248
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
249
|
+
)
|
243
250
|
),
|
244
251
|
json=jsonable_encoder(_request)
|
245
252
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -303,8 +310,10 @@ class AsyncMessageClient:
|
|
303
310
|
url=urllib.parse.urljoin(
|
304
311
|
f"{self._client_wrapper.get_base_url()}/", f"api/v0/message/{jsonable_encoder(id)}"
|
305
312
|
),
|
306
|
-
params=
|
307
|
-
|
313
|
+
params=encode_query(
|
314
|
+
jsonable_encoder(
|
315
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
316
|
+
)
|
308
317
|
),
|
309
318
|
headers=jsonable_encoder(
|
310
319
|
remove_none_from_dict(
|
@@ -8,6 +8,7 @@ from ..core.api_error import ApiError
|
|
8
8
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
9
9
|
from ..core.jsonable_encoder import jsonable_encoder
|
10
10
|
from ..core.pydantic_utilities import pydantic_v1
|
11
|
+
from ..core.query_encoder import encode_query
|
11
12
|
from ..core.remove_none_from_dict import remove_none_from_dict
|
12
13
|
from ..core.request_options import RequestOptions
|
13
14
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
@@ -55,8 +56,10 @@ class QueryClient:
|
|
55
56
|
_response = self._client_wrapper.httpx_client.request(
|
56
57
|
method="POST",
|
57
58
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/execute-sql"),
|
58
|
-
params=
|
59
|
-
|
59
|
+
params=encode_query(
|
60
|
+
jsonable_encoder(
|
61
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
62
|
+
)
|
60
63
|
),
|
61
64
|
json=jsonable_encoder({"sql_command": sql_command, "database_id": database_id})
|
62
65
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -128,8 +131,10 @@ class AsyncQueryClient:
|
|
128
131
|
_response = await self._client_wrapper.httpx_client.request(
|
129
132
|
method="POST",
|
130
133
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/execute-sql"),
|
131
|
-
params=
|
132
|
-
|
134
|
+
params=encode_query(
|
135
|
+
jsonable_encoder(
|
136
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
137
|
+
)
|
133
138
|
),
|
134
139
|
json=jsonable_encoder({"sql_command": sql_command, "database_id": database_id})
|
135
140
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -8,6 +8,7 @@ from ..core.api_error import ApiError
|
|
8
8
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
9
9
|
from ..core.jsonable_encoder import jsonable_encoder
|
10
10
|
from ..core.pydantic_utilities import pydantic_v1
|
11
|
+
from ..core.query_encoder import encode_query
|
11
12
|
from ..core.remove_none_from_dict import remove_none_from_dict
|
12
13
|
from ..core.request_options import RequestOptions
|
13
14
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
@@ -61,8 +62,10 @@ class ReportClient:
|
|
61
62
|
_response = self._client_wrapper.httpx_client.request(
|
62
63
|
method="POST",
|
63
64
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/report"),
|
64
|
-
params=
|
65
|
-
|
65
|
+
params=encode_query(
|
66
|
+
jsonable_encoder(
|
67
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
68
|
+
)
|
66
69
|
),
|
67
70
|
json=jsonable_encoder(_request)
|
68
71
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -140,8 +143,10 @@ class AsyncReportClient:
|
|
140
143
|
_response = await self._client_wrapper.httpx_client.request(
|
141
144
|
method="POST",
|
142
145
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/report"),
|
143
|
-
params=
|
144
|
-
|
146
|
+
params=encode_query(
|
147
|
+
jsonable_encoder(
|
148
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
149
|
+
)
|
145
150
|
),
|
146
151
|
json=jsonable_encoder(_request)
|
147
152
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -8,6 +8,7 @@ from ..core.api_error import ApiError
|
|
8
8
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
9
9
|
from ..core.jsonable_encoder import jsonable_encoder
|
10
10
|
from ..core.pydantic_utilities import pydantic_v1
|
11
|
+
from ..core.query_encoder import encode_query
|
11
12
|
from ..core.remove_none_from_dict import remove_none_from_dict
|
12
13
|
from ..core.request_options import RequestOptions
|
13
14
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
@@ -79,8 +80,10 @@ class SearchClient:
|
|
79
80
|
_response = self._client_wrapper.httpx_client.request(
|
80
81
|
method="POST",
|
81
82
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/search/get-urls"),
|
82
|
-
params=
|
83
|
-
|
83
|
+
params=encode_query(
|
84
|
+
jsonable_encoder(
|
85
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
86
|
+
)
|
84
87
|
),
|
85
88
|
json=jsonable_encoder(_request)
|
86
89
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -176,8 +179,10 @@ class AsyncSearchClient:
|
|
176
179
|
_response = await self._client_wrapper.httpx_client.request(
|
177
180
|
method="POST",
|
178
181
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/search/get-urls"),
|
179
|
-
params=
|
180
|
-
|
182
|
+
params=encode_query(
|
183
|
+
jsonable_encoder(
|
184
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
185
|
+
)
|
181
186
|
),
|
182
187
|
json=jsonable_encoder(_request)
|
183
188
|
if request_options is None or request_options.get("additional_body_parameters") is None
|