athena-intelligence 0.1.87__tar.gz → 0.1.89__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.
Files changed (93) hide show
  1. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/PKG-INFO +1 -1
  2. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/pyproject.toml +3 -2
  3. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/base_client.py +4 -4
  4. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/chain/client.py +30 -138
  5. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/client.py +126 -23
  6. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/core/client_wrapper.py +13 -3
  7. athena_intelligence-0.1.89/src/athena/core/http_client.py +443 -0
  8. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/core/remove_none_from_dict.py +2 -2
  9. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/dataset/client.py +8 -64
  10. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/message/client.py +20 -113
  11. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/query/client.py +8 -54
  12. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/report/client.py +10 -66
  13. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/search/client.py +22 -68
  14. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/snippet/client.py +10 -116
  15. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/tools/client.py +112 -542
  16. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/upload/client.py +2 -58
  17. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/workflow/client.py +8 -54
  18. athena_intelligence-0.1.87/src/athena/core/http_client.py +0 -130
  19. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/README.md +0 -0
  20. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/__init__.py +0 -0
  21. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/chain/__init__.py +0 -0
  22. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/core/__init__.py +0 -0
  23. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/core/api_error.py +0 -0
  24. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/core/datetime_utils.py +0 -0
  25. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/core/file.py +0 -0
  26. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/core/jsonable_encoder.py +0 -0
  27. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/core/pydantic_utilities.py +0 -0
  28. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/core/query_encoder.py +0 -0
  29. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/core/request_options.py +0 -0
  30. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/dataset/__init__.py +0 -0
  31. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/environment.py +0 -0
  32. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/errors/__init__.py +0 -0
  33. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/errors/internal_server_error.py +0 -0
  34. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/errors/not_found_error.py +0 -0
  35. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/errors/unprocessable_entity_error.py +0 -0
  36. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/errors/unsupported_media_type_error.py +0 -0
  37. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/message/__init__.py +0 -0
  38. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/polling_message_client.py +0 -0
  39. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/py.typed +0 -0
  40. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/query/__init__.py +0 -0
  41. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/report/__init__.py +0 -0
  42. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/search/__init__.py +0 -0
  43. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/snippet/__init__.py +0 -0
  44. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/tools/__init__.py +0 -0
  45. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/tools/types/__init__.py +0 -0
  46. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/tools/types/tools_data_frame_request_columns_item.py +0 -0
  47. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/__init__.py +0 -0
  48. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/athena_document_v_2_out.py +0 -0
  49. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/convert_pdf_to_sheet_out.py +0 -0
  50. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/data_frame_parsing_error.py +0 -0
  51. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/data_frame_request_out.py +0 -0
  52. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/data_frame_request_out_columns_item.py +0 -0
  53. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/data_frame_request_out_data_item_item.py +0 -0
  54. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/data_frame_request_out_index_item.py +0 -0
  55. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/data_frame_unknown_format_error.py +0 -0
  56. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/dataset.py +0 -0
  57. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/document.py +0 -0
  58. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/excecute_tool_first_workflow_out.py +0 -0
  59. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/file_data_response.py +0 -0
  60. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/file_fetch_error.py +0 -0
  61. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/filter_model.py +0 -0
  62. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/filter_operator.py +0 -0
  63. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/firecrawl_scrape_url_data_reponse_dto.py +0 -0
  64. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/firecrawl_scrape_url_metadata.py +0 -0
  65. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/get_datasets_response.py +0 -0
  66. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/get_snippet_out.py +0 -0
  67. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/get_snippets_response.py +0 -0
  68. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/http_validation_error.py +0 -0
  69. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/langchain_documents_request_out.py +0 -0
  70. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/llm_model.py +0 -0
  71. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/map_reduce_chain_out.py +0 -0
  72. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/message_out.py +0 -0
  73. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/message_out_dto.py +0 -0
  74. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/model.py +0 -0
  75. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/publish_formats.py +0 -0
  76. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/query_model.py +0 -0
  77. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/report.py +0 -0
  78. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/researcher_out.py +0 -0
  79. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/semantic_query_out.py +0 -0
  80. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/snippet.py +0 -0
  81. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/sql_results.py +0 -0
  82. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/status_enum.py +0 -0
  83. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/structured_parse_result.py +0 -0
  84. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/time_dimension_model.py +0 -0
  85. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/tools.py +0 -0
  86. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/upload_documents_out.py +0 -0
  87. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/url_result.py +0 -0
  88. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/validation_error.py +0 -0
  89. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/validation_error_loc_item.py +0 -0
  90. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/types/workflow_status_out.py +0 -0
  91. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/upload/__init__.py +0 -0
  92. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/version.py +0 -0
  93. {athena_intelligence-0.1.87 → athena_intelligence-0.1.89}/src/athena/workflow/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: athena-intelligence
3
- Version: 0.1.87
3
+ Version: 0.1.89
4
4
  Summary: Athena Intelligence Python Library
5
5
  Requires-Python: >=3.8,<4.0
6
6
  Classifier: Intended Audience :: Developers
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "athena-intelligence"
3
- version = "0.1.87"
3
+ version = "0.1.89"
4
4
  description = "Athena Intelligence Python Library"
5
5
  readme = "README.md"
6
6
  authors = []
@@ -40,10 +40,11 @@ python-magic = "0.4.27"
40
40
  typing_extensions = ">= 4.0.0"
41
41
 
42
42
  [tool.poetry.dev-dependencies]
43
- mypy = "1.9.0"
43
+ mypy = "1.0.1"
44
44
  pytest = "^7.4.0"
45
45
  pytest-asyncio = "^0.23.5"
46
46
  python-dateutil = "^2.9.0"
47
+ types-python-dateutil = "^2.9.0.20240316"
47
48
  pandas = ">= 1.5.3"
48
49
  pandas-stubs = ">= 1.5.3"
49
50
 
@@ -20,7 +20,7 @@ from .workflow.client import AsyncWorkflowClient, WorkflowClient
20
20
 
21
21
  class BaseAthena:
22
22
  """
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.
23
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
24
24
 
25
25
  Parameters
26
26
  ----------
@@ -38,7 +38,7 @@ class BaseAthena:
38
38
 
39
39
  api_key : str
40
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.
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 this default is not enforced.
42
42
 
43
43
  follow_redirects : typing.Optional[bool]
44
44
  Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
@@ -90,7 +90,7 @@ class BaseAthena:
90
90
 
91
91
  class AsyncBaseAthena:
92
92
  """
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.
93
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
94
94
 
95
95
  Parameters
96
96
  ----------
@@ -108,7 +108,7 @@ class AsyncBaseAthena:
108
108
 
109
109
  api_key : str
110
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.
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 this default is not enforced.
112
112
 
113
113
  follow_redirects : typing.Optional[bool]
114
114
  Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
@@ -1,15 +1,11 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  import typing
4
- import urllib.parse
5
4
  from json.decoder import JSONDecodeError
6
5
 
7
6
  from ..core.api_error import ApiError
8
7
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
- from ..core.jsonable_encoder import jsonable_encoder
10
8
  from ..core.pydantic_utilities import pydantic_v1
11
- from ..core.query_encoder import encode_query
12
- from ..core.remove_none_from_dict import remove_none_from_dict
13
9
  from ..core.request_options import RequestOptions
14
10
  from ..errors.unprocessable_entity_error import UnprocessableEntityError
15
11
  from ..types.document import Document
@@ -32,7 +28,7 @@ class ChainClient:
32
28
  text_input: str,
33
29
  custom_type_dict: typing.Dict[str, typing.Any],
34
30
  model: LlmModel,
35
- request_options: typing.Optional[RequestOptions] = None,
31
+ request_options: typing.Optional[RequestOptions] = None
36
32
  ) -> StructuredParseResult:
37
33
  """
38
34
  Parameters
@@ -68,32 +64,11 @@ class ChainClient:
68
64
  )
69
65
  """
70
66
  _response = self._client_wrapper.httpx_client.request(
67
+ "api/v0/structured-parse",
71
68
  method="POST",
72
- url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/structured-parse"),
73
- params=encode_query(
74
- jsonable_encoder(
75
- request_options.get("additional_query_parameters") if request_options is not None else None
76
- )
77
- ),
78
- json=jsonable_encoder({"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model})
79
- if request_options is None or request_options.get("additional_body_parameters") is None
80
- else {
81
- **jsonable_encoder({"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model}),
82
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
83
- },
84
- headers=jsonable_encoder(
85
- remove_none_from_dict(
86
- {
87
- **self._client_wrapper.get_headers(),
88
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
89
- }
90
- )
91
- ),
92
- timeout=request_options.get("timeout_in_seconds")
93
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
94
- else self._client_wrapper.get_timeout(),
95
- retries=0,
96
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
69
+ json={"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model},
70
+ request_options=request_options,
71
+ omit=OMIT,
97
72
  )
98
73
  if 200 <= _response.status_code < 300:
99
74
  return pydantic_v1.parse_obj_as(StructuredParseResult, _response.json()) # type: ignore
@@ -115,7 +90,7 @@ class ChainClient:
115
90
  operator_prompt: str,
116
91
  reducer_prompt: str,
117
92
  input: str,
118
- request_options: typing.Optional[RequestOptions] = None,
93
+ request_options: typing.Optional[RequestOptions] = None
119
94
  ) -> MapReduceChainOut:
120
95
  """
121
96
  Parameters
@@ -160,48 +135,17 @@ class ChainClient:
160
135
  )
161
136
  """
162
137
  _response = self._client_wrapper.httpx_client.request(
138
+ "api/v0/tools/map-reduce",
163
139
  method="POST",
164
- url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/map-reduce"),
165
- params=encode_query(
166
- jsonable_encoder(
167
- request_options.get("additional_query_parameters") if request_options is not None else None
168
- )
169
- ),
170
- json=jsonable_encoder(
171
- {
172
- "documents": documents,
173
- "model": model,
174
- "operator_prompt": operator_prompt,
175
- "reducer_prompt": reducer_prompt,
176
- "input": input,
177
- }
178
- )
179
- if request_options is None or request_options.get("additional_body_parameters") is None
180
- else {
181
- **jsonable_encoder(
182
- {
183
- "documents": documents,
184
- "model": model,
185
- "operator_prompt": operator_prompt,
186
- "reducer_prompt": reducer_prompt,
187
- "input": input,
188
- }
189
- ),
190
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
140
+ json={
141
+ "documents": documents,
142
+ "model": model,
143
+ "operator_prompt": operator_prompt,
144
+ "reducer_prompt": reducer_prompt,
145
+ "input": input,
191
146
  },
192
- headers=jsonable_encoder(
193
- remove_none_from_dict(
194
- {
195
- **self._client_wrapper.get_headers(),
196
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
197
- }
198
- )
199
- ),
200
- timeout=request_options.get("timeout_in_seconds")
201
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
202
- else self._client_wrapper.get_timeout(),
203
- retries=0,
204
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
147
+ request_options=request_options,
148
+ omit=OMIT,
205
149
  )
206
150
  if 200 <= _response.status_code < 300:
207
151
  return pydantic_v1.parse_obj_as(MapReduceChainOut, _response.json()) # type: ignore
@@ -226,7 +170,7 @@ class AsyncChainClient:
226
170
  text_input: str,
227
171
  custom_type_dict: typing.Dict[str, typing.Any],
228
172
  model: LlmModel,
229
- request_options: typing.Optional[RequestOptions] = None,
173
+ request_options: typing.Optional[RequestOptions] = None
230
174
  ) -> StructuredParseResult:
231
175
  """
232
176
  Parameters
@@ -262,32 +206,11 @@ class AsyncChainClient:
262
206
  )
263
207
  """
264
208
  _response = await self._client_wrapper.httpx_client.request(
209
+ "api/v0/structured-parse",
265
210
  method="POST",
266
- url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/structured-parse"),
267
- params=encode_query(
268
- jsonable_encoder(
269
- request_options.get("additional_query_parameters") if request_options is not None else None
270
- )
271
- ),
272
- json=jsonable_encoder({"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model})
273
- if request_options is None or request_options.get("additional_body_parameters") is None
274
- else {
275
- **jsonable_encoder({"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model}),
276
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
277
- },
278
- headers=jsonable_encoder(
279
- remove_none_from_dict(
280
- {
281
- **self._client_wrapper.get_headers(),
282
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
283
- }
284
- )
285
- ),
286
- timeout=request_options.get("timeout_in_seconds")
287
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
288
- else self._client_wrapper.get_timeout(),
289
- retries=0,
290
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
211
+ json={"text_input": text_input, "custom_type_dict": custom_type_dict, "model": model},
212
+ request_options=request_options,
213
+ omit=OMIT,
291
214
  )
292
215
  if 200 <= _response.status_code < 300:
293
216
  return pydantic_v1.parse_obj_as(StructuredParseResult, _response.json()) # type: ignore
@@ -309,7 +232,7 @@ class AsyncChainClient:
309
232
  operator_prompt: str,
310
233
  reducer_prompt: str,
311
234
  input: str,
312
- request_options: typing.Optional[RequestOptions] = None,
235
+ request_options: typing.Optional[RequestOptions] = None
313
236
  ) -> MapReduceChainOut:
314
237
  """
315
238
  Parameters
@@ -354,48 +277,17 @@ class AsyncChainClient:
354
277
  )
355
278
  """
356
279
  _response = await self._client_wrapper.httpx_client.request(
280
+ "api/v0/tools/map-reduce",
357
281
  method="POST",
358
- url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/map-reduce"),
359
- params=encode_query(
360
- jsonable_encoder(
361
- request_options.get("additional_query_parameters") if request_options is not None else None
362
- )
363
- ),
364
- json=jsonable_encoder(
365
- {
366
- "documents": documents,
367
- "model": model,
368
- "operator_prompt": operator_prompt,
369
- "reducer_prompt": reducer_prompt,
370
- "input": input,
371
- }
372
- )
373
- if request_options is None or request_options.get("additional_body_parameters") is None
374
- else {
375
- **jsonable_encoder(
376
- {
377
- "documents": documents,
378
- "model": model,
379
- "operator_prompt": operator_prompt,
380
- "reducer_prompt": reducer_prompt,
381
- "input": input,
382
- }
383
- ),
384
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
282
+ json={
283
+ "documents": documents,
284
+ "model": model,
285
+ "operator_prompt": operator_prompt,
286
+ "reducer_prompt": reducer_prompt,
287
+ "input": input,
385
288
  },
386
- headers=jsonable_encoder(
387
- remove_none_from_dict(
388
- {
389
- **self._client_wrapper.get_headers(),
390
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
391
- }
392
- )
393
- ),
394
- timeout=request_options.get("timeout_in_seconds")
395
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
396
- else self._client_wrapper.get_timeout(),
397
- retries=0,
398
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
289
+ request_options=request_options,
290
+ omit=OMIT,
399
291
  )
400
292
  if 200 <= _response.status_code < 300:
401
293
  return pydantic_v1.parse_obj_as(MapReduceChainOut, _response.json()) # type: ignore
@@ -1,4 +1,5 @@
1
1
  import io
2
+ import os
2
3
  import typing
3
4
  import warnings
4
5
 
@@ -20,42 +21,103 @@ T = TypeVar("T")
20
21
  U = TypeVar('U')
21
22
 
22
23
 
23
- def _inherit_signature(f: typing.Callable[P, T]) -> typing.Callable[..., typing.Callable[P, U]]:
24
- return lambda x: x
24
+ def _inherit_signature_and_doc(
25
+ f: typing.Callable[P, T],
26
+ replace_in_doc: typing.Dict[str, str]
27
+ ) -> typing.Callable[..., typing.Callable[P, U]]:
28
+ def decorator(decorated):
29
+ for old, new in replace_in_doc.items():
30
+ assert old in f.__doc__
31
+ decorated.__doc__ = f.__doc__.replace(old, new)
32
+ return decorated
33
+ return decorator
25
34
 
26
35
 
27
36
  class WrappedToolsClient(ToolsClient):
28
37
 
29
38
  def get_file(self, document_id: str) -> io.BytesIO:
39
+ """
40
+ Parameters
41
+ ----------
42
+ document_id : str
43
+
44
+ Returns
45
+ -------
46
+ io.BytesIO
47
+
48
+ Examples
49
+ --------
50
+ import polars as pl
51
+ from athena.client import Athena
52
+
53
+ client = Athena(api_key="YOUR_API_KEY")
54
+ file_io = client.tools.get_file(document_id="document_id")
55
+ pl.read_csv(file_io)
56
+ """
30
57
  file_bytes = b''.join(self.raw_data(document_id=document_id))
31
58
  bytes_io = io.BytesIO(file_bytes)
32
59
  return bytes_io
33
60
 
34
- @_inherit_signature(ToolsClient.data_frame)
61
+ @_inherit_signature_and_doc(ToolsClient.data_frame, {'DataFrameRequestOut': 'pd.DataFrame'})
35
62
  def data_frame(self, *, document_id: str, **kwargs) -> 'pd.DataFrame':
36
63
  _check_pandas_installed()
37
64
  model = super().data_frame(document_id=document_id, **kwargs)
38
65
  return _read_json_frame(model)
39
66
 
40
67
  def read_data_frame(self, document_id: str, *args, **kwargs) -> 'pd.DataFrame':
68
+ """
69
+ Parameters
70
+ ----------
71
+ document_id : str
72
+
73
+ **kwargs : dict
74
+ keyword arguments passed to pandas `read_csv` or `read_excel` function,
75
+ depending on the file type of the document identified by `document_id`.
76
+
77
+ Returns
78
+ -------
79
+ pd.DataFrame
80
+
81
+ Examples
82
+ --------
83
+ from athena.client import Athena
84
+
85
+ client = Athena(api_key="YOUR_API_KEY")
86
+ client.tools.read_data_frame(document_id="document_id")
87
+ """
41
88
  _check_pandas_installed()
42
89
  file_bytes = self.get_file(document_id)
43
90
  return _to_pandas_df(file_bytes, *args, **kwargs)
44
91
 
45
92
 
93
+ def _add_docs_for_async_variant(obj):
94
+ def decorator(decorated):
95
+ doc = obj.__doc__
96
+ name = obj.__name__
97
+ decorated.__doc__ = (
98
+ doc
99
+ .replace('client = Athena', 'client = AsyncAthena')
100
+ .replace(f'client.tools.{name}', f'await client.tools.{name}')
101
+ )
102
+ return decorated
103
+ return decorator
104
+
105
+
46
106
  class WrappedAsyncToolsClient(AsyncToolsClient):
47
107
 
108
+ @_add_docs_for_async_variant(WrappedToolsClient.get_file)
48
109
  async def get_file(self, document_id: str) -> io.BytesIO:
49
110
  file_bytes = b''.join([gen async for gen in self.raw_data(document_id=document_id)])
50
111
  bytes_io = io.BytesIO(file_bytes)
51
112
  return bytes_io
52
113
 
53
- @_inherit_signature(ToolsClient.data_frame)
114
+ @_inherit_signature_and_doc(AsyncToolsClient.data_frame, {'DataFrameRequestOut': 'pd.DataFrame'})
54
115
  async def data_frame(self, *, document_id: str, **kwargs) -> 'pd.DataFrame':
55
116
  _check_pandas_installed()
56
117
  model = await super().data_frame(document_id=document_id, **kwargs)
57
118
  return _read_json_frame(model)
58
119
 
120
+ @_add_docs_for_async_variant(WrappedToolsClient.read_data_frame)
59
121
  async def read_data_frame(self, document_id: str, *args, **kwargs) -> 'pd.DataFrame':
60
122
  _check_pandas_installed()
61
123
  file_bytes = await self.get_file(document_id)
@@ -66,19 +128,29 @@ class Athena(BaseAthena):
66
128
  """
67
129
  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.
68
130
 
69
- Parameters:
70
- - base_url: typing.Optional[str]. The base url to use for requests from the client.
131
+ Parameters
132
+ ----------
133
+ base_url : typing.Optional[str]
134
+ The base url to use for requests from the client.
135
+
136
+ environment : AthenaEnvironment
137
+ The environment to use for requests from the client. from .environment import AthenaEnvironment
71
138
 
72
- - environment: AthenaEnvironment. The environment to use for requests from the client. from .environment import AthenaEnvironment
73
139
 
74
- Defaults to AthenaEnvironment.DEFAULT
75
140
 
76
- - api_key: str.
141
+ Defaults to AthenaEnvironment.DEFAULT
77
142
 
78
- - timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds.
79
143
 
80
- - httpx_client: typing.Optional[httpx.Client]. 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.
81
- ---
144
+
145
+ api_key: typing.Optional[str]. The API key. Required when used outside of the athena notebook environment.
146
+ timeout : typing.Optional[float]
147
+ 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 this default is not enforced.
148
+
149
+ httpx_client : typing.Optional[httpx.Client]
150
+ 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.
151
+
152
+ Examples
153
+ --------
82
154
  from athena.client import Athena
83
155
 
84
156
  client = Athena(
@@ -86,15 +158,25 @@ class Athena(BaseAthena):
86
158
  )
87
159
  """
88
160
 
161
+ tools: WrappedToolsClient
162
+
89
163
  def __init__(
90
164
  self,
91
165
  *,
92
166
  base_url: typing.Optional[str] = None,
93
167
  environment: AthenaEnvironment = AthenaEnvironment.DEFAULT,
94
- api_key: str,
168
+ api_key: typing.Optional[str] = None,
95
169
  timeout: typing.Optional[float] = 60,
96
170
  httpx_client: typing.Optional[httpx.Client] = None
97
171
  ):
172
+ if api_key is None:
173
+ try:
174
+ api_key = os.environ['ATHENA_API_KEY']
175
+ except KeyError:
176
+ raise TypeError(
177
+ "Athena() missing 1 required keyword-only argument: 'api_key'"
178
+ ' (ATHENA_API_KEY environment variable not found)'
179
+ )
98
180
  super().__init__(
99
181
  base_url=base_url,
100
182
  environment=environment,
@@ -109,21 +191,32 @@ class Athena(BaseAthena):
109
191
 
110
192
  class AsyncAthena(AsyncBaseAthena):
111
193
  """
112
- 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.
194
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
195
+
196
+
197
+ Parameters
198
+ ----------
199
+ base_url : typing.Optional[str]
200
+ The base url to use for requests from the client.
201
+
202
+ environment : AthenaEnvironment
203
+ The environment to use for requests from the client. from .environment import AthenaEnvironment
113
204
 
114
- Parameters:
115
- - base_url: typing.Optional[str]. The base url to use for requests from the client.
116
205
 
117
- - environment: AthenaEnvironment. The environment to use for requests from the client. from .environment import AthenaEnvironment
118
206
 
119
- Defaults to AthenaEnvironment.DEFAULT
207
+ Defaults to AthenaEnvironment.DEFAULT
120
208
 
121
- - api_key: str.
122
209
 
123
- - timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds.
124
210
 
125
- - httpx_client: typing.Optional[httpx.AsyncClient]. 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.
126
- ---
211
+ api_key: typing.Optional[str]. The API key. Required when used outside of the athena notebook environment.
212
+ timeout : typing.Optional[float]
213
+ 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 this default is not enforced.
214
+
215
+ httpx_client : typing.Optional[httpx.AsyncClient]
216
+ 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.
217
+
218
+ Examples
219
+ --------
127
220
  from athena.client import AsyncAthena
128
221
 
129
222
  client = AsyncAthena(
@@ -131,15 +224,25 @@ class AsyncAthena(AsyncBaseAthena):
131
224
  )
132
225
  """
133
226
 
227
+ tools: WrappedAsyncToolsClient
228
+
134
229
  def __init__(
135
230
  self,
136
231
  *,
137
232
  base_url: typing.Optional[str] = None,
138
233
  environment: AthenaEnvironment = AthenaEnvironment.DEFAULT,
139
- api_key: str,
234
+ api_key: typing.Optional[str] = None,
140
235
  timeout: typing.Optional[float] = 60,
141
236
  httpx_client: typing.Optional[httpx.AsyncClient] = None
142
237
  ):
238
+ if api_key is None:
239
+ try:
240
+ api_key = os.environ['ATHENA_API_KEY']
241
+ except KeyError:
242
+ raise TypeError(
243
+ "AsyncAthena() missing 1 required keyword-only argument: 'api_key'"
244
+ ' (ATHENA_API_KEY environment variable not found)'
245
+ )
143
246
  super().__init__(
144
247
  base_url=base_url,
145
248
  environment=environment,
@@ -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.87",
20
+ "X-Fern-SDK-Version": "0.1.89",
21
21
  }
22
22
  headers["X-API-KEY"] = self.api_key
23
23
  return headers
@@ -34,7 +34,12 @@ class SyncClientWrapper(BaseClientWrapper):
34
34
  self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.Client
35
35
  ):
36
36
  super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
37
- self.httpx_client = HttpClient(httpx_client=httpx_client)
37
+ self.httpx_client = HttpClient(
38
+ httpx_client=httpx_client,
39
+ base_headers=self.get_headers(),
40
+ base_timeout=self.get_timeout(),
41
+ base_url=self.get_base_url(),
42
+ )
38
43
 
39
44
 
40
45
  class AsyncClientWrapper(BaseClientWrapper):
@@ -42,4 +47,9 @@ class AsyncClientWrapper(BaseClientWrapper):
42
47
  self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient
43
48
  ):
44
49
  super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
45
- self.httpx_client = AsyncHttpClient(httpx_client=httpx_client)
50
+ self.httpx_client = AsyncHttpClient(
51
+ httpx_client=httpx_client,
52
+ base_headers=self.get_headers(),
53
+ base_timeout=self.get_timeout(),
54
+ base_url=self.get_base_url(),
55
+ )