athena-intelligence 0.1.94__py3-none-any.whl → 0.1.96__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/__init__.py +1 -76
- athena/base_client.py +4 -31
- athena/client.py +4 -9
- athena/core/client_wrapper.py +1 -1
- athena/environment.py +1 -1
- athena/tools/client.py +61 -916
- athena/tools/types/tools_data_frame_request_columns_item.py +1 -1
- athena/types/__init__.py +0 -66
- athena/types/data_frame_parsing_error.py +1 -1
- athena/types/data_frame_request_out.py +7 -3
- athena/types/data_frame_unknown_format_error.py +1 -1
- {athena_intelligence-0.1.94.dist-info → athena_intelligence-0.1.96.dist-info}/METADATA +1 -1
- athena_intelligence-0.1.96.dist-info/RECORD +40 -0
- athena/chain/__init__.py +0 -2
- athena/chain/client.py +0 -302
- athena/dataset/__init__.py +0 -2
- athena/dataset/client.py +0 -124
- athena/message/__init__.py +0 -2
- athena/message/client.py +0 -249
- athena/polling_message_client.py +0 -125
- athena/query/__init__.py +0 -2
- athena/query/client.py +0 -123
- athena/report/__init__.py +0 -2
- athena/report/client.py +0 -125
- athena/search/__init__.py +0 -2
- athena/search/client.py +0 -171
- athena/snippet/__init__.py +0 -2
- athena/snippet/client.py +0 -208
- athena/types/athena_document_v_2_out.py +0 -29
- athena/types/convert_pdf_to_sheet_out.py +0 -30
- athena/types/dataset.py +0 -33
- athena/types/document.py +0 -47
- athena/types/excecute_tool_first_workflow_out.py +0 -29
- athena/types/file_data_response.py +0 -36
- athena/types/filter_model.py +0 -32
- athena/types/filter_operator.py +0 -73
- athena/types/firecrawl_scrape_url_data_reponse_dto.py +0 -32
- athena/types/firecrawl_scrape_url_metadata.py +0 -34
- athena/types/get_datasets_response.py +0 -34
- athena/types/get_snippet_out.py +0 -29
- athena/types/get_snippets_response.py +0 -34
- athena/types/langchain_documents_request_out.py +0 -29
- athena/types/llm_model.py +0 -141
- athena/types/map_reduce_chain_out.py +0 -32
- athena/types/message_out.py +0 -29
- athena/types/message_out_dto.py +0 -35
- athena/types/model.py +0 -93
- athena/types/publish_formats.py +0 -31
- athena/types/query_model.py +0 -40
- athena/types/report.py +0 -32
- athena/types/researcher_out.py +0 -29
- athena/types/semantic_query_out.py +0 -29
- athena/types/snippet.py +0 -35
- athena/types/sql_results.py +0 -29
- athena/types/status_enum.py +0 -29
- athena/types/structured_parse_result.py +0 -29
- athena/types/time_dimension_model.py +0 -33
- athena/types/tools.py +0 -57
- athena/types/upload_documents_out.py +0 -31
- athena/types/url_result.py +0 -29
- athena/types/workflow_status_out.py +0 -31
- athena/upload/__init__.py +0 -2
- athena/upload/client.py +0 -108
- athena/workflow/__init__.py +0 -2
- athena/workflow/client.py +0 -117
- athena_intelligence-0.1.94.dist-info/RECORD +0 -92
- {athena_intelligence-0.1.94.dist-info → athena_intelligence-0.1.96.dist-info}/WHEEL +0 -0
athena/tools/client.py
CHANGED
@@ -11,145 +11,18 @@ from ..errors.internal_server_error import InternalServerError
|
|
11
11
|
from ..errors.not_found_error import NotFoundError
|
12
12
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
13
13
|
from ..errors.unsupported_media_type_error import UnsupportedMediaTypeError
|
14
|
-
from ..types.athena_document_v_2_out import AthenaDocumentV2Out
|
15
|
-
from ..types.convert_pdf_to_sheet_out import ConvertPdfToSheetOut
|
16
14
|
from ..types.data_frame_parsing_error import DataFrameParsingError
|
17
15
|
from ..types.data_frame_request_out import DataFrameRequestOut
|
18
16
|
from ..types.data_frame_unknown_format_error import DataFrameUnknownFormatError
|
19
|
-
from ..types.excecute_tool_first_workflow_out import ExcecuteToolFirstWorkflowOut
|
20
17
|
from ..types.file_fetch_error import FileFetchError
|
21
|
-
from ..types.firecrawl_scrape_url_data_reponse_dto import FirecrawlScrapeUrlDataReponseDto
|
22
18
|
from ..types.http_validation_error import HttpValidationError
|
23
|
-
from ..types.langchain_documents_request_out import LangchainDocumentsRequestOut
|
24
|
-
from ..types.llm_model import LlmModel
|
25
|
-
from ..types.publish_formats import PublishFormats
|
26
|
-
from ..types.query_model import QueryModel
|
27
|
-
from ..types.researcher_out import ResearcherOut
|
28
|
-
from ..types.semantic_query_out import SemanticQueryOut
|
29
19
|
from .types.tools_data_frame_request_columns_item import ToolsDataFrameRequestColumnsItem
|
30
20
|
|
31
|
-
# this is used as the default value for optional parameters
|
32
|
-
OMIT = typing.cast(typing.Any, ...)
|
33
|
-
|
34
21
|
|
35
22
|
class ToolsClient:
|
36
23
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
37
24
|
self._client_wrapper = client_wrapper
|
38
25
|
|
39
|
-
def scrape_url(
|
40
|
-
self,
|
41
|
-
*,
|
42
|
-
url: str,
|
43
|
-
params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
44
|
-
request_options: typing.Optional[RequestOptions] = None
|
45
|
-
) -> FirecrawlScrapeUrlDataReponseDto:
|
46
|
-
"""
|
47
|
-
Parameters
|
48
|
-
----------
|
49
|
-
url : str
|
50
|
-
|
51
|
-
params : typing.Optional[typing.Dict[str, typing.Any]]
|
52
|
-
|
53
|
-
request_options : typing.Optional[RequestOptions]
|
54
|
-
Request-specific configuration.
|
55
|
-
|
56
|
-
Returns
|
57
|
-
-------
|
58
|
-
FirecrawlScrapeUrlDataReponseDto
|
59
|
-
Successful Response
|
60
|
-
|
61
|
-
Examples
|
62
|
-
--------
|
63
|
-
from athena.client import Athena
|
64
|
-
|
65
|
-
client = Athena(
|
66
|
-
api_key="YOUR_API_KEY",
|
67
|
-
)
|
68
|
-
client.tools.scrape_url(
|
69
|
-
url="https://www.athenaintelligence.ai",
|
70
|
-
params={"key": "value"},
|
71
|
-
)
|
72
|
-
"""
|
73
|
-
_response = self._client_wrapper.httpx_client.request(
|
74
|
-
"api/v0/tools/firecrawl/scrape-url",
|
75
|
-
method="POST",
|
76
|
-
json={"url": url, "params": params},
|
77
|
-
request_options=request_options,
|
78
|
-
omit=OMIT,
|
79
|
-
)
|
80
|
-
if 200 <= _response.status_code < 300:
|
81
|
-
return pydantic_v1.parse_obj_as(FirecrawlScrapeUrlDataReponseDto, _response.json()) # type: ignore
|
82
|
-
if _response.status_code == 422:
|
83
|
-
raise UnprocessableEntityError(
|
84
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
85
|
-
)
|
86
|
-
try:
|
87
|
-
_response_json = _response.json()
|
88
|
-
except JSONDecodeError:
|
89
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
90
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
91
|
-
|
92
|
-
def langchain_documents(
|
93
|
-
self,
|
94
|
-
*,
|
95
|
-
document_id: str,
|
96
|
-
pagination_limit: typing.Optional[int] = OMIT,
|
97
|
-
pagination_offset: typing.Optional[int] = OMIT,
|
98
|
-
request_options: typing.Optional[RequestOptions] = None
|
99
|
-
) -> LangchainDocumentsRequestOut:
|
100
|
-
"""
|
101
|
-
Parameters
|
102
|
-
----------
|
103
|
-
document_id : str
|
104
|
-
|
105
|
-
pagination_limit : typing.Optional[int]
|
106
|
-
|
107
|
-
pagination_offset : typing.Optional[int]
|
108
|
-
|
109
|
-
request_options : typing.Optional[RequestOptions]
|
110
|
-
Request-specific configuration.
|
111
|
-
|
112
|
-
Returns
|
113
|
-
-------
|
114
|
-
LangchainDocumentsRequestOut
|
115
|
-
Successful Response
|
116
|
-
|
117
|
-
Examples
|
118
|
-
--------
|
119
|
-
from athena.client import Athena
|
120
|
-
|
121
|
-
client = Athena(
|
122
|
-
api_key="YOUR_API_KEY",
|
123
|
-
)
|
124
|
-
client.tools.langchain_documents(
|
125
|
-
document_id="doc_9249292-d118-42d3-95b4-00eccfe0754f",
|
126
|
-
pagination_limit=250,
|
127
|
-
pagination_offset=0,
|
128
|
-
)
|
129
|
-
"""
|
130
|
-
_response = self._client_wrapper.httpx_client.request(
|
131
|
-
"api/v0/tools/file/langchain-documents",
|
132
|
-
method="POST",
|
133
|
-
json={
|
134
|
-
"document_id": document_id,
|
135
|
-
"pagination_limit": pagination_limit,
|
136
|
-
"pagination_offset": pagination_offset,
|
137
|
-
},
|
138
|
-
request_options=request_options,
|
139
|
-
omit=OMIT,
|
140
|
-
)
|
141
|
-
if 200 <= _response.status_code < 300:
|
142
|
-
return pydantic_v1.parse_obj_as(LangchainDocumentsRequestOut, _response.json()) # type: ignore
|
143
|
-
if _response.status_code == 422:
|
144
|
-
raise UnprocessableEntityError(
|
145
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
146
|
-
)
|
147
|
-
try:
|
148
|
-
_response_json = _response.json()
|
149
|
-
except JSONDecodeError:
|
150
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
151
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
152
|
-
|
153
26
|
def data_frame(
|
154
27
|
self,
|
155
28
|
*,
|
@@ -159,7 +32,7 @@ class ToolsClient:
|
|
159
32
|
columns: typing.Optional[
|
160
33
|
typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]
|
161
34
|
] = None,
|
162
|
-
sheet_name: typing.Optional[
|
35
|
+
sheet_name: typing.Optional[str] = None,
|
163
36
|
separator: typing.Optional[str] = None,
|
164
37
|
request_options: typing.Optional[RequestOptions] = None
|
165
38
|
) -> DataFrameRequestOut:
|
@@ -175,7 +48,7 @@ class ToolsClient:
|
|
175
48
|
columns : typing.Optional[typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]]
|
176
49
|
should be a list of strings or a list of integers
|
177
50
|
|
178
|
-
sheet_name : typing.Optional[
|
51
|
+
sheet_name : typing.Optional[str]
|
179
52
|
only for excel files
|
180
53
|
|
181
54
|
separator : typing.Optional[str]
|
@@ -237,6 +110,8 @@ class ToolsClient:
|
|
237
110
|
self, *, document_id: str, request_options: typing.Optional[RequestOptions] = None
|
238
111
|
) -> typing.Iterator[bytes]:
|
239
112
|
"""
|
113
|
+
Get the raw file data for given asset.
|
114
|
+
|
240
115
|
Parameters
|
241
116
|
----------
|
242
117
|
document_id : str
|
@@ -283,273 +158,100 @@ class ToolsClient:
|
|
283
158
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
284
159
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
285
160
|
|
286
|
-
def tool_first_workflow(
|
287
|
-
self,
|
288
|
-
*,
|
289
|
-
tool_name: str,
|
290
|
-
content: str,
|
291
|
-
model: typing.Optional[LlmModel] = OMIT,
|
292
|
-
tool_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
293
|
-
request_options: typing.Optional[RequestOptions] = None
|
294
|
-
) -> ExcecuteToolFirstWorkflowOut:
|
295
|
-
"""
|
296
|
-
Parameters
|
297
|
-
----------
|
298
|
-
tool_name : str
|
299
|
-
|
300
|
-
content : str
|
301
|
-
|
302
|
-
model : typing.Optional[LlmModel]
|
303
|
-
|
304
|
-
tool_kwargs : typing.Optional[typing.Dict[str, typing.Any]]
|
305
|
-
|
306
|
-
request_options : typing.Optional[RequestOptions]
|
307
|
-
Request-specific configuration.
|
308
|
-
|
309
|
-
Returns
|
310
|
-
-------
|
311
|
-
ExcecuteToolFirstWorkflowOut
|
312
|
-
Successful Response
|
313
|
-
|
314
|
-
Examples
|
315
|
-
--------
|
316
|
-
from athena import LlmModel
|
317
|
-
from athena.client import Athena
|
318
161
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
client.tools.tool_first_workflow(
|
323
|
-
model=LlmModel.MISTRAL_LARGE_0224,
|
324
|
-
tool_name="tavily_search",
|
325
|
-
content="summarize the website in one paragraph",
|
326
|
-
tool_kwargs={"query": "website: www.athenaintelligence.ai"},
|
327
|
-
)
|
328
|
-
"""
|
329
|
-
_response = self._client_wrapper.httpx_client.request(
|
330
|
-
"api/v0/tools/first-agent",
|
331
|
-
method="POST",
|
332
|
-
json={"model": model, "tool_name": tool_name, "content": content, "tool_kwargs": tool_kwargs},
|
333
|
-
request_options=request_options,
|
334
|
-
omit=OMIT,
|
335
|
-
)
|
336
|
-
if 200 <= _response.status_code < 300:
|
337
|
-
return pydantic_v1.parse_obj_as(ExcecuteToolFirstWorkflowOut, _response.json()) # type: ignore
|
338
|
-
if _response.status_code == 422:
|
339
|
-
raise UnprocessableEntityError(
|
340
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
341
|
-
)
|
342
|
-
try:
|
343
|
-
_response_json = _response.json()
|
344
|
-
except JSONDecodeError:
|
345
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
346
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
162
|
+
class AsyncToolsClient:
|
163
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
164
|
+
self._client_wrapper = client_wrapper
|
347
165
|
|
348
|
-
def
|
166
|
+
async def data_frame(
|
349
167
|
self,
|
350
168
|
*,
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
169
|
+
document_id: str,
|
170
|
+
row_limit: typing.Optional[int] = None,
|
171
|
+
index_column: typing.Optional[int] = None,
|
172
|
+
columns: typing.Optional[
|
173
|
+
typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]
|
174
|
+
] = None,
|
175
|
+
sheet_name: typing.Optional[str] = None,
|
176
|
+
separator: typing.Optional[str] = None,
|
357
177
|
request_options: typing.Optional[RequestOptions] = None
|
358
|
-
) ->
|
178
|
+
) -> DataFrameRequestOut:
|
359
179
|
"""
|
360
180
|
Parameters
|
361
181
|
----------
|
362
|
-
|
182
|
+
document_id : str
|
363
183
|
|
364
|
-
|
184
|
+
row_limit : typing.Optional[int]
|
365
185
|
|
366
|
-
|
186
|
+
index_column : typing.Optional[int]
|
367
187
|
|
368
|
-
|
188
|
+
columns : typing.Optional[typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]]
|
189
|
+
should be a list of strings or a list of integers
|
369
190
|
|
370
|
-
|
191
|
+
sheet_name : typing.Optional[str]
|
192
|
+
only for excel files
|
371
193
|
|
372
|
-
|
194
|
+
separator : typing.Optional[str]
|
195
|
+
only for csv files
|
373
196
|
|
374
197
|
request_options : typing.Optional[RequestOptions]
|
375
198
|
Request-specific configuration.
|
376
199
|
|
377
200
|
Returns
|
378
201
|
-------
|
379
|
-
|
202
|
+
DataFrameRequestOut
|
380
203
|
Successful Response
|
381
204
|
|
382
205
|
Examples
|
383
206
|
--------
|
384
|
-
from athena import
|
385
|
-
from athena.client import Athena
|
207
|
+
from athena.client import AsyncAthena
|
386
208
|
|
387
|
-
client =
|
209
|
+
client = AsyncAthena(
|
388
210
|
api_key="YOUR_API_KEY",
|
389
211
|
)
|
390
|
-
client.tools.
|
391
|
-
|
392
|
-
max_sections=10,
|
393
|
-
guidelines=[
|
394
|
-
"The report MUST be written in APA format",
|
395
|
-
"Each sub section MUST include supporting sources using hyperlinks. If none exist, erase the sub section or rewrite it to be a part of the previous section",
|
396
|
-
"The report MUST be written in english",
|
397
|
-
],
|
398
|
-
publish_formats=PublishFormats(
|
399
|
-
markdown=False,
|
400
|
-
pdf=True,
|
401
|
-
docx=False,
|
402
|
-
),
|
403
|
-
source="web",
|
404
|
-
athena_document_ids=["doc_1", "doc_2"],
|
212
|
+
await client.tools.data_frame(
|
213
|
+
document_id="document_id",
|
405
214
|
)
|
406
215
|
"""
|
407
|
-
_response = self._client_wrapper.httpx_client.request(
|
408
|
-
"api/v0/tools/
|
409
|
-
method="
|
410
|
-
|
411
|
-
"
|
412
|
-
"
|
413
|
-
"
|
414
|
-
"
|
415
|
-
"
|
416
|
-
"
|
216
|
+
_response = await self._client_wrapper.httpx_client.request(
|
217
|
+
"api/v0/tools/file/data-frame",
|
218
|
+
method="GET",
|
219
|
+
params={
|
220
|
+
"document_id": document_id,
|
221
|
+
"row_limit": row_limit,
|
222
|
+
"index_column": index_column,
|
223
|
+
"columns": columns,
|
224
|
+
"sheet_name": sheet_name,
|
225
|
+
"separator": separator,
|
417
226
|
},
|
418
227
|
request_options=request_options,
|
419
|
-
omit=OMIT,
|
420
|
-
)
|
421
|
-
if 200 <= _response.status_code < 300:
|
422
|
-
return pydantic_v1.parse_obj_as(ResearcherOut, _response.json()) # type: ignore
|
423
|
-
if _response.status_code == 422:
|
424
|
-
raise UnprocessableEntityError(
|
425
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
426
|
-
)
|
427
|
-
try:
|
428
|
-
_response_json = _response.json()
|
429
|
-
except JSONDecodeError:
|
430
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
431
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
432
|
-
|
433
|
-
def convert_pdf_to_sheet(
|
434
|
-
self, *, document_id: str, request_options: typing.Optional[RequestOptions] = None
|
435
|
-
) -> ConvertPdfToSheetOut:
|
436
|
-
"""
|
437
|
-
Parameters
|
438
|
-
----------
|
439
|
-
document_id : str
|
440
|
-
|
441
|
-
request_options : typing.Optional[RequestOptions]
|
442
|
-
Request-specific configuration.
|
443
|
-
|
444
|
-
Returns
|
445
|
-
-------
|
446
|
-
ConvertPdfToSheetOut
|
447
|
-
Successful Response
|
448
|
-
|
449
|
-
Examples
|
450
|
-
--------
|
451
|
-
from athena.client import Athena
|
452
|
-
|
453
|
-
client = Athena(
|
454
|
-
api_key="YOUR_API_KEY",
|
455
|
-
)
|
456
|
-
client.tools.convert_pdf_to_sheet(
|
457
|
-
document_id="doc_9249292-d118-42d3-95b4-00eccfe0754f",
|
458
|
-
)
|
459
|
-
"""
|
460
|
-
_response = self._client_wrapper.httpx_client.request(
|
461
|
-
"api/v0/tools/convert-pdf-to-sheet",
|
462
|
-
method="POST",
|
463
|
-
json={"document_id": document_id},
|
464
|
-
request_options=request_options,
|
465
|
-
omit=OMIT,
|
466
228
|
)
|
467
229
|
if 200 <= _response.status_code < 300:
|
468
|
-
return pydantic_v1.parse_obj_as(
|
469
|
-
if _response.status_code ==
|
470
|
-
raise
|
471
|
-
|
230
|
+
return pydantic_v1.parse_obj_as(DataFrameRequestOut, _response.json()) # type: ignore
|
231
|
+
if _response.status_code == 404:
|
232
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(FileFetchError, _response.json())) # type: ignore
|
233
|
+
if _response.status_code == 415:
|
234
|
+
raise UnsupportedMediaTypeError(
|
235
|
+
pydantic_v1.parse_obj_as(DataFrameUnknownFormatError, _response.json()) # type: ignore
|
472
236
|
)
|
473
|
-
try:
|
474
|
-
_response_json = _response.json()
|
475
|
-
except JSONDecodeError:
|
476
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
477
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
478
|
-
|
479
|
-
def semantic_query(
|
480
|
-
self,
|
481
|
-
*,
|
482
|
-
query: QueryModel,
|
483
|
-
table_name: typing.Optional[str] = OMIT,
|
484
|
-
request_options: typing.Optional[RequestOptions] = None
|
485
|
-
) -> SemanticQueryOut:
|
486
|
-
"""
|
487
|
-
Parameters
|
488
|
-
----------
|
489
|
-
query : QueryModel
|
490
|
-
|
491
|
-
table_name : typing.Optional[str]
|
492
|
-
|
493
|
-
request_options : typing.Optional[RequestOptions]
|
494
|
-
Request-specific configuration.
|
495
|
-
|
496
|
-
Returns
|
497
|
-
-------
|
498
|
-
SemanticQueryOut
|
499
|
-
Successful Response
|
500
|
-
|
501
|
-
Examples
|
502
|
-
--------
|
503
|
-
from athena import FilterModel, FilterOperator, QueryModel, TimeDimensionModel
|
504
|
-
from athena.client import Athena
|
505
|
-
|
506
|
-
client = Athena(
|
507
|
-
api_key="YOUR_API_KEY",
|
508
|
-
)
|
509
|
-
client.tools.semantic_query(
|
510
|
-
query=QueryModel(
|
511
|
-
measures=["count"],
|
512
|
-
time_dimensions=[
|
513
|
-
TimeDimensionModel(
|
514
|
-
dimension="dimension",
|
515
|
-
granularity="granularity",
|
516
|
-
date_range=["dateRange"],
|
517
|
-
)
|
518
|
-
],
|
519
|
-
dimensions=["manufacturer"],
|
520
|
-
filters=[
|
521
|
-
FilterModel(
|
522
|
-
dimension="manufacturer",
|
523
|
-
operator=FilterOperator.EQUALS,
|
524
|
-
values=["Athena"],
|
525
|
-
)
|
526
|
-
],
|
527
|
-
),
|
528
|
-
)
|
529
|
-
"""
|
530
|
-
_response = self._client_wrapper.httpx_client.request(
|
531
|
-
"api/v0/tools/strict-semantic-query",
|
532
|
-
method="POST",
|
533
|
-
json={"query": query, "table_name": table_name},
|
534
|
-
request_options=request_options,
|
535
|
-
omit=OMIT,
|
536
|
-
)
|
537
|
-
if 200 <= _response.status_code < 300:
|
538
|
-
return pydantic_v1.parse_obj_as(SemanticQueryOut, _response.json()) # type: ignore
|
539
237
|
if _response.status_code == 422:
|
540
238
|
raise UnprocessableEntityError(
|
541
239
|
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
542
240
|
)
|
241
|
+
if _response.status_code == 500:
|
242
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(DataFrameParsingError, _response.json())) # type: ignore
|
543
243
|
try:
|
544
244
|
_response_json = _response.json()
|
545
245
|
except JSONDecodeError:
|
546
246
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
547
247
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
548
248
|
|
549
|
-
def
|
249
|
+
async def raw_data(
|
550
250
|
self, *, document_id: str, request_options: typing.Optional[RequestOptions] = None
|
551
|
-
) ->
|
251
|
+
) -> typing.AsyncIterator[bytes]:
|
552
252
|
"""
|
253
|
+
Get the raw file data for given asset.
|
254
|
+
|
553
255
|
Parameters
|
554
256
|
----------
|
555
257
|
document_id : str
|
@@ -557,268 +259,20 @@ class ToolsClient:
|
|
557
259
|
request_options : typing.Optional[RequestOptions]
|
558
260
|
Request-specific configuration.
|
559
261
|
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
262
|
+
Yields
|
263
|
+
------
|
264
|
+
typing.AsyncIterator[bytes]
|
265
|
+
Stream the file in original format.
|
564
266
|
|
565
267
|
Examples
|
566
268
|
--------
|
567
|
-
from athena.client import
|
269
|
+
from athena.client import AsyncAthena
|
568
270
|
|
569
|
-
client =
|
271
|
+
client = AsyncAthena(
|
570
272
|
api_key="YOUR_API_KEY",
|
571
273
|
)
|
572
|
-
client.tools.
|
573
|
-
document_id="
|
574
|
-
)
|
575
|
-
"""
|
576
|
-
_response = self._client_wrapper.httpx_client.request(
|
577
|
-
"api/v0/tools/athena-document-v2",
|
578
|
-
method="POST",
|
579
|
-
json={"document_id": document_id},
|
580
|
-
request_options=request_options,
|
581
|
-
omit=OMIT,
|
582
|
-
)
|
583
|
-
if 200 <= _response.status_code < 300:
|
584
|
-
return pydantic_v1.parse_obj_as(AthenaDocumentV2Out, _response.json()) # type: ignore
|
585
|
-
if _response.status_code == 422:
|
586
|
-
raise UnprocessableEntityError(
|
587
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
588
|
-
)
|
589
|
-
try:
|
590
|
-
_response_json = _response.json()
|
591
|
-
except JSONDecodeError:
|
592
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
593
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
594
|
-
|
595
|
-
|
596
|
-
class AsyncToolsClient:
|
597
|
-
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
598
|
-
self._client_wrapper = client_wrapper
|
599
|
-
|
600
|
-
async def scrape_url(
|
601
|
-
self,
|
602
|
-
*,
|
603
|
-
url: str,
|
604
|
-
params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
605
|
-
request_options: typing.Optional[RequestOptions] = None
|
606
|
-
) -> FirecrawlScrapeUrlDataReponseDto:
|
607
|
-
"""
|
608
|
-
Parameters
|
609
|
-
----------
|
610
|
-
url : str
|
611
|
-
|
612
|
-
params : typing.Optional[typing.Dict[str, typing.Any]]
|
613
|
-
|
614
|
-
request_options : typing.Optional[RequestOptions]
|
615
|
-
Request-specific configuration.
|
616
|
-
|
617
|
-
Returns
|
618
|
-
-------
|
619
|
-
FirecrawlScrapeUrlDataReponseDto
|
620
|
-
Successful Response
|
621
|
-
|
622
|
-
Examples
|
623
|
-
--------
|
624
|
-
from athena.client import AsyncAthena
|
625
|
-
|
626
|
-
client = AsyncAthena(
|
627
|
-
api_key="YOUR_API_KEY",
|
628
|
-
)
|
629
|
-
await client.tools.scrape_url(
|
630
|
-
url="https://www.athenaintelligence.ai",
|
631
|
-
params={"key": "value"},
|
632
|
-
)
|
633
|
-
"""
|
634
|
-
_response = await self._client_wrapper.httpx_client.request(
|
635
|
-
"api/v0/tools/firecrawl/scrape-url",
|
636
|
-
method="POST",
|
637
|
-
json={"url": url, "params": params},
|
638
|
-
request_options=request_options,
|
639
|
-
omit=OMIT,
|
640
|
-
)
|
641
|
-
if 200 <= _response.status_code < 300:
|
642
|
-
return pydantic_v1.parse_obj_as(FirecrawlScrapeUrlDataReponseDto, _response.json()) # type: ignore
|
643
|
-
if _response.status_code == 422:
|
644
|
-
raise UnprocessableEntityError(
|
645
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
646
|
-
)
|
647
|
-
try:
|
648
|
-
_response_json = _response.json()
|
649
|
-
except JSONDecodeError:
|
650
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
651
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
652
|
-
|
653
|
-
async def langchain_documents(
|
654
|
-
self,
|
655
|
-
*,
|
656
|
-
document_id: str,
|
657
|
-
pagination_limit: typing.Optional[int] = OMIT,
|
658
|
-
pagination_offset: typing.Optional[int] = OMIT,
|
659
|
-
request_options: typing.Optional[RequestOptions] = None
|
660
|
-
) -> LangchainDocumentsRequestOut:
|
661
|
-
"""
|
662
|
-
Parameters
|
663
|
-
----------
|
664
|
-
document_id : str
|
665
|
-
|
666
|
-
pagination_limit : typing.Optional[int]
|
667
|
-
|
668
|
-
pagination_offset : typing.Optional[int]
|
669
|
-
|
670
|
-
request_options : typing.Optional[RequestOptions]
|
671
|
-
Request-specific configuration.
|
672
|
-
|
673
|
-
Returns
|
674
|
-
-------
|
675
|
-
LangchainDocumentsRequestOut
|
676
|
-
Successful Response
|
677
|
-
|
678
|
-
Examples
|
679
|
-
--------
|
680
|
-
from athena.client import AsyncAthena
|
681
|
-
|
682
|
-
client = AsyncAthena(
|
683
|
-
api_key="YOUR_API_KEY",
|
684
|
-
)
|
685
|
-
await client.tools.langchain_documents(
|
686
|
-
document_id="doc_9249292-d118-42d3-95b4-00eccfe0754f",
|
687
|
-
pagination_limit=250,
|
688
|
-
pagination_offset=0,
|
689
|
-
)
|
690
|
-
"""
|
691
|
-
_response = await self._client_wrapper.httpx_client.request(
|
692
|
-
"api/v0/tools/file/langchain-documents",
|
693
|
-
method="POST",
|
694
|
-
json={
|
695
|
-
"document_id": document_id,
|
696
|
-
"pagination_limit": pagination_limit,
|
697
|
-
"pagination_offset": pagination_offset,
|
698
|
-
},
|
699
|
-
request_options=request_options,
|
700
|
-
omit=OMIT,
|
701
|
-
)
|
702
|
-
if 200 <= _response.status_code < 300:
|
703
|
-
return pydantic_v1.parse_obj_as(LangchainDocumentsRequestOut, _response.json()) # type: ignore
|
704
|
-
if _response.status_code == 422:
|
705
|
-
raise UnprocessableEntityError(
|
706
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
707
|
-
)
|
708
|
-
try:
|
709
|
-
_response_json = _response.json()
|
710
|
-
except JSONDecodeError:
|
711
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
712
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
713
|
-
|
714
|
-
async def data_frame(
|
715
|
-
self,
|
716
|
-
*,
|
717
|
-
document_id: str,
|
718
|
-
row_limit: typing.Optional[int] = None,
|
719
|
-
index_column: typing.Optional[int] = None,
|
720
|
-
columns: typing.Optional[
|
721
|
-
typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]
|
722
|
-
] = None,
|
723
|
-
sheet_name: typing.Optional[int] = None,
|
724
|
-
separator: typing.Optional[str] = None,
|
725
|
-
request_options: typing.Optional[RequestOptions] = None
|
726
|
-
) -> DataFrameRequestOut:
|
727
|
-
"""
|
728
|
-
Parameters
|
729
|
-
----------
|
730
|
-
document_id : str
|
731
|
-
|
732
|
-
row_limit : typing.Optional[int]
|
733
|
-
|
734
|
-
index_column : typing.Optional[int]
|
735
|
-
|
736
|
-
columns : typing.Optional[typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]]
|
737
|
-
should be a list of strings or a list of integers
|
738
|
-
|
739
|
-
sheet_name : typing.Optional[int]
|
740
|
-
only for excel files
|
741
|
-
|
742
|
-
separator : typing.Optional[str]
|
743
|
-
only for csv files
|
744
|
-
|
745
|
-
request_options : typing.Optional[RequestOptions]
|
746
|
-
Request-specific configuration.
|
747
|
-
|
748
|
-
Returns
|
749
|
-
-------
|
750
|
-
DataFrameRequestOut
|
751
|
-
Successful Response
|
752
|
-
|
753
|
-
Examples
|
754
|
-
--------
|
755
|
-
from athena.client import AsyncAthena
|
756
|
-
|
757
|
-
client = AsyncAthena(
|
758
|
-
api_key="YOUR_API_KEY",
|
759
|
-
)
|
760
|
-
await client.tools.data_frame(
|
761
|
-
document_id="document_id",
|
762
|
-
)
|
763
|
-
"""
|
764
|
-
_response = await self._client_wrapper.httpx_client.request(
|
765
|
-
"api/v0/tools/file/data-frame",
|
766
|
-
method="GET",
|
767
|
-
params={
|
768
|
-
"document_id": document_id,
|
769
|
-
"row_limit": row_limit,
|
770
|
-
"index_column": index_column,
|
771
|
-
"columns": columns,
|
772
|
-
"sheet_name": sheet_name,
|
773
|
-
"separator": separator,
|
774
|
-
},
|
775
|
-
request_options=request_options,
|
776
|
-
)
|
777
|
-
if 200 <= _response.status_code < 300:
|
778
|
-
return pydantic_v1.parse_obj_as(DataFrameRequestOut, _response.json()) # type: ignore
|
779
|
-
if _response.status_code == 404:
|
780
|
-
raise NotFoundError(pydantic_v1.parse_obj_as(FileFetchError, _response.json())) # type: ignore
|
781
|
-
if _response.status_code == 415:
|
782
|
-
raise UnsupportedMediaTypeError(
|
783
|
-
pydantic_v1.parse_obj_as(DataFrameUnknownFormatError, _response.json()) # type: ignore
|
784
|
-
)
|
785
|
-
if _response.status_code == 422:
|
786
|
-
raise UnprocessableEntityError(
|
787
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
788
|
-
)
|
789
|
-
if _response.status_code == 500:
|
790
|
-
raise InternalServerError(pydantic_v1.parse_obj_as(DataFrameParsingError, _response.json())) # type: ignore
|
791
|
-
try:
|
792
|
-
_response_json = _response.json()
|
793
|
-
except JSONDecodeError:
|
794
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
795
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
796
|
-
|
797
|
-
async def raw_data(
|
798
|
-
self, *, document_id: str, request_options: typing.Optional[RequestOptions] = None
|
799
|
-
) -> typing.AsyncIterator[bytes]:
|
800
|
-
"""
|
801
|
-
Parameters
|
802
|
-
----------
|
803
|
-
document_id : str
|
804
|
-
|
805
|
-
request_options : typing.Optional[RequestOptions]
|
806
|
-
Request-specific configuration.
|
807
|
-
|
808
|
-
Yields
|
809
|
-
------
|
810
|
-
typing.AsyncIterator[bytes]
|
811
|
-
Stream the file in original format.
|
812
|
-
|
813
|
-
Examples
|
814
|
-
--------
|
815
|
-
from athena.client import AsyncAthena
|
816
|
-
|
817
|
-
client = AsyncAthena(
|
818
|
-
api_key="YOUR_API_KEY",
|
819
|
-
)
|
820
|
-
await client.tools.raw_data(
|
821
|
-
document_id="string",
|
274
|
+
await client.tools.raw_data(
|
275
|
+
document_id="string",
|
822
276
|
)
|
823
277
|
"""
|
824
278
|
async with self._client_wrapper.httpx_client.stream(
|
@@ -843,312 +297,3 @@ class AsyncToolsClient:
|
|
843
297
|
except JSONDecodeError:
|
844
298
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
845
299
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
846
|
-
|
847
|
-
async def tool_first_workflow(
|
848
|
-
self,
|
849
|
-
*,
|
850
|
-
tool_name: str,
|
851
|
-
content: str,
|
852
|
-
model: typing.Optional[LlmModel] = OMIT,
|
853
|
-
tool_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
854
|
-
request_options: typing.Optional[RequestOptions] = None
|
855
|
-
) -> ExcecuteToolFirstWorkflowOut:
|
856
|
-
"""
|
857
|
-
Parameters
|
858
|
-
----------
|
859
|
-
tool_name : str
|
860
|
-
|
861
|
-
content : str
|
862
|
-
|
863
|
-
model : typing.Optional[LlmModel]
|
864
|
-
|
865
|
-
tool_kwargs : typing.Optional[typing.Dict[str, typing.Any]]
|
866
|
-
|
867
|
-
request_options : typing.Optional[RequestOptions]
|
868
|
-
Request-specific configuration.
|
869
|
-
|
870
|
-
Returns
|
871
|
-
-------
|
872
|
-
ExcecuteToolFirstWorkflowOut
|
873
|
-
Successful Response
|
874
|
-
|
875
|
-
Examples
|
876
|
-
--------
|
877
|
-
from athena import LlmModel
|
878
|
-
from athena.client import AsyncAthena
|
879
|
-
|
880
|
-
client = AsyncAthena(
|
881
|
-
api_key="YOUR_API_KEY",
|
882
|
-
)
|
883
|
-
await client.tools.tool_first_workflow(
|
884
|
-
model=LlmModel.MISTRAL_LARGE_0224,
|
885
|
-
tool_name="tavily_search",
|
886
|
-
content="summarize the website in one paragraph",
|
887
|
-
tool_kwargs={"query": "website: www.athenaintelligence.ai"},
|
888
|
-
)
|
889
|
-
"""
|
890
|
-
_response = await self._client_wrapper.httpx_client.request(
|
891
|
-
"api/v0/tools/first-agent",
|
892
|
-
method="POST",
|
893
|
-
json={"model": model, "tool_name": tool_name, "content": content, "tool_kwargs": tool_kwargs},
|
894
|
-
request_options=request_options,
|
895
|
-
omit=OMIT,
|
896
|
-
)
|
897
|
-
if 200 <= _response.status_code < 300:
|
898
|
-
return pydantic_v1.parse_obj_as(ExcecuteToolFirstWorkflowOut, _response.json()) # type: ignore
|
899
|
-
if _response.status_code == 422:
|
900
|
-
raise UnprocessableEntityError(
|
901
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
902
|
-
)
|
903
|
-
try:
|
904
|
-
_response_json = _response.json()
|
905
|
-
except JSONDecodeError:
|
906
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
907
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
908
|
-
|
909
|
-
async def researcher(
|
910
|
-
self,
|
911
|
-
*,
|
912
|
-
query: str,
|
913
|
-
max_sections: int,
|
914
|
-
guidelines: typing.Sequence[str],
|
915
|
-
publish_formats: typing.Optional[PublishFormats] = OMIT,
|
916
|
-
source: typing.Optional[str] = OMIT,
|
917
|
-
athena_document_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
918
|
-
request_options: typing.Optional[RequestOptions] = None
|
919
|
-
) -> ResearcherOut:
|
920
|
-
"""
|
921
|
-
Parameters
|
922
|
-
----------
|
923
|
-
query : str
|
924
|
-
|
925
|
-
max_sections : int
|
926
|
-
|
927
|
-
guidelines : typing.Sequence[str]
|
928
|
-
|
929
|
-
publish_formats : typing.Optional[PublishFormats]
|
930
|
-
|
931
|
-
source : typing.Optional[str]
|
932
|
-
|
933
|
-
athena_document_ids : typing.Optional[typing.Sequence[str]]
|
934
|
-
|
935
|
-
request_options : typing.Optional[RequestOptions]
|
936
|
-
Request-specific configuration.
|
937
|
-
|
938
|
-
Returns
|
939
|
-
-------
|
940
|
-
ResearcherOut
|
941
|
-
Successful Response
|
942
|
-
|
943
|
-
Examples
|
944
|
-
--------
|
945
|
-
from athena import PublishFormats
|
946
|
-
from athena.client import AsyncAthena
|
947
|
-
|
948
|
-
client = AsyncAthena(
|
949
|
-
api_key="YOUR_API_KEY",
|
950
|
-
)
|
951
|
-
await client.tools.researcher(
|
952
|
-
query="Write a report about the company Athena Intelligence.",
|
953
|
-
max_sections=10,
|
954
|
-
guidelines=[
|
955
|
-
"The report MUST be written in APA format",
|
956
|
-
"Each sub section MUST include supporting sources using hyperlinks. If none exist, erase the sub section or rewrite it to be a part of the previous section",
|
957
|
-
"The report MUST be written in english",
|
958
|
-
],
|
959
|
-
publish_formats=PublishFormats(
|
960
|
-
markdown=False,
|
961
|
-
pdf=True,
|
962
|
-
docx=False,
|
963
|
-
),
|
964
|
-
source="web",
|
965
|
-
athena_document_ids=["doc_1", "doc_2"],
|
966
|
-
)
|
967
|
-
"""
|
968
|
-
_response = await self._client_wrapper.httpx_client.request(
|
969
|
-
"api/v0/tools/researcher",
|
970
|
-
method="POST",
|
971
|
-
json={
|
972
|
-
"query": query,
|
973
|
-
"max_sections": max_sections,
|
974
|
-
"guidelines": guidelines,
|
975
|
-
"publish_formats": publish_formats,
|
976
|
-
"source": source,
|
977
|
-
"athena_document_ids": athena_document_ids,
|
978
|
-
},
|
979
|
-
request_options=request_options,
|
980
|
-
omit=OMIT,
|
981
|
-
)
|
982
|
-
if 200 <= _response.status_code < 300:
|
983
|
-
return pydantic_v1.parse_obj_as(ResearcherOut, _response.json()) # type: ignore
|
984
|
-
if _response.status_code == 422:
|
985
|
-
raise UnprocessableEntityError(
|
986
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
987
|
-
)
|
988
|
-
try:
|
989
|
-
_response_json = _response.json()
|
990
|
-
except JSONDecodeError:
|
991
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
992
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
993
|
-
|
994
|
-
async def convert_pdf_to_sheet(
|
995
|
-
self, *, document_id: str, request_options: typing.Optional[RequestOptions] = None
|
996
|
-
) -> ConvertPdfToSheetOut:
|
997
|
-
"""
|
998
|
-
Parameters
|
999
|
-
----------
|
1000
|
-
document_id : str
|
1001
|
-
|
1002
|
-
request_options : typing.Optional[RequestOptions]
|
1003
|
-
Request-specific configuration.
|
1004
|
-
|
1005
|
-
Returns
|
1006
|
-
-------
|
1007
|
-
ConvertPdfToSheetOut
|
1008
|
-
Successful Response
|
1009
|
-
|
1010
|
-
Examples
|
1011
|
-
--------
|
1012
|
-
from athena.client import AsyncAthena
|
1013
|
-
|
1014
|
-
client = AsyncAthena(
|
1015
|
-
api_key="YOUR_API_KEY",
|
1016
|
-
)
|
1017
|
-
await client.tools.convert_pdf_to_sheet(
|
1018
|
-
document_id="doc_9249292-d118-42d3-95b4-00eccfe0754f",
|
1019
|
-
)
|
1020
|
-
"""
|
1021
|
-
_response = await self._client_wrapper.httpx_client.request(
|
1022
|
-
"api/v0/tools/convert-pdf-to-sheet",
|
1023
|
-
method="POST",
|
1024
|
-
json={"document_id": document_id},
|
1025
|
-
request_options=request_options,
|
1026
|
-
omit=OMIT,
|
1027
|
-
)
|
1028
|
-
if 200 <= _response.status_code < 300:
|
1029
|
-
return pydantic_v1.parse_obj_as(ConvertPdfToSheetOut, _response.json()) # type: ignore
|
1030
|
-
if _response.status_code == 422:
|
1031
|
-
raise UnprocessableEntityError(
|
1032
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
1033
|
-
)
|
1034
|
-
try:
|
1035
|
-
_response_json = _response.json()
|
1036
|
-
except JSONDecodeError:
|
1037
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
1038
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
1039
|
-
|
1040
|
-
async def semantic_query(
|
1041
|
-
self,
|
1042
|
-
*,
|
1043
|
-
query: QueryModel,
|
1044
|
-
table_name: typing.Optional[str] = OMIT,
|
1045
|
-
request_options: typing.Optional[RequestOptions] = None
|
1046
|
-
) -> SemanticQueryOut:
|
1047
|
-
"""
|
1048
|
-
Parameters
|
1049
|
-
----------
|
1050
|
-
query : QueryModel
|
1051
|
-
|
1052
|
-
table_name : typing.Optional[str]
|
1053
|
-
|
1054
|
-
request_options : typing.Optional[RequestOptions]
|
1055
|
-
Request-specific configuration.
|
1056
|
-
|
1057
|
-
Returns
|
1058
|
-
-------
|
1059
|
-
SemanticQueryOut
|
1060
|
-
Successful Response
|
1061
|
-
|
1062
|
-
Examples
|
1063
|
-
--------
|
1064
|
-
from athena import FilterModel, FilterOperator, QueryModel, TimeDimensionModel
|
1065
|
-
from athena.client import AsyncAthena
|
1066
|
-
|
1067
|
-
client = AsyncAthena(
|
1068
|
-
api_key="YOUR_API_KEY",
|
1069
|
-
)
|
1070
|
-
await client.tools.semantic_query(
|
1071
|
-
query=QueryModel(
|
1072
|
-
measures=["count"],
|
1073
|
-
time_dimensions=[
|
1074
|
-
TimeDimensionModel(
|
1075
|
-
dimension="dimension",
|
1076
|
-
granularity="granularity",
|
1077
|
-
date_range=["dateRange"],
|
1078
|
-
)
|
1079
|
-
],
|
1080
|
-
dimensions=["manufacturer"],
|
1081
|
-
filters=[
|
1082
|
-
FilterModel(
|
1083
|
-
dimension="manufacturer",
|
1084
|
-
operator=FilterOperator.EQUALS,
|
1085
|
-
values=["Athena"],
|
1086
|
-
)
|
1087
|
-
],
|
1088
|
-
),
|
1089
|
-
)
|
1090
|
-
"""
|
1091
|
-
_response = await self._client_wrapper.httpx_client.request(
|
1092
|
-
"api/v0/tools/strict-semantic-query",
|
1093
|
-
method="POST",
|
1094
|
-
json={"query": query, "table_name": table_name},
|
1095
|
-
request_options=request_options,
|
1096
|
-
omit=OMIT,
|
1097
|
-
)
|
1098
|
-
if 200 <= _response.status_code < 300:
|
1099
|
-
return pydantic_v1.parse_obj_as(SemanticQueryOut, _response.json()) # type: ignore
|
1100
|
-
if _response.status_code == 422:
|
1101
|
-
raise UnprocessableEntityError(
|
1102
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
1103
|
-
)
|
1104
|
-
try:
|
1105
|
-
_response_json = _response.json()
|
1106
|
-
except JSONDecodeError:
|
1107
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
1108
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
1109
|
-
|
1110
|
-
async def athena_documents(
|
1111
|
-
self, *, document_id: str, request_options: typing.Optional[RequestOptions] = None
|
1112
|
-
) -> AthenaDocumentV2Out:
|
1113
|
-
"""
|
1114
|
-
Parameters
|
1115
|
-
----------
|
1116
|
-
document_id : str
|
1117
|
-
|
1118
|
-
request_options : typing.Optional[RequestOptions]
|
1119
|
-
Request-specific configuration.
|
1120
|
-
|
1121
|
-
Returns
|
1122
|
-
-------
|
1123
|
-
AthenaDocumentV2Out
|
1124
|
-
Successful Response
|
1125
|
-
|
1126
|
-
Examples
|
1127
|
-
--------
|
1128
|
-
from athena.client import AsyncAthena
|
1129
|
-
|
1130
|
-
client = AsyncAthena(
|
1131
|
-
api_key="YOUR_API_KEY",
|
1132
|
-
)
|
1133
|
-
await client.tools.athena_documents(
|
1134
|
-
document_id="doc_9249292-d118-42d3-95b4-00eccfe0754f",
|
1135
|
-
)
|
1136
|
-
"""
|
1137
|
-
_response = await self._client_wrapper.httpx_client.request(
|
1138
|
-
"api/v0/tools/athena-document-v2",
|
1139
|
-
method="POST",
|
1140
|
-
json={"document_id": document_id},
|
1141
|
-
request_options=request_options,
|
1142
|
-
omit=OMIT,
|
1143
|
-
)
|
1144
|
-
if 200 <= _response.status_code < 300:
|
1145
|
-
return pydantic_v1.parse_obj_as(AthenaDocumentV2Out, _response.json()) # type: ignore
|
1146
|
-
if _response.status_code == 422:
|
1147
|
-
raise UnprocessableEntityError(
|
1148
|
-
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
1149
|
-
)
|
1150
|
-
try:
|
1151
|
-
_response_json = _response.json()
|
1152
|
-
except JSONDecodeError:
|
1153
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
1154
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|