athena-intelligence 0.1.126__py3-none-any.whl → 0.1.184__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 +28 -3
- athena/agents/__init__.py +2 -0
- athena/agents/client.py +51 -95
- athena/agents/drive/__init__.py +2 -0
- athena/agents/drive/client.py +31 -80
- athena/agents/drive/raw_client.py +155 -0
- athena/agents/general/__init__.py +2 -0
- athena/agents/general/client.py +91 -238
- athena/agents/general/raw_client.py +369 -0
- athena/agents/raw_client.py +176 -0
- athena/agents/research/__init__.py +2 -0
- athena/agents/research/client.py +31 -80
- athena/agents/research/raw_client.py +155 -0
- athena/agents/sql/__init__.py +2 -0
- athena/agents/sql/client.py +31 -80
- athena/agents/sql/raw_client.py +155 -0
- athena/assets/__init__.py +4 -0
- athena/assets/client.py +144 -0
- athena/assets/raw_client.py +164 -0
- athena/base_client.py +25 -11
- athena/client.py +1 -1
- athena/core/__init__.py +5 -0
- athena/core/api_error.py +13 -5
- athena/core/client_wrapper.py +33 -8
- athena/core/force_multipart.py +16 -0
- athena/core/http_client.py +70 -26
- athena/core/http_response.py +55 -0
- athena/core/jsonable_encoder.py +0 -1
- athena/core/pydantic_utilities.py +70 -111
- athena/core/serialization.py +7 -3
- athena/errors/__init__.py +2 -0
- athena/errors/bad_request_error.py +4 -2
- athena/errors/content_too_large_error.py +4 -2
- athena/errors/internal_server_error.py +4 -3
- athena/errors/not_found_error.py +4 -2
- athena/errors/unauthorized_error.py +4 -3
- athena/errors/unprocessable_entity_error.py +4 -3
- athena/errors/unsupported_media_type_error.py +4 -2
- athena/query/__init__.py +2 -0
- athena/query/client.py +39 -219
- athena/query/raw_client.py +344 -0
- athena/query/types/__init__.py +2 -0
- athena/tools/__init__.py +2 -0
- athena/tools/calendar/__init__.py +2 -0
- athena/tools/calendar/client.py +35 -79
- athena/tools/calendar/raw_client.py +172 -0
- athena/tools/client.py +267 -653
- athena/tools/email/__init__.py +2 -0
- athena/tools/email/client.py +39 -115
- athena/tools/email/raw_client.py +248 -0
- athena/tools/raw_client.py +1328 -0
- athena/tools/structured_data_extractor/__init__.py +2 -0
- athena/tools/structured_data_extractor/client.py +42 -96
- athena/tools/structured_data_extractor/raw_client.py +240 -0
- athena/tools/tasks/__init__.py +2 -0
- athena/tools/tasks/client.py +31 -43
- athena/tools/tasks/raw_client.py +96 -0
- athena/tools/types/__init__.py +2 -0
- athena/types/__init__.py +28 -2
- athena/types/asset_content_request_out.py +26 -0
- athena/types/asset_node.py +3 -3
- athena/types/asset_not_found_error.py +2 -2
- athena/types/asset_screenshot_response_out.py +43 -0
- athena/types/chunk.py +3 -3
- athena/types/chunk_content_item.py +3 -2
- athena/types/chunk_result.py +3 -3
- athena/types/content.py +7 -0
- athena/types/custom_agent_response.py +2 -2
- athena/types/data_frame_request_out.py +3 -3
- athena/types/data_frame_unknown_format_error.py +2 -2
- athena/types/document_chunk.py +2 -2
- athena/types/drive_agent_response.py +2 -2
- athena/types/file_chunk_request_out.py +3 -3
- athena/types/file_too_large_error.py +2 -2
- athena/types/folder_response.py +10 -4
- athena/types/general_agent_config.py +4 -3
- athena/types/general_agent_config_enabled_tools_item.py +1 -2
- athena/types/general_agent_request.py +15 -4
- athena/types/general_agent_response.py +4 -3
- athena/types/general_agent_response_message.py +100 -0
- athena/types/general_agent_response_message_kwargs.py +74 -0
- athena/types/{tool.py → id.py} +1 -1
- athena/types/image_url_content.py +2 -2
- athena/types/input_message.py +29 -0
- athena/types/input_message_content_item.py +39 -0
- athena/types/paginated_assets_out.py +52 -0
- athena/types/parent_folder_error.py +2 -2
- athena/types/prompt_message.py +3 -3
- athena/types/public_asset_out.py +97 -0
- athena/types/research_agent_response.py +2 -2
- athena/types/save_asset_request_out.py +2 -2
- athena/types/sql_agent_response.py +2 -2
- athena/types/structured_data_extractor_response.py +3 -3
- athena/types/text_content.py +2 -2
- athena/types/type.py +1 -1
- {athena_intelligence-0.1.126.dist-info → athena_intelligence-0.1.184.dist-info}/METADATA +3 -7
- athena_intelligence-0.1.184.dist-info/RECORD +112 -0
- {athena_intelligence-0.1.126.dist-info → athena_intelligence-0.1.184.dist-info}/WHEEL +1 -1
- athena_intelligence-0.1.126.dist-info/RECORD +0 -87
@@ -1,17 +1,13 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
3
|
import typing
|
4
|
-
|
4
|
+
|
5
|
+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
6
|
+
from ...core.request_options import RequestOptions
|
5
7
|
from ...types.chunk import Chunk
|
6
8
|
from ...types.prompt_message import PromptMessage
|
7
|
-
from ...core.request_options import RequestOptions
|
8
9
|
from ...types.structured_data_extractor_response import StructuredDataExtractorResponse
|
9
|
-
from
|
10
|
-
from ...core.pydantic_utilities import parse_obj_as
|
11
|
-
from ...errors.unprocessable_entity_error import UnprocessableEntityError
|
12
|
-
from json.decoder import JSONDecodeError
|
13
|
-
from ...core.api_error import ApiError
|
14
|
-
from ...core.client_wrapper import AsyncClientWrapper
|
10
|
+
from .raw_client import AsyncRawStructuredDataExtractorClient, RawStructuredDataExtractorClient
|
15
11
|
|
16
12
|
# this is used as the default value for optional parameters
|
17
13
|
OMIT = typing.cast(typing.Any, ...)
|
@@ -19,7 +15,18 @@ OMIT = typing.cast(typing.Any, ...)
|
|
19
15
|
|
20
16
|
class StructuredDataExtractorClient:
|
21
17
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
22
|
-
self.
|
18
|
+
self._raw_client = RawStructuredDataExtractorClient(client_wrapper=client_wrapper)
|
19
|
+
|
20
|
+
@property
|
21
|
+
def with_raw_response(self) -> RawStructuredDataExtractorClient:
|
22
|
+
"""
|
23
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
24
|
+
|
25
|
+
Returns
|
26
|
+
-------
|
27
|
+
RawStructuredDataExtractorClient
|
28
|
+
"""
|
29
|
+
return self._raw_client
|
23
30
|
|
24
31
|
def invoke(
|
25
32
|
self,
|
@@ -118,56 +125,31 @@ class StructuredDataExtractorClient:
|
|
118
125
|
},
|
119
126
|
)
|
120
127
|
"""
|
121
|
-
_response = self.
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
),
|
128
|
-
"chunks": convert_and_respect_annotation_metadata(
|
129
|
-
object_=chunks, annotation=typing.Sequence[Chunk], direction="write"
|
130
|
-
),
|
131
|
-
"json_schema": json_schema,
|
132
|
-
"reduce": reduce,
|
133
|
-
"reduce_messages": convert_and_respect_annotation_metadata(
|
134
|
-
object_=reduce_messages, annotation=typing.Sequence[PromptMessage], direction="write"
|
135
|
-
),
|
136
|
-
},
|
137
|
-
headers={
|
138
|
-
"content-type": "application/json",
|
139
|
-
},
|
128
|
+
_response = self._raw_client.invoke(
|
129
|
+
chunks=chunks,
|
130
|
+
json_schema=json_schema,
|
131
|
+
chunk_messages=chunk_messages,
|
132
|
+
reduce=reduce,
|
133
|
+
reduce_messages=reduce_messages,
|
140
134
|
request_options=request_options,
|
141
|
-
omit=OMIT,
|
142
135
|
)
|
143
|
-
|
144
|
-
if 200 <= _response.status_code < 300:
|
145
|
-
return typing.cast(
|
146
|
-
StructuredDataExtractorResponse,
|
147
|
-
parse_obj_as(
|
148
|
-
type_=StructuredDataExtractorResponse, # type: ignore
|
149
|
-
object_=_response.json(),
|
150
|
-
),
|
151
|
-
)
|
152
|
-
if _response.status_code == 422:
|
153
|
-
raise UnprocessableEntityError(
|
154
|
-
typing.cast(
|
155
|
-
typing.Optional[typing.Any],
|
156
|
-
parse_obj_as(
|
157
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
158
|
-
object_=_response.json(),
|
159
|
-
),
|
160
|
-
)
|
161
|
-
)
|
162
|
-
_response_json = _response.json()
|
163
|
-
except JSONDecodeError:
|
164
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
165
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
136
|
+
return _response.data
|
166
137
|
|
167
138
|
|
168
139
|
class AsyncStructuredDataExtractorClient:
|
169
140
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
170
|
-
self.
|
141
|
+
self._raw_client = AsyncRawStructuredDataExtractorClient(client_wrapper=client_wrapper)
|
142
|
+
|
143
|
+
@property
|
144
|
+
def with_raw_response(self) -> AsyncRawStructuredDataExtractorClient:
|
145
|
+
"""
|
146
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
147
|
+
|
148
|
+
Returns
|
149
|
+
-------
|
150
|
+
AsyncRawStructuredDataExtractorClient
|
151
|
+
"""
|
152
|
+
return self._raw_client
|
171
153
|
|
172
154
|
async def invoke(
|
173
155
|
self,
|
@@ -274,48 +256,12 @@ class AsyncStructuredDataExtractorClient:
|
|
274
256
|
|
275
257
|
asyncio.run(main())
|
276
258
|
"""
|
277
|
-
_response = await self.
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
),
|
284
|
-
"chunks": convert_and_respect_annotation_metadata(
|
285
|
-
object_=chunks, annotation=typing.Sequence[Chunk], direction="write"
|
286
|
-
),
|
287
|
-
"json_schema": json_schema,
|
288
|
-
"reduce": reduce,
|
289
|
-
"reduce_messages": convert_and_respect_annotation_metadata(
|
290
|
-
object_=reduce_messages, annotation=typing.Sequence[PromptMessage], direction="write"
|
291
|
-
),
|
292
|
-
},
|
293
|
-
headers={
|
294
|
-
"content-type": "application/json",
|
295
|
-
},
|
259
|
+
_response = await self._raw_client.invoke(
|
260
|
+
chunks=chunks,
|
261
|
+
json_schema=json_schema,
|
262
|
+
chunk_messages=chunk_messages,
|
263
|
+
reduce=reduce,
|
264
|
+
reduce_messages=reduce_messages,
|
296
265
|
request_options=request_options,
|
297
|
-
omit=OMIT,
|
298
266
|
)
|
299
|
-
|
300
|
-
if 200 <= _response.status_code < 300:
|
301
|
-
return typing.cast(
|
302
|
-
StructuredDataExtractorResponse,
|
303
|
-
parse_obj_as(
|
304
|
-
type_=StructuredDataExtractorResponse, # type: ignore
|
305
|
-
object_=_response.json(),
|
306
|
-
),
|
307
|
-
)
|
308
|
-
if _response.status_code == 422:
|
309
|
-
raise UnprocessableEntityError(
|
310
|
-
typing.cast(
|
311
|
-
typing.Optional[typing.Any],
|
312
|
-
parse_obj_as(
|
313
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
314
|
-
object_=_response.json(),
|
315
|
-
),
|
316
|
-
)
|
317
|
-
)
|
318
|
-
_response_json = _response.json()
|
319
|
-
except JSONDecodeError:
|
320
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
321
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
267
|
+
return _response.data
|
@@ -0,0 +1,240 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import typing
|
4
|
+
from json.decoder import JSONDecodeError
|
5
|
+
|
6
|
+
from ...core.api_error import ApiError
|
7
|
+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
8
|
+
from ...core.http_response import AsyncHttpResponse, HttpResponse
|
9
|
+
from ...core.pydantic_utilities import parse_obj_as
|
10
|
+
from ...core.request_options import RequestOptions
|
11
|
+
from ...core.serialization import convert_and_respect_annotation_metadata
|
12
|
+
from ...errors.unprocessable_entity_error import UnprocessableEntityError
|
13
|
+
from ...types.chunk import Chunk
|
14
|
+
from ...types.prompt_message import PromptMessage
|
15
|
+
from ...types.structured_data_extractor_response import StructuredDataExtractorResponse
|
16
|
+
|
17
|
+
# this is used as the default value for optional parameters
|
18
|
+
OMIT = typing.cast(typing.Any, ...)
|
19
|
+
|
20
|
+
|
21
|
+
class RawStructuredDataExtractorClient:
|
22
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
23
|
+
self._client_wrapper = client_wrapper
|
24
|
+
|
25
|
+
def invoke(
|
26
|
+
self,
|
27
|
+
*,
|
28
|
+
chunks: typing.Sequence[Chunk],
|
29
|
+
json_schema: typing.Dict[str, typing.Optional[typing.Any]],
|
30
|
+
chunk_messages: typing.Optional[typing.Sequence[PromptMessage]] = OMIT,
|
31
|
+
reduce: typing.Optional[bool] = OMIT,
|
32
|
+
reduce_messages: typing.Optional[typing.Sequence[PromptMessage]] = OMIT,
|
33
|
+
request_options: typing.Optional[RequestOptions] = None,
|
34
|
+
) -> HttpResponse[StructuredDataExtractorResponse]:
|
35
|
+
"""
|
36
|
+
Extract structured data.
|
37
|
+
|
38
|
+
tl;dr:
|
39
|
+
- pass a valid JSON schema in `json_schema`
|
40
|
+
- pass the page chunks as a list of `Chunk` objects, by default: `{"type": "text", "content": "..."}`
|
41
|
+
- leave all other fields as default
|
42
|
+
|
43
|
+
Detailed configuration (only relevant for complex use cases):
|
44
|
+
|
45
|
+
The structured data extractor's architecture follows the map-reduce pattern,
|
46
|
+
where the asset is divided into chunks, the schema is extracted from each chunk,
|
47
|
+
and the chunks are then reduced to a single structured data object.
|
48
|
+
|
49
|
+
In some applications, you may not want to:
|
50
|
+
|
51
|
+
- map (if your input asset is small enough)
|
52
|
+
- reduce (if your output object is large enough that it will overflow the output length;
|
53
|
+
if you're extracting a long list of entities; if youre )
|
54
|
+
to extract all instances of the schema).
|
55
|
+
|
56
|
+
You can configure these behaviors with the `map` and `reduce` fields.
|
57
|
+
|
58
|
+
Parameters
|
59
|
+
----------
|
60
|
+
chunks : typing.Sequence[Chunk]
|
61
|
+
The chunks from which to extract structured data.
|
62
|
+
|
63
|
+
json_schema : typing.Dict[str, typing.Optional[typing.Any]]
|
64
|
+
The JSON schema to use for validation (version draft 2020-12). See the docs [here](https://json-schema.org/learn/getting-started-step-by-step).
|
65
|
+
|
66
|
+
chunk_messages : typing.Optional[typing.Sequence[PromptMessage]]
|
67
|
+
The prompt to use for the data extraction over *each individual chunk*. It must be a list of messages. The chunk content will be appended as a list of human messages.
|
68
|
+
|
69
|
+
reduce : typing.Optional[bool]
|
70
|
+
If `map`, whether to reduce the chunks to a single structured object (true) or return the full list (false). Use True unless you want to preserve duplicates from each page or expect the object to overflow the output context.
|
71
|
+
|
72
|
+
reduce_messages : typing.Optional[typing.Sequence[PromptMessage]]
|
73
|
+
The prompt to use for the reduce steps. It must be a list of messages. The two extraction attempts will be appended as a list of human messages.
|
74
|
+
|
75
|
+
request_options : typing.Optional[RequestOptions]
|
76
|
+
Request-specific configuration.
|
77
|
+
|
78
|
+
Returns
|
79
|
+
-------
|
80
|
+
HttpResponse[StructuredDataExtractorResponse]
|
81
|
+
Successful Response
|
82
|
+
"""
|
83
|
+
_response = self._client_wrapper.httpx_client.request(
|
84
|
+
"api/v0/tools/structured-data-extractor/invoke",
|
85
|
+
method="POST",
|
86
|
+
json={
|
87
|
+
"chunk_messages": convert_and_respect_annotation_metadata(
|
88
|
+
object_=chunk_messages, annotation=typing.Sequence[PromptMessage], direction="write"
|
89
|
+
),
|
90
|
+
"chunks": convert_and_respect_annotation_metadata(
|
91
|
+
object_=chunks, annotation=typing.Sequence[Chunk], direction="write"
|
92
|
+
),
|
93
|
+
"json_schema": json_schema,
|
94
|
+
"reduce": reduce,
|
95
|
+
"reduce_messages": convert_and_respect_annotation_metadata(
|
96
|
+
object_=reduce_messages, annotation=typing.Sequence[PromptMessage], direction="write"
|
97
|
+
),
|
98
|
+
},
|
99
|
+
headers={
|
100
|
+
"content-type": "application/json",
|
101
|
+
},
|
102
|
+
request_options=request_options,
|
103
|
+
omit=OMIT,
|
104
|
+
)
|
105
|
+
try:
|
106
|
+
if 200 <= _response.status_code < 300:
|
107
|
+
_data = typing.cast(
|
108
|
+
StructuredDataExtractorResponse,
|
109
|
+
parse_obj_as(
|
110
|
+
type_=StructuredDataExtractorResponse, # type: ignore
|
111
|
+
object_=_response.json(),
|
112
|
+
),
|
113
|
+
)
|
114
|
+
return HttpResponse(response=_response, data=_data)
|
115
|
+
if _response.status_code == 422:
|
116
|
+
raise UnprocessableEntityError(
|
117
|
+
headers=dict(_response.headers),
|
118
|
+
body=typing.cast(
|
119
|
+
typing.Optional[typing.Any],
|
120
|
+
parse_obj_as(
|
121
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
122
|
+
object_=_response.json(),
|
123
|
+
),
|
124
|
+
),
|
125
|
+
)
|
126
|
+
_response_json = _response.json()
|
127
|
+
except JSONDecodeError:
|
128
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
129
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
130
|
+
|
131
|
+
|
132
|
+
class AsyncRawStructuredDataExtractorClient:
|
133
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
134
|
+
self._client_wrapper = client_wrapper
|
135
|
+
|
136
|
+
async def invoke(
|
137
|
+
self,
|
138
|
+
*,
|
139
|
+
chunks: typing.Sequence[Chunk],
|
140
|
+
json_schema: typing.Dict[str, typing.Optional[typing.Any]],
|
141
|
+
chunk_messages: typing.Optional[typing.Sequence[PromptMessage]] = OMIT,
|
142
|
+
reduce: typing.Optional[bool] = OMIT,
|
143
|
+
reduce_messages: typing.Optional[typing.Sequence[PromptMessage]] = OMIT,
|
144
|
+
request_options: typing.Optional[RequestOptions] = None,
|
145
|
+
) -> AsyncHttpResponse[StructuredDataExtractorResponse]:
|
146
|
+
"""
|
147
|
+
Extract structured data.
|
148
|
+
|
149
|
+
tl;dr:
|
150
|
+
- pass a valid JSON schema in `json_schema`
|
151
|
+
- pass the page chunks as a list of `Chunk` objects, by default: `{"type": "text", "content": "..."}`
|
152
|
+
- leave all other fields as default
|
153
|
+
|
154
|
+
Detailed configuration (only relevant for complex use cases):
|
155
|
+
|
156
|
+
The structured data extractor's architecture follows the map-reduce pattern,
|
157
|
+
where the asset is divided into chunks, the schema is extracted from each chunk,
|
158
|
+
and the chunks are then reduced to a single structured data object.
|
159
|
+
|
160
|
+
In some applications, you may not want to:
|
161
|
+
|
162
|
+
- map (if your input asset is small enough)
|
163
|
+
- reduce (if your output object is large enough that it will overflow the output length;
|
164
|
+
if you're extracting a long list of entities; if youre )
|
165
|
+
to extract all instances of the schema).
|
166
|
+
|
167
|
+
You can configure these behaviors with the `map` and `reduce` fields.
|
168
|
+
|
169
|
+
Parameters
|
170
|
+
----------
|
171
|
+
chunks : typing.Sequence[Chunk]
|
172
|
+
The chunks from which to extract structured data.
|
173
|
+
|
174
|
+
json_schema : typing.Dict[str, typing.Optional[typing.Any]]
|
175
|
+
The JSON schema to use for validation (version draft 2020-12). See the docs [here](https://json-schema.org/learn/getting-started-step-by-step).
|
176
|
+
|
177
|
+
chunk_messages : typing.Optional[typing.Sequence[PromptMessage]]
|
178
|
+
The prompt to use for the data extraction over *each individual chunk*. It must be a list of messages. The chunk content will be appended as a list of human messages.
|
179
|
+
|
180
|
+
reduce : typing.Optional[bool]
|
181
|
+
If `map`, whether to reduce the chunks to a single structured object (true) or return the full list (false). Use True unless you want to preserve duplicates from each page or expect the object to overflow the output context.
|
182
|
+
|
183
|
+
reduce_messages : typing.Optional[typing.Sequence[PromptMessage]]
|
184
|
+
The prompt to use for the reduce steps. It must be a list of messages. The two extraction attempts will be appended as a list of human messages.
|
185
|
+
|
186
|
+
request_options : typing.Optional[RequestOptions]
|
187
|
+
Request-specific configuration.
|
188
|
+
|
189
|
+
Returns
|
190
|
+
-------
|
191
|
+
AsyncHttpResponse[StructuredDataExtractorResponse]
|
192
|
+
Successful Response
|
193
|
+
"""
|
194
|
+
_response = await self._client_wrapper.httpx_client.request(
|
195
|
+
"api/v0/tools/structured-data-extractor/invoke",
|
196
|
+
method="POST",
|
197
|
+
json={
|
198
|
+
"chunk_messages": convert_and_respect_annotation_metadata(
|
199
|
+
object_=chunk_messages, annotation=typing.Sequence[PromptMessage], direction="write"
|
200
|
+
),
|
201
|
+
"chunks": convert_and_respect_annotation_metadata(
|
202
|
+
object_=chunks, annotation=typing.Sequence[Chunk], direction="write"
|
203
|
+
),
|
204
|
+
"json_schema": json_schema,
|
205
|
+
"reduce": reduce,
|
206
|
+
"reduce_messages": convert_and_respect_annotation_metadata(
|
207
|
+
object_=reduce_messages, annotation=typing.Sequence[PromptMessage], direction="write"
|
208
|
+
),
|
209
|
+
},
|
210
|
+
headers={
|
211
|
+
"content-type": "application/json",
|
212
|
+
},
|
213
|
+
request_options=request_options,
|
214
|
+
omit=OMIT,
|
215
|
+
)
|
216
|
+
try:
|
217
|
+
if 200 <= _response.status_code < 300:
|
218
|
+
_data = typing.cast(
|
219
|
+
StructuredDataExtractorResponse,
|
220
|
+
parse_obj_as(
|
221
|
+
type_=StructuredDataExtractorResponse, # type: ignore
|
222
|
+
object_=_response.json(),
|
223
|
+
),
|
224
|
+
)
|
225
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
226
|
+
if _response.status_code == 422:
|
227
|
+
raise UnprocessableEntityError(
|
228
|
+
headers=dict(_response.headers),
|
229
|
+
body=typing.cast(
|
230
|
+
typing.Optional[typing.Any],
|
231
|
+
parse_obj_as(
|
232
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
233
|
+
object_=_response.json(),
|
234
|
+
),
|
235
|
+
),
|
236
|
+
)
|
237
|
+
_response_json = _response.json()
|
238
|
+
except JSONDecodeError:
|
239
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
240
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
athena/tools/tasks/__init__.py
CHANGED
athena/tools/tasks/client.py
CHANGED
@@ -1,17 +1,26 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
|
-
from ...core.client_wrapper import SyncClientWrapper
|
4
3
|
import typing
|
4
|
+
|
5
|
+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
5
6
|
from ...core.request_options import RequestOptions
|
6
|
-
from
|
7
|
-
from json.decoder import JSONDecodeError
|
8
|
-
from ...core.api_error import ApiError
|
9
|
-
from ...core.client_wrapper import AsyncClientWrapper
|
7
|
+
from .raw_client import AsyncRawTasksClient, RawTasksClient
|
10
8
|
|
11
9
|
|
12
10
|
class TasksClient:
|
13
11
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
14
|
-
self.
|
12
|
+
self._raw_client = RawTasksClient(client_wrapper=client_wrapper)
|
13
|
+
|
14
|
+
@property
|
15
|
+
def with_raw_response(self) -> RawTasksClient:
|
16
|
+
"""
|
17
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
18
|
+
|
19
|
+
Returns
|
20
|
+
-------
|
21
|
+
RawTasksClient
|
22
|
+
"""
|
23
|
+
return self._raw_client
|
15
24
|
|
16
25
|
def run_task(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Optional[typing.Any]:
|
17
26
|
"""
|
@@ -36,29 +45,24 @@ class TasksClient:
|
|
36
45
|
)
|
37
46
|
client.tools.tasks.run_task()
|
38
47
|
"""
|
39
|
-
_response = self.
|
40
|
-
|
41
|
-
method="POST",
|
42
|
-
request_options=request_options,
|
43
|
-
)
|
44
|
-
try:
|
45
|
-
if 200 <= _response.status_code < 300:
|
46
|
-
return typing.cast(
|
47
|
-
typing.Optional[typing.Any],
|
48
|
-
parse_obj_as(
|
49
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
50
|
-
object_=_response.json(),
|
51
|
-
),
|
52
|
-
)
|
53
|
-
_response_json = _response.json()
|
54
|
-
except JSONDecodeError:
|
55
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
56
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
48
|
+
_response = self._raw_client.run_task(request_options=request_options)
|
49
|
+
return _response.data
|
57
50
|
|
58
51
|
|
59
52
|
class AsyncTasksClient:
|
60
53
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
61
|
-
self.
|
54
|
+
self._raw_client = AsyncRawTasksClient(client_wrapper=client_wrapper)
|
55
|
+
|
56
|
+
@property
|
57
|
+
def with_raw_response(self) -> AsyncRawTasksClient:
|
58
|
+
"""
|
59
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
60
|
+
|
61
|
+
Returns
|
62
|
+
-------
|
63
|
+
AsyncRawTasksClient
|
64
|
+
"""
|
65
|
+
return self._raw_client
|
62
66
|
|
63
67
|
async def run_task(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Optional[typing.Any]:
|
64
68
|
"""
|
@@ -91,21 +95,5 @@ class AsyncTasksClient:
|
|
91
95
|
|
92
96
|
asyncio.run(main())
|
93
97
|
"""
|
94
|
-
_response = await self.
|
95
|
-
|
96
|
-
method="POST",
|
97
|
-
request_options=request_options,
|
98
|
-
)
|
99
|
-
try:
|
100
|
-
if 200 <= _response.status_code < 300:
|
101
|
-
return typing.cast(
|
102
|
-
typing.Optional[typing.Any],
|
103
|
-
parse_obj_as(
|
104
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
105
|
-
object_=_response.json(),
|
106
|
-
),
|
107
|
-
)
|
108
|
-
_response_json = _response.json()
|
109
|
-
except JSONDecodeError:
|
110
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
111
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
98
|
+
_response = await self._raw_client.run_task(request_options=request_options)
|
99
|
+
return _response.data
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import typing
|
4
|
+
from json.decoder import JSONDecodeError
|
5
|
+
|
6
|
+
from ...core.api_error import ApiError
|
7
|
+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
8
|
+
from ...core.http_response import AsyncHttpResponse, HttpResponse
|
9
|
+
from ...core.pydantic_utilities import parse_obj_as
|
10
|
+
from ...core.request_options import RequestOptions
|
11
|
+
|
12
|
+
|
13
|
+
class RawTasksClient:
|
14
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
15
|
+
self._client_wrapper = client_wrapper
|
16
|
+
|
17
|
+
def run_task(
|
18
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
19
|
+
) -> HttpResponse[typing.Optional[typing.Any]]:
|
20
|
+
"""
|
21
|
+
Coming soon! Run a [task](https://resources.athenaintel.com/docs/task-studio/home).
|
22
|
+
|
23
|
+
Parameters
|
24
|
+
----------
|
25
|
+
request_options : typing.Optional[RequestOptions]
|
26
|
+
Request-specific configuration.
|
27
|
+
|
28
|
+
Returns
|
29
|
+
-------
|
30
|
+
HttpResponse[typing.Optional[typing.Any]]
|
31
|
+
Successful Response
|
32
|
+
"""
|
33
|
+
_response = self._client_wrapper.httpx_client.request(
|
34
|
+
"api/v0/tools/tasks/run",
|
35
|
+
method="POST",
|
36
|
+
request_options=request_options,
|
37
|
+
)
|
38
|
+
try:
|
39
|
+
if _response is None or not _response.text.strip():
|
40
|
+
return HttpResponse(response=_response, data=None)
|
41
|
+
if 200 <= _response.status_code < 300:
|
42
|
+
_data = typing.cast(
|
43
|
+
typing.Optional[typing.Any],
|
44
|
+
parse_obj_as(
|
45
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
46
|
+
object_=_response.json(),
|
47
|
+
),
|
48
|
+
)
|
49
|
+
return HttpResponse(response=_response, data=_data)
|
50
|
+
_response_json = _response.json()
|
51
|
+
except JSONDecodeError:
|
52
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
53
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
54
|
+
|
55
|
+
|
56
|
+
class AsyncRawTasksClient:
|
57
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
58
|
+
self._client_wrapper = client_wrapper
|
59
|
+
|
60
|
+
async def run_task(
|
61
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
62
|
+
) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
|
63
|
+
"""
|
64
|
+
Coming soon! Run a [task](https://resources.athenaintel.com/docs/task-studio/home).
|
65
|
+
|
66
|
+
Parameters
|
67
|
+
----------
|
68
|
+
request_options : typing.Optional[RequestOptions]
|
69
|
+
Request-specific configuration.
|
70
|
+
|
71
|
+
Returns
|
72
|
+
-------
|
73
|
+
AsyncHttpResponse[typing.Optional[typing.Any]]
|
74
|
+
Successful Response
|
75
|
+
"""
|
76
|
+
_response = await self._client_wrapper.httpx_client.request(
|
77
|
+
"api/v0/tools/tasks/run",
|
78
|
+
method="POST",
|
79
|
+
request_options=request_options,
|
80
|
+
)
|
81
|
+
try:
|
82
|
+
if _response is None or not _response.text.strip():
|
83
|
+
return AsyncHttpResponse(response=_response, data=None)
|
84
|
+
if 200 <= _response.status_code < 300:
|
85
|
+
_data = typing.cast(
|
86
|
+
typing.Optional[typing.Any],
|
87
|
+
parse_obj_as(
|
88
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
89
|
+
object_=_response.json(),
|
90
|
+
),
|
91
|
+
)
|
92
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
93
|
+
_response_json = _response.json()
|
94
|
+
except JSONDecodeError:
|
95
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
96
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|