athena-intelligence 0.1.82__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.82 → athena_intelligence-0.1.84}/PKG-INFO +12 -2
- athena_intelligence-0.1.84/pyproject.toml +60 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/base_client.py +40 -18
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/chain/client.py +85 -36
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/client.py +91 -4
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/core/__init__.py +4 -1
- {athena_intelligence-0.1.82 → 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.82 → athena_intelligence-0.1.84}/src/athena/dataset/client.py +59 -32
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/message/client.py +77 -32
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/query/client.py +37 -14
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/report/client.py +37 -14
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/search/client.py +45 -22
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/snippet/client.py +93 -44
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/tools/client.py +357 -174
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/convert_pdf_to_sheet_out.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/data_frame_parsing_error.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/data_frame_request_out.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/data_frame_unknown_format_error.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/dataset.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/document.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/excecute_tool_first_workflow_out.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/file_data_response.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/file_fetch_error.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/filter_model.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/firecrawl_scrape_url_data_reponse_dto.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/firecrawl_scrape_url_metadata.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/get_datasets_response.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/get_snippet_out.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/get_snippets_response.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/http_validation_error.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/langchain_documents_request_out.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/map_reduce_chain_out.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/message_out.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/message_out_dto.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/publish_formats.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/query_model.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/report.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/researcher_out.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/semantic_query_out.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/snippet.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/sql_results.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/structured_parse_result.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/time_dimension_model.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/upload_documents_out.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/url_result.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/validation_error.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/workflow_status_out.py +7 -3
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/upload/client.py +37 -12
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/workflow/client.py +35 -12
- athena_intelligence-0.1.82/pyproject.toml +0 -34
- athena_intelligence-0.1.82/src/athena/core/pydantic_utilities.py +0 -12
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/README.md +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/chain/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/core/api_error.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/core/datetime_utils.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/core/file.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/core/http_client.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/core/jsonable_encoder.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/core/remove_none_from_dict.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/core/request_options.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/dataset/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/environment.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/errors/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/errors/internal_server_error.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/errors/not_found_error.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/errors/unprocessable_entity_error.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/errors/unsupported_media_type_error.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/message/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/polling_message_client.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/py.typed +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/query/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/report/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/search/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/snippet/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/tools/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/tools/types/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/tools/types/tools_data_frame_request_columns_item.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/data_frame_request_out_columns_item.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/data_frame_request_out_data_item_item.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/data_frame_request_out_index_item.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/filter_operator.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/llm_model.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/model.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/status_enum.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/tools.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/types/validation_error_loc_item.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/upload/__init__.py +0 -0
- {athena_intelligence-0.1.82 → athena_intelligence-0.1.84}/src/athena/version.py +0 -0
- {athena_intelligence-0.1.82 → 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"
|
@@ -22,21 +22,32 @@ class BaseAthena:
|
|
22
22
|
"""
|
23
23
|
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.
|
24
24
|
|
25
|
-
Parameters
|
26
|
-
|
25
|
+
Parameters
|
26
|
+
----------
|
27
|
+
base_url : typing.Optional[str]
|
28
|
+
The base url to use for requests from the client.
|
27
29
|
|
28
|
-
|
30
|
+
environment : AthenaEnvironment
|
31
|
+
The environment to use for requests from the client. from .environment import AthenaEnvironment
|
29
32
|
|
30
|
-
Defaults to AthenaEnvironment.DEFAULT
|
31
33
|
|
32
|
-
- api_key: str.
|
33
34
|
|
34
|
-
|
35
|
+
Defaults to AthenaEnvironment.DEFAULT
|
35
36
|
|
36
|
-
- follow_redirects: typing.Optional[bool]. Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
|
39
|
+
api_key : str
|
40
|
+
timeout : typing.Optional[float]
|
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 a default is not set.
|
42
|
+
|
43
|
+
follow_redirects : typing.Optional[bool]
|
44
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
45
|
+
|
46
|
+
httpx_client : typing.Optional[httpx.Client]
|
47
|
+
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.
|
48
|
+
|
49
|
+
Examples
|
50
|
+
--------
|
40
51
|
from athena.client import Athena
|
41
52
|
|
42
53
|
client = Athena(
|
@@ -81,21 +92,32 @@ class AsyncBaseAthena:
|
|
81
92
|
"""
|
82
93
|
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.
|
83
94
|
|
84
|
-
Parameters
|
85
|
-
|
95
|
+
Parameters
|
96
|
+
----------
|
97
|
+
base_url : typing.Optional[str]
|
98
|
+
The base url to use for requests from the client.
|
99
|
+
|
100
|
+
environment : AthenaEnvironment
|
101
|
+
The environment to use for requests from the client. from .environment import AthenaEnvironment
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
Defaults to AthenaEnvironment.DEFAULT
|
86
106
|
|
87
|
-
- environment: AthenaEnvironment. The environment to use for requests from the client. from .environment import AthenaEnvironment
|
88
107
|
|
89
|
-
Defaults to AthenaEnvironment.DEFAULT
|
90
108
|
|
91
|
-
|
109
|
+
api_key : str
|
110
|
+
timeout : typing.Optional[float]
|
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 a default is not set.
|
92
112
|
|
93
|
-
|
113
|
+
follow_redirects : typing.Optional[bool]
|
114
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
94
115
|
|
95
|
-
|
116
|
+
httpx_client : typing.Optional[httpx.AsyncClient]
|
117
|
+
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.
|
96
118
|
|
97
|
-
|
98
|
-
|
119
|
+
Examples
|
120
|
+
--------
|
99
121
|
from athena.client import AsyncAthena
|
100
122
|
|
101
123
|
client = AsyncAthena(
|
@@ -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
|
@@ -34,15 +35,26 @@ class ChainClient:
|
|
34
35
|
request_options: typing.Optional[RequestOptions] = None,
|
35
36
|
) -> StructuredParseResult:
|
36
37
|
"""
|
37
|
-
Parameters
|
38
|
-
|
38
|
+
Parameters
|
39
|
+
----------
|
40
|
+
text_input : str
|
41
|
+
The text input to be parsed.
|
39
42
|
|
40
|
-
|
43
|
+
custom_type_dict : typing.Dict[str, typing.Any]
|
44
|
+
A dictionary of field names and their default values.
|
41
45
|
|
42
|
-
|
46
|
+
model : LlmModel
|
43
47
|
|
44
|
-
|
45
|
-
|
48
|
+
request_options : typing.Optional[RequestOptions]
|
49
|
+
Request-specific configuration.
|
50
|
+
|
51
|
+
Returns
|
52
|
+
-------
|
53
|
+
StructuredParseResult
|
54
|
+
Successful Response
|
55
|
+
|
56
|
+
Examples
|
57
|
+
--------
|
46
58
|
from athena import LlmModel
|
47
59
|
from athena.client import Athena
|
48
60
|
|
@@ -58,8 +70,10 @@ class ChainClient:
|
|
58
70
|
_response = self._client_wrapper.httpx_client.request(
|
59
71
|
method="POST",
|
60
72
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/structured-parse"),
|
61
|
-
params=
|
62
|
-
|
73
|
+
params=encode_query(
|
74
|
+
jsonable_encoder(
|
75
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
76
|
+
)
|
63
77
|
),
|
64
78
|
json=jsonable_encoder({"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model})
|
65
79
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -104,19 +118,28 @@ class ChainClient:
|
|
104
118
|
request_options: typing.Optional[RequestOptions] = None,
|
105
119
|
) -> MapReduceChainOut:
|
106
120
|
"""
|
107
|
-
Parameters
|
108
|
-
|
121
|
+
Parameters
|
122
|
+
----------
|
123
|
+
documents : typing.Sequence[Document]
|
109
124
|
|
110
|
-
|
125
|
+
model : LlmModel
|
111
126
|
|
112
|
-
|
127
|
+
operator_prompt : str
|
113
128
|
|
114
|
-
|
129
|
+
reducer_prompt : str
|
115
130
|
|
116
|
-
|
131
|
+
input : str
|
117
132
|
|
118
|
-
|
119
|
-
|
133
|
+
request_options : typing.Optional[RequestOptions]
|
134
|
+
Request-specific configuration.
|
135
|
+
|
136
|
+
Returns
|
137
|
+
-------
|
138
|
+
MapReduceChainOut
|
139
|
+
Successful Response
|
140
|
+
|
141
|
+
Examples
|
142
|
+
--------
|
120
143
|
from athena import Document, LlmModel
|
121
144
|
from athena.client import Athena
|
122
145
|
|
@@ -139,8 +162,10 @@ class ChainClient:
|
|
139
162
|
_response = self._client_wrapper.httpx_client.request(
|
140
163
|
method="POST",
|
141
164
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/map-reduce"),
|
142
|
-
params=
|
143
|
-
|
165
|
+
params=encode_query(
|
166
|
+
jsonable_encoder(
|
167
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
168
|
+
)
|
144
169
|
),
|
145
170
|
json=jsonable_encoder(
|
146
171
|
{
|
@@ -204,15 +229,26 @@ class AsyncChainClient:
|
|
204
229
|
request_options: typing.Optional[RequestOptions] = None,
|
205
230
|
) -> StructuredParseResult:
|
206
231
|
"""
|
207
|
-
Parameters
|
208
|
-
|
232
|
+
Parameters
|
233
|
+
----------
|
234
|
+
text_input : str
|
235
|
+
The text input to be parsed.
|
209
236
|
|
210
|
-
|
237
|
+
custom_type_dict : typing.Dict[str, typing.Any]
|
238
|
+
A dictionary of field names and their default values.
|
211
239
|
|
212
|
-
|
240
|
+
model : LlmModel
|
213
241
|
|
214
|
-
|
215
|
-
|
242
|
+
request_options : typing.Optional[RequestOptions]
|
243
|
+
Request-specific configuration.
|
244
|
+
|
245
|
+
Returns
|
246
|
+
-------
|
247
|
+
StructuredParseResult
|
248
|
+
Successful Response
|
249
|
+
|
250
|
+
Examples
|
251
|
+
--------
|
216
252
|
from athena import LlmModel
|
217
253
|
from athena.client import AsyncAthena
|
218
254
|
|
@@ -228,8 +264,10 @@ class AsyncChainClient:
|
|
228
264
|
_response = await self._client_wrapper.httpx_client.request(
|
229
265
|
method="POST",
|
230
266
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/structured-parse"),
|
231
|
-
params=
|
232
|
-
|
267
|
+
params=encode_query(
|
268
|
+
jsonable_encoder(
|
269
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
270
|
+
)
|
233
271
|
),
|
234
272
|
json=jsonable_encoder({"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model})
|
235
273
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -274,19 +312,28 @@ class AsyncChainClient:
|
|
274
312
|
request_options: typing.Optional[RequestOptions] = None,
|
275
313
|
) -> MapReduceChainOut:
|
276
314
|
"""
|
277
|
-
Parameters
|
278
|
-
|
315
|
+
Parameters
|
316
|
+
----------
|
317
|
+
documents : typing.Sequence[Document]
|
279
318
|
|
280
|
-
|
319
|
+
model : LlmModel
|
281
320
|
|
282
|
-
|
321
|
+
operator_prompt : str
|
283
322
|
|
284
|
-
|
323
|
+
reducer_prompt : str
|
285
324
|
|
286
|
-
|
325
|
+
input : str
|
287
326
|
|
288
|
-
|
289
|
-
|
327
|
+
request_options : typing.Optional[RequestOptions]
|
328
|
+
Request-specific configuration.
|
329
|
+
|
330
|
+
Returns
|
331
|
+
-------
|
332
|
+
MapReduceChainOut
|
333
|
+
Successful Response
|
334
|
+
|
335
|
+
Examples
|
336
|
+
--------
|
290
337
|
from athena import Document, LlmModel
|
291
338
|
from athena.client import AsyncAthena
|
292
339
|
|
@@ -309,8 +356,10 @@ class AsyncChainClient:
|
|
309
356
|
_response = await self._client_wrapper.httpx_client.request(
|
310
357
|
method="POST",
|
311
358
|
url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/map-reduce"),
|
312
|
-
params=
|
313
|
-
|
359
|
+
params=encode_query(
|
360
|
+
jsonable_encoder(
|
361
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
362
|
+
)
|
314
363
|
),
|
315
364
|
json=jsonable_encoder(
|
316
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
|