athena-intelligence 0.1.6__py3-none-any.whl → 0.1.8__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 CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  from .types import HttpValidationError, MessageOut, MessageOutDto, Model, Tools, ValidationError, ValidationErrorLocItem
4
4
  from .errors import UnprocessableEntityError
5
+ from .resources import message
5
6
  from .environment import AthenaEnvironment
6
7
 
7
8
  __all__ = [
@@ -14,4 +15,5 @@ __all__ = [
14
15
  "UnprocessableEntityError",
15
16
  "ValidationError",
16
17
  "ValidationErrorLocItem",
18
+ "message",
17
19
  ]
athena/client.py CHANGED
@@ -1,31 +1,12 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  import typing
4
- import urllib.parse
5
- from json.decoder import JSONDecodeError
6
4
 
7
5
  import httpx
8
6
 
9
- from .core.api_error import ApiError
10
7
  from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
11
- from .core.jsonable_encoder import jsonable_encoder
12
- from .core.remove_none_from_dict import remove_none_from_dict
13
- from .core.request_options import RequestOptions
14
8
  from .environment import AthenaEnvironment
15
- from .errors.unprocessable_entity_error import UnprocessableEntityError
16
- from .types.http_validation_error import HttpValidationError
17
- from .types.message_out import MessageOut
18
- from .types.message_out_dto import MessageOutDto
19
- from .types.model import Model
20
- from .types.tools import Tools
21
-
22
- try:
23
- import pydantic.v1 as pydantic # type: ignore
24
- except ImportError:
25
- import pydantic # type: ignore
26
-
27
- # this is used as the default value for optional parameters
28
- OMIT = typing.cast(typing.Any, ...)
9
+ from .resources.message.client import AsyncMessageClient, MessageClient
29
10
 
30
11
 
31
12
  class Athena:
@@ -41,7 +22,7 @@ class Athena:
41
22
 
42
23
  - api_key: str.
43
24
 
44
- - token: typing.Optional[typing.Union[str, typing.Callable[[], str]]].
25
+ - token: typing.Union[str, typing.Callable[[], str]].
45
26
 
46
27
  - timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds.
47
28
 
@@ -61,9 +42,9 @@ class Athena:
61
42
  base_url: typing.Optional[str] = None,
62
43
  environment: AthenaEnvironment = AthenaEnvironment.DEFAULT,
63
44
  api_key: str,
64
- token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
45
+ token: typing.Union[str, typing.Callable[[], str]],
65
46
  timeout: typing.Optional[float] = 60,
66
- httpx_client: typing.Optional[httpx.Client] = None,
47
+ httpx_client: typing.Optional[httpx.Client] = None
67
48
  ):
68
49
  self._client_wrapper = SyncClientWrapper(
69
50
  base_url=_get_base_url(base_url=base_url, environment=environment),
@@ -71,171 +52,7 @@ class Athena:
71
52
  token=token,
72
53
  httpx_client=httpx.Client(timeout=timeout) if httpx_client is None else httpx_client,
73
54
  )
74
-
75
- def post_message(
76
- self,
77
- *,
78
- content: str,
79
- model: typing.Optional[Model] = OMIT,
80
- tools: typing.Optional[typing.Sequence[Tools]] = OMIT,
81
- conversation_id: typing.Optional[str] = OMIT,
82
- conversation_name: typing.Optional[str] = OMIT,
83
- request_options: typing.Optional[RequestOptions] = None,
84
- ) -> MessageOut:
85
- """
86
- Parameters:
87
- - content: str.
88
-
89
- - model: typing.Optional[Model].
90
-
91
- - tools: typing.Optional[typing.Sequence[Tools]].
92
-
93
- - conversation_id: typing.Optional[str].
94
-
95
- - conversation_name: typing.Optional[str].
96
-
97
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
98
- ---
99
- from athena.client import Athena
100
-
101
- client = Athena(
102
- api_key="YOUR_API_KEY",
103
- token="YOUR_TOKEN",
104
- )
105
- client.post_message(
106
- content="content",
107
- )
108
- """
109
- _request: typing.Dict[str, typing.Any] = {"content": content}
110
- if model is not OMIT:
111
- _request["model"] = model.value if model is not None else None
112
- if tools is not OMIT:
113
- _request["tools"] = tools
114
- if conversation_id is not OMIT:
115
- _request["conversation_id"] = conversation_id
116
- if conversation_name is not OMIT:
117
- _request["conversation_name"] = conversation_name
118
- _response = self._client_wrapper.httpx_client.request(
119
- "POST",
120
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/message"),
121
- params=jsonable_encoder(
122
- request_options.get("additional_query_parameters") if request_options is not None else None
123
- ),
124
- json=jsonable_encoder(_request)
125
- if request_options is None or request_options.get("additional_body_parameters") is None
126
- else {
127
- **jsonable_encoder(_request),
128
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
129
- },
130
- headers=jsonable_encoder(
131
- remove_none_from_dict(
132
- {
133
- **self._client_wrapper.get_headers(),
134
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
135
- }
136
- )
137
- ),
138
- timeout=request_options.get("timeout_in_seconds")
139
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
140
- else 60,
141
- )
142
- if 200 <= _response.status_code < 300:
143
- return pydantic.parse_obj_as(MessageOut, _response.json()) # type: ignore
144
- if _response.status_code == 422:
145
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
146
- try:
147
- _response_json = _response.json()
148
- except JSONDecodeError:
149
- raise ApiError(status_code=_response.status_code, body=_response.text)
150
- raise ApiError(status_code=_response.status_code, body=_response_json)
151
-
152
- def athena_get_message(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> MessageOutDto:
153
- """
154
- Parameters:
155
- - id: str.
156
-
157
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
158
- ---
159
- from athena.client import Athena
160
-
161
- client = Athena(
162
- api_key="YOUR_API_KEY",
163
- token="YOUR_TOKEN",
164
- )
165
- client.athena_get_message(
166
- id="id",
167
- )
168
- """
169
- _response = self._client_wrapper.httpx_client.request(
170
- "GET",
171
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v0/message/{jsonable_encoder(id)}"),
172
- params=jsonable_encoder(
173
- request_options.get("additional_query_parameters") if request_options is not None else None
174
- ),
175
- headers=jsonable_encoder(
176
- remove_none_from_dict(
177
- {
178
- **self._client_wrapper.get_headers(),
179
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
180
- }
181
- )
182
- ),
183
- timeout=request_options.get("timeout_in_seconds")
184
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
185
- else 60,
186
- )
187
- if 200 <= _response.status_code < 300:
188
- return pydantic.parse_obj_as(MessageOutDto, _response.json()) # type: ignore
189
- if _response.status_code == 422:
190
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
191
- try:
192
- _response_json = _response.json()
193
- except JSONDecodeError:
194
- raise ApiError(status_code=_response.status_code, body=_response.text)
195
- raise ApiError(status_code=_response.status_code, body=_response_json)
196
-
197
- def health_check(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
198
- """
199
- Checks the health of a project.
200
-
201
- It returns 200 if the project is healthy.
202
-
203
- Parameters:
204
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
205
- ---
206
- from athena.client import Athena
207
-
208
- client = Athena(
209
- api_key="YOUR_API_KEY",
210
- token="YOUR_TOKEN",
211
- )
212
- client.health_check()
213
- """
214
- _response = self._client_wrapper.httpx_client.request(
215
- "GET",
216
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/health"),
217
- params=jsonable_encoder(
218
- request_options.get("additional_query_parameters") if request_options is not None else None
219
- ),
220
- headers=jsonable_encoder(
221
- remove_none_from_dict(
222
- {
223
- **self._client_wrapper.get_headers(),
224
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
225
- }
226
- )
227
- ),
228
- timeout=request_options.get("timeout_in_seconds")
229
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
230
- else 60,
231
- )
232
- if 200 <= _response.status_code < 300:
233
- return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
234
- try:
235
- _response_json = _response.json()
236
- except JSONDecodeError:
237
- raise ApiError(status_code=_response.status_code, body=_response.text)
238
- raise ApiError(status_code=_response.status_code, body=_response_json)
55
+ self.message = MessageClient(client_wrapper=self._client_wrapper)
239
56
 
240
57
 
241
58
  class AsyncAthena:
@@ -251,7 +68,7 @@ class AsyncAthena:
251
68
 
252
69
  - api_key: str.
253
70
 
254
- - token: typing.Optional[typing.Union[str, typing.Callable[[], str]]].
71
+ - token: typing.Union[str, typing.Callable[[], str]].
255
72
 
256
73
  - timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds.
257
74
 
@@ -271,9 +88,9 @@ class AsyncAthena:
271
88
  base_url: typing.Optional[str] = None,
272
89
  environment: AthenaEnvironment = AthenaEnvironment.DEFAULT,
273
90
  api_key: str,
274
- token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
91
+ token: typing.Union[str, typing.Callable[[], str]],
275
92
  timeout: typing.Optional[float] = 60,
276
- httpx_client: typing.Optional[httpx.AsyncClient] = None,
93
+ httpx_client: typing.Optional[httpx.AsyncClient] = None
277
94
  ):
278
95
  self._client_wrapper = AsyncClientWrapper(
279
96
  base_url=_get_base_url(base_url=base_url, environment=environment),
@@ -281,173 +98,7 @@ class AsyncAthena:
281
98
  token=token,
282
99
  httpx_client=httpx.AsyncClient(timeout=timeout) if httpx_client is None else httpx_client,
283
100
  )
284
-
285
- async def post_message(
286
- self,
287
- *,
288
- content: str,
289
- model: typing.Optional[Model] = OMIT,
290
- tools: typing.Optional[typing.Sequence[Tools]] = OMIT,
291
- conversation_id: typing.Optional[str] = OMIT,
292
- conversation_name: typing.Optional[str] = OMIT,
293
- request_options: typing.Optional[RequestOptions] = None,
294
- ) -> MessageOut:
295
- """
296
- Parameters:
297
- - content: str.
298
-
299
- - model: typing.Optional[Model].
300
-
301
- - tools: typing.Optional[typing.Sequence[Tools]].
302
-
303
- - conversation_id: typing.Optional[str].
304
-
305
- - conversation_name: typing.Optional[str].
306
-
307
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
308
- ---
309
- from athena.client import AsyncAthena
310
-
311
- client = AsyncAthena(
312
- api_key="YOUR_API_KEY",
313
- token="YOUR_TOKEN",
314
- )
315
- await client.post_message(
316
- content="content",
317
- )
318
- """
319
- _request: typing.Dict[str, typing.Any] = {"content": content}
320
- if model is not OMIT:
321
- _request["model"] = model.value if model is not None else None
322
- if tools is not OMIT:
323
- _request["tools"] = tools
324
- if conversation_id is not OMIT:
325
- _request["conversation_id"] = conversation_id
326
- if conversation_name is not OMIT:
327
- _request["conversation_name"] = conversation_name
328
- _response = await self._client_wrapper.httpx_client.request(
329
- "POST",
330
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/message"),
331
- params=jsonable_encoder(
332
- request_options.get("additional_query_parameters") if request_options is not None else None
333
- ),
334
- json=jsonable_encoder(_request)
335
- if request_options is None or request_options.get("additional_body_parameters") is None
336
- else {
337
- **jsonable_encoder(_request),
338
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
339
- },
340
- headers=jsonable_encoder(
341
- remove_none_from_dict(
342
- {
343
- **self._client_wrapper.get_headers(),
344
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
345
- }
346
- )
347
- ),
348
- timeout=request_options.get("timeout_in_seconds")
349
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
350
- else 60,
351
- )
352
- if 200 <= _response.status_code < 300:
353
- return pydantic.parse_obj_as(MessageOut, _response.json()) # type: ignore
354
- if _response.status_code == 422:
355
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
356
- try:
357
- _response_json = _response.json()
358
- except JSONDecodeError:
359
- raise ApiError(status_code=_response.status_code, body=_response.text)
360
- raise ApiError(status_code=_response.status_code, body=_response_json)
361
-
362
- async def athena_get_message(
363
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
364
- ) -> MessageOutDto:
365
- """
366
- Parameters:
367
- - id: str.
368
-
369
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
370
- ---
371
- from athena.client import AsyncAthena
372
-
373
- client = AsyncAthena(
374
- api_key="YOUR_API_KEY",
375
- token="YOUR_TOKEN",
376
- )
377
- await client.athena_get_message(
378
- id="id",
379
- )
380
- """
381
- _response = await self._client_wrapper.httpx_client.request(
382
- "GET",
383
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v0/message/{jsonable_encoder(id)}"),
384
- params=jsonable_encoder(
385
- request_options.get("additional_query_parameters") if request_options is not None else None
386
- ),
387
- headers=jsonable_encoder(
388
- remove_none_from_dict(
389
- {
390
- **self._client_wrapper.get_headers(),
391
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
392
- }
393
- )
394
- ),
395
- timeout=request_options.get("timeout_in_seconds")
396
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
397
- else 60,
398
- )
399
- if 200 <= _response.status_code < 300:
400
- return pydantic.parse_obj_as(MessageOutDto, _response.json()) # type: ignore
401
- if _response.status_code == 422:
402
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
403
- try:
404
- _response_json = _response.json()
405
- except JSONDecodeError:
406
- raise ApiError(status_code=_response.status_code, body=_response.text)
407
- raise ApiError(status_code=_response.status_code, body=_response_json)
408
-
409
- async def health_check(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
410
- """
411
- Checks the health of a project.
412
-
413
- It returns 200 if the project is healthy.
414
-
415
- Parameters:
416
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
417
- ---
418
- from athena.client import AsyncAthena
419
-
420
- client = AsyncAthena(
421
- api_key="YOUR_API_KEY",
422
- token="YOUR_TOKEN",
423
- )
424
- await client.health_check()
425
- """
426
- _response = await self._client_wrapper.httpx_client.request(
427
- "GET",
428
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/health"),
429
- params=jsonable_encoder(
430
- request_options.get("additional_query_parameters") if request_options is not None else None
431
- ),
432
- headers=jsonable_encoder(
433
- remove_none_from_dict(
434
- {
435
- **self._client_wrapper.get_headers(),
436
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
437
- }
438
- )
439
- ),
440
- timeout=request_options.get("timeout_in_seconds")
441
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
442
- else 60,
443
- )
444
- if 200 <= _response.status_code < 300:
445
- return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
446
- try:
447
- _response_json = _response.json()
448
- except JSONDecodeError:
449
- raise ApiError(status_code=_response.status_code, body=_response.text)
450
- raise ApiError(status_code=_response.status_code, body=_response_json)
101
+ self.message = AsyncMessageClient(client_wrapper=self._client_wrapper)
451
102
 
452
103
 
453
104
  def _get_base_url(*, base_url: typing.Optional[str] = None, environment: AthenaEnvironment) -> str:
@@ -6,9 +6,7 @@ import httpx
6
6
 
7
7
 
8
8
  class BaseClientWrapper:
9
- def __init__(
10
- self, *, api_key: str, token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, base_url: str
11
- ):
9
+ def __init__(self, *, api_key: str, token: typing.Union[str, typing.Callable[[], str]], base_url: str):
12
10
  self._api_key = api_key
13
11
  self._token = token
14
12
  self._base_url = base_url
@@ -17,16 +15,14 @@ class BaseClientWrapper:
17
15
  headers: typing.Dict[str, str] = {
18
16
  "X-Fern-Language": "Python",
19
17
  "X-Fern-SDK-Name": "athena-intelligence",
20
- "X-Fern-SDK-Version": "0.1.6",
18
+ "X-Fern-SDK-Version": "0.1.8",
21
19
  }
22
20
  headers["X-API-KEY"] = self._api_key
23
- token = self._get_token()
24
- if token is not None:
25
- headers["Authorization"] = f"Bearer {token}"
21
+ headers["Authorization"] = f"Bearer {self._get_token()}"
26
22
  return headers
27
23
 
28
- def _get_token(self) -> typing.Optional[str]:
29
- if isinstance(self._token, str) or self._token is None:
24
+ def _get_token(self) -> str:
25
+ if isinstance(self._token, str):
30
26
  return self._token
31
27
  else:
32
28
  return self._token()
@@ -40,7 +36,7 @@ class SyncClientWrapper(BaseClientWrapper):
40
36
  self,
41
37
  *,
42
38
  api_key: str,
43
- token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
39
+ token: typing.Union[str, typing.Callable[[], str]],
44
40
  base_url: str,
45
41
  httpx_client: httpx.Client,
46
42
  ):
@@ -53,7 +49,7 @@ class AsyncClientWrapper(BaseClientWrapper):
53
49
  self,
54
50
  *,
55
51
  api_key: str,
56
- token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
52
+ token: typing.Union[str, typing.Callable[[], str]],
57
53
  base_url: str,
58
54
  httpx_client: httpx.AsyncClient,
59
55
  ):
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from . import message
4
+
5
+ __all__ = ["message"]
@@ -0,0 +1,2 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
@@ -0,0 +1,285 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ import urllib.parse
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from ...core.api_error import ApiError
8
+ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from ...core.jsonable_encoder import jsonable_encoder
10
+ from ...core.remove_none_from_dict import remove_none_from_dict
11
+ from ...core.request_options import RequestOptions
12
+ from ...errors.unprocessable_entity_error import UnprocessableEntityError
13
+ from ...types.http_validation_error import HttpValidationError
14
+ from ...types.message_out import MessageOut
15
+ from ...types.message_out_dto import MessageOutDto
16
+ from ...types.model import Model
17
+ from ...types.tools import Tools
18
+
19
+ try:
20
+ import pydantic.v1 as pydantic # type: ignore
21
+ except ImportError:
22
+ import pydantic # type: ignore
23
+
24
+ # this is used as the default value for optional parameters
25
+ OMIT = typing.cast(typing.Any, ...)
26
+
27
+
28
+ class MessageClient:
29
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
30
+ self._client_wrapper = client_wrapper
31
+
32
+ def submit(
33
+ self,
34
+ *,
35
+ content: str,
36
+ model: typing.Optional[Model] = OMIT,
37
+ tools: typing.Optional[typing.Sequence[Tools]] = OMIT,
38
+ conversation_id: typing.Optional[str] = OMIT,
39
+ conversation_name: typing.Optional[str] = OMIT,
40
+ request_options: typing.Optional[RequestOptions] = None,
41
+ ) -> MessageOut:
42
+ """
43
+ Parameters:
44
+ - content: str.
45
+
46
+ - model: typing.Optional[Model].
47
+
48
+ - tools: typing.Optional[typing.Sequence[Tools]].
49
+
50
+ - conversation_id: typing.Optional[str].
51
+
52
+ - conversation_name: typing.Optional[str].
53
+
54
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
55
+ ---
56
+ from athena import Model, Tools
57
+ from athena.client import Athena
58
+
59
+ client = Athena(
60
+ api_key="YOUR_API_KEY",
61
+ token="YOUR_TOKEN",
62
+ )
63
+ client.message.submit(
64
+ content="visit www.athenaintelligence.ai and summarize the website in one paragraph",
65
+ model=Model.GPT_4_TURBO_PREVIEW,
66
+ tools=[Tools.SEARCH, Tools.BROWSE, Tools.SEARCH],
67
+ )
68
+ """
69
+ _request: typing.Dict[str, typing.Any] = {"content": content}
70
+ if model is not OMIT:
71
+ _request["model"] = model.value if model is not None else None
72
+ if tools is not OMIT:
73
+ _request["tools"] = tools
74
+ if conversation_id is not OMIT:
75
+ _request["conversation_id"] = conversation_id
76
+ if conversation_name is not OMIT:
77
+ _request["conversation_name"] = conversation_name
78
+ _response = self._client_wrapper.httpx_client.request(
79
+ "POST",
80
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/message"),
81
+ params=jsonable_encoder(
82
+ request_options.get("additional_query_parameters") if request_options is not None else None
83
+ ),
84
+ json=jsonable_encoder(_request)
85
+ if request_options is None or request_options.get("additional_body_parameters") is None
86
+ else {
87
+ **jsonable_encoder(_request),
88
+ **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
89
+ },
90
+ headers=jsonable_encoder(
91
+ remove_none_from_dict(
92
+ {
93
+ **self._client_wrapper.get_headers(),
94
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
95
+ }
96
+ )
97
+ ),
98
+ timeout=request_options.get("timeout_in_seconds")
99
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
100
+ else 60,
101
+ )
102
+ if 200 <= _response.status_code < 300:
103
+ return pydantic.parse_obj_as(MessageOut, _response.json()) # type: ignore
104
+ if _response.status_code == 422:
105
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
106
+ try:
107
+ _response_json = _response.json()
108
+ except JSONDecodeError:
109
+ raise ApiError(status_code=_response.status_code, body=_response.text)
110
+ raise ApiError(status_code=_response.status_code, body=_response_json)
111
+
112
+ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> MessageOutDto:
113
+ """
114
+ Parameters:
115
+ - id: str.
116
+
117
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
118
+ ---
119
+ from athena.client import Athena
120
+
121
+ client = Athena(
122
+ api_key="YOUR_API_KEY",
123
+ token="YOUR_TOKEN",
124
+ )
125
+ client.message.get(
126
+ id="id",
127
+ )
128
+ """
129
+ _response = self._client_wrapper.httpx_client.request(
130
+ "GET",
131
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v0/message/{jsonable_encoder(id)}"),
132
+ params=jsonable_encoder(
133
+ request_options.get("additional_query_parameters") if request_options is not None else None
134
+ ),
135
+ headers=jsonable_encoder(
136
+ remove_none_from_dict(
137
+ {
138
+ **self._client_wrapper.get_headers(),
139
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
140
+ }
141
+ )
142
+ ),
143
+ timeout=request_options.get("timeout_in_seconds")
144
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
145
+ else 60,
146
+ )
147
+ if 200 <= _response.status_code < 300:
148
+ return pydantic.parse_obj_as(MessageOutDto, _response.json()) # type: ignore
149
+ if _response.status_code == 422:
150
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
151
+ try:
152
+ _response_json = _response.json()
153
+ except JSONDecodeError:
154
+ raise ApiError(status_code=_response.status_code, body=_response.text)
155
+ raise ApiError(status_code=_response.status_code, body=_response_json)
156
+
157
+
158
+ class AsyncMessageClient:
159
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
160
+ self._client_wrapper = client_wrapper
161
+
162
+ async def submit(
163
+ self,
164
+ *,
165
+ content: str,
166
+ model: typing.Optional[Model] = OMIT,
167
+ tools: typing.Optional[typing.Sequence[Tools]] = OMIT,
168
+ conversation_id: typing.Optional[str] = OMIT,
169
+ conversation_name: typing.Optional[str] = OMIT,
170
+ request_options: typing.Optional[RequestOptions] = None,
171
+ ) -> MessageOut:
172
+ """
173
+ Parameters:
174
+ - content: str.
175
+
176
+ - model: typing.Optional[Model].
177
+
178
+ - tools: typing.Optional[typing.Sequence[Tools]].
179
+
180
+ - conversation_id: typing.Optional[str].
181
+
182
+ - conversation_name: typing.Optional[str].
183
+
184
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
185
+ ---
186
+ from athena import Model, Tools
187
+ from athena.client import AsyncAthena
188
+
189
+ client = AsyncAthena(
190
+ api_key="YOUR_API_KEY",
191
+ token="YOUR_TOKEN",
192
+ )
193
+ await client.message.submit(
194
+ content="visit www.athenaintelligence.ai and summarize the website in one paragraph",
195
+ model=Model.GPT_4_TURBO_PREVIEW,
196
+ tools=[Tools.SEARCH, Tools.BROWSE, Tools.SEARCH],
197
+ )
198
+ """
199
+ _request: typing.Dict[str, typing.Any] = {"content": content}
200
+ if model is not OMIT:
201
+ _request["model"] = model.value if model is not None else None
202
+ if tools is not OMIT:
203
+ _request["tools"] = tools
204
+ if conversation_id is not OMIT:
205
+ _request["conversation_id"] = conversation_id
206
+ if conversation_name is not OMIT:
207
+ _request["conversation_name"] = conversation_name
208
+ _response = await self._client_wrapper.httpx_client.request(
209
+ "POST",
210
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/message"),
211
+ params=jsonable_encoder(
212
+ request_options.get("additional_query_parameters") if request_options is not None else None
213
+ ),
214
+ json=jsonable_encoder(_request)
215
+ if request_options is None or request_options.get("additional_body_parameters") is None
216
+ else {
217
+ **jsonable_encoder(_request),
218
+ **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
219
+ },
220
+ headers=jsonable_encoder(
221
+ remove_none_from_dict(
222
+ {
223
+ **self._client_wrapper.get_headers(),
224
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
225
+ }
226
+ )
227
+ ),
228
+ timeout=request_options.get("timeout_in_seconds")
229
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
230
+ else 60,
231
+ )
232
+ if 200 <= _response.status_code < 300:
233
+ return pydantic.parse_obj_as(MessageOut, _response.json()) # type: ignore
234
+ if _response.status_code == 422:
235
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
236
+ try:
237
+ _response_json = _response.json()
238
+ except JSONDecodeError:
239
+ raise ApiError(status_code=_response.status_code, body=_response.text)
240
+ raise ApiError(status_code=_response.status_code, body=_response_json)
241
+
242
+ async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> MessageOutDto:
243
+ """
244
+ Parameters:
245
+ - id: str.
246
+
247
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
248
+ ---
249
+ from athena.client import AsyncAthena
250
+
251
+ client = AsyncAthena(
252
+ api_key="YOUR_API_KEY",
253
+ token="YOUR_TOKEN",
254
+ )
255
+ await client.message.get(
256
+ id="id",
257
+ )
258
+ """
259
+ _response = await self._client_wrapper.httpx_client.request(
260
+ "GET",
261
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v0/message/{jsonable_encoder(id)}"),
262
+ params=jsonable_encoder(
263
+ request_options.get("additional_query_parameters") if request_options is not None else None
264
+ ),
265
+ headers=jsonable_encoder(
266
+ remove_none_from_dict(
267
+ {
268
+ **self._client_wrapper.get_headers(),
269
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
270
+ }
271
+ )
272
+ ),
273
+ timeout=request_options.get("timeout_in_seconds")
274
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
275
+ else 60,
276
+ )
277
+ if 200 <= _response.status_code < 300:
278
+ return pydantic.parse_obj_as(MessageOutDto, _response.json()) # type: ignore
279
+ if _response.status_code == 422:
280
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
281
+ try:
282
+ _response_json = _response.json()
283
+ except JSONDecodeError:
284
+ raise ApiError(status_code=_response.status_code, body=_response.text)
285
+ raise ApiError(status_code=_response.status_code, body=_response_json)
athena/types/model.py CHANGED
@@ -11,19 +11,19 @@ class Model(str, enum.Enum):
11
11
  An enumeration.
12
12
  """
13
13
 
14
- GPT_4 = "gpt_4"
15
- GPT_4_TURBO_PREVIEW = "gpt_4_turbo_preview"
16
- GPT_3_5_TURBO = "gpt_3_5_turbo"
14
+ GPT_35_TURBO = "gpt-3.5-turbo"
15
+ GPT_4_TURBO_PREVIEW = "gpt-4-turbo-preview"
16
+ MIXTRAL_SMALL_8_X_7_B_0211 = "mixtral-small-8x7b-0211"
17
17
 
18
18
  def visit(
19
19
  self,
20
- gpt_4: typing.Callable[[], T_Result],
20
+ gpt_35_turbo: typing.Callable[[], T_Result],
21
21
  gpt_4_turbo_preview: typing.Callable[[], T_Result],
22
- gpt_3_5_turbo: typing.Callable[[], T_Result],
22
+ mixtral_small_8_x_7_b_0211: typing.Callable[[], T_Result],
23
23
  ) -> T_Result:
24
- if self is Model.GPT_4:
25
- return gpt_4()
24
+ if self is Model.GPT_35_TURBO:
25
+ return gpt_35_turbo()
26
26
  if self is Model.GPT_4_TURBO_PREVIEW:
27
27
  return gpt_4_turbo_preview()
28
- if self is Model.GPT_3_5_TURBO:
29
- return gpt_3_5_turbo()
28
+ if self is Model.MIXTRAL_SMALL_8_X_7_B_0211:
29
+ return mixtral_small_8_x_7_b_0211()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: athena-intelligence
3
- Version: 0.1.6
3
+ Version: 0.1.8
4
4
  Summary:
5
5
  Requires-Python: >=3.8,<4.0
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,8 +1,8 @@
1
- athena/__init__.py,sha256=S4TY2NjQ19rPwYCWsw8-Cxrr51PjtSN2pma_ybgaUtQ,491
2
- athena/client.py,sha256=WXN18ACRosd3qN1d94NgM-78FUulVbdlerOwDnU5k6Q,18835
1
+ athena/__init__.py,sha256=7MO7cM1Jgw7XSF7MQwokJ4oeRy_uFCuFNqT4Kpn7KSQ,537
2
+ athena/client.py,sha256=ax_fRBUF-7c5-HAnEGJCz7eBDmk-Y6E_YGXWkmGcriI,4321
3
3
  athena/core/__init__.py,sha256=95onSWXymaL0iV-nBsuKNgjh1LbsymAkRkx7POn1nc0,696
4
4
  athena/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
5
- athena/core/client_wrapper.py,sha256=tSfOvOz_OP0344gd3EtzPmncGuzRczjYiP_Gpg97kzs,1810
5
+ athena/core/client_wrapper.py,sha256=KHNAQ7NxjY2OMX7f0KO9CMqdMEaSwZ6BtruNLbmsy64,1628
6
6
  athena/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
7
7
  athena/core/file.py,sha256=sy1RUGZ3aJYuw998bZytxxo6QdgKmlnlgBaMvwEKCGg,1480
8
8
  athena/core/jsonable_encoder.py,sha256=MTYkDov2EryHgee4QM46uZiBOuOXK9KTHlBdBwU-CpU,3799
@@ -12,14 +12,17 @@ athena/environment.py,sha256=D_CljQlUahhEi9smvMslj_5Y8gMFO6D0fRCL0ydRLuM,165
12
12
  athena/errors/__init__.py,sha256=pbbVUFtB9LCocA1RMWMMF_RKjsy5YkOKX5BAuE49w6g,170
13
13
  athena/errors/unprocessable_entity_error.py,sha256=FvR7XPlV3Xx5nu8HNlmLhBRdk4so_gCHjYT5PyZe6sM,313
14
14
  athena/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ athena/resources/__init__.py,sha256=H2Sg5QOlqjAbAl_ADBNYPqFArb-9plPdXDPVdeIkXDk,110
16
+ athena/resources/message/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
17
+ athena/resources/message/client.py,sha256=l0_IjdepvNGDeHT0kp6ivNQD13IiP2zwtCi9qjeBQAc,11892
15
18
  athena/types/__init__.py,sha256=sG74gyPktXegm01dMPmvxhq9um_3GdxMtF8kbSR9L4s,517
16
19
  athena/types/http_validation_error.py,sha256=Fcv_CTMMrLvCeTHjF0n5xf5tskMDgt-J6H9gp654eQw,973
17
20
  athena/types/message_out.py,sha256=uvZY_Podv2XccEk8CICug9I_S2hFJTSzCBwcHiauW7A,865
18
21
  athena/types/message_out_dto.py,sha256=GZ30Lk4PS0opAJS24cC_VfpPVZ87lFW171YH82_dEaQ,1008
19
- athena/types/model.py,sha256=SXpMQM_Dk-AIEbisBd4OGwLiqI1ePaDNEqXrs9ijuEY,732
22
+ athena/types/model.py,sha256=xyD4lk5YWZTzYQc6f76FUBOQe4_jTHSS8edSzOY5eQc,830
20
23
  athena/types/tools.py,sha256=Vfb-D9CYcPZH6MBATNODgfXjFyBpCs4qbkqpCMl7eBM,1277
21
24
  athena/types/validation_error.py,sha256=2JhGNJouo8QpfrMBoT_JCwYSn1nFN2Nnq0p9uPLDH-U,992
22
25
  athena/types/validation_error_loc_item.py,sha256=LAtjCHIllWRBFXvAZ5QZpp7CPXjdtN9EB7HrLVo6EP0,128
23
- athena_intelligence-0.1.6.dist-info/METADATA,sha256=L4IpOz-BUW715BoB_CQEvtUEBOQo19ewsn-ozfa0Ft8,3741
24
- athena_intelligence-0.1.6.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
25
- athena_intelligence-0.1.6.dist-info/RECORD,,
26
+ athena_intelligence-0.1.8.dist-info/METADATA,sha256=JXx4HB0DMfwE0IXPePJVChZhpnwKzC8bfc0g5r-uEx0,3741
27
+ athena_intelligence-0.1.8.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
28
+ athena_intelligence-0.1.8.dist-info/RECORD,,