Skip to main content

Athena Intelligence Python Library

Project description

Athena Intelligence Python Library

fern shield pypi

The Athena Intelligence Python Library provides convenient access to the Athena Intelligence API from applications written in Python.

The library includes type definitions for all request and response fields, and offers both synchronous and asynchronous clients powered by httpx.

Installation

Add this dependency to your project's build file:

pip install athena-intelligence
# or
poetry add athena-intelligence

Usage

Simply import Athena and start making calls to our API.

from athena.client import Athena
from athena import Model, Tools

client = Athena(
  api_key="YOUR_API_KEY" # Defaults to ATHENA_API_KEY
)
message = client.message.submit(
    content="visit www.athenaintelligence.ai and summarize the website in one paragraph",
    model=Model.GPT_3_5_TURBO,
    tools=[Tools.SEARCH, Tools.BROWSE, Tools.SEARCH],
)

Async Client

The SDK also exports an async client so that you can make non-blocking calls to our API.

from athena.client import AsyncAthena
from athena import Model, Tools

client = AsyncAthena(
  api_key="YOUR_API_KEY" # Defaults to ATHENA_API_KEY
)

async def main() -> None:
    message = client.message.submit(
      content="visit www.athenaintelligence.ai and summarize the website in one paragraph",
      model=Model.GPT_3_5_TURBO,
      tools=[Tools.SEARCH, Tools.BROWSE, Tools.SEARCH],
    )
    print("Received message", message)

asyncio.run(main())

Polling

The SDK provides helper functions that will automatically poll when retrieving a message. Use the submit_and_poll method as shown below:

from athena.client import Athena
from athena import Model, Tools

client = Athena(api_key="...")
message =  client.message.submit_and_poll(
  content="visit www.athenaintelligence.ai and summarize the website in one paragraph",
  model=Model.GPT_3_5_TURBO,
  tools=[Tools.SEARCH, Tools.BROWSE, Tools.SEARCH],
)

By default, the method will poll every 2 seconds but you can override this with the poll_interval argument.

Athena Module

All of the models are nested within the Athena module. Let IntelliSense guide you!

Exception Handling

All errors thrown by the SDK will be subclasses of ApiError.

import athena

try:
  client.messages.get(...)
except athena.core.ApiError as e: # Handle all errors
  print(e.status_code)
  print(e.body)

Advanced

Timeouts

By default, requests time out after 60 seconds. You can configure this with a timeout option at the client or request level.

from athena.client import Athena

client = Athena(
    # All timeouts are 20 seconds
    timeout=20.0,
)

# Override timeout for a specific method
client.messages.get(..., {
    timeout_in_seconds=20
})

Custom HTTP client

You can override the httpx client to customize it for your use-case. Some common use-cases include support for proxies and transports.

import httpx

from athena.client import Athena

client = Athena(
    http_client=httpx.Client(
        proxies="http://my.test.proxy.example.com",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    ),
)

Beta Status

This SDK is in Preview, and there may be breaking changes between versions without a major version update.

To ensure a reproducible environment (and minimize risk of breaking changes), we recommend pinning a specific package version.

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

athena_intelligence-0.1.95.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

athena_intelligence-0.1.95-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file athena_intelligence-0.1.95.tar.gz.

File metadata

  • Download URL: athena_intelligence-0.1.95.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/5.15.0-1074-azure

File hashes

Hashes for athena_intelligence-0.1.95.tar.gz
Algorithm Hash digest
SHA256 b67c8f3579b32a4fb9c2ea96de8df6c1199a14e7fc497a645b8fe9932a1dd574
MD5 bba516f7a4219aadbd4fc9afb35dbda9
BLAKE2b-256 2c0a7fb3dc062f74f34162bca43e2d870ee42155a6d6efb344df53282cb48524

See more details on using hashes here.

File details

Details for the file athena_intelligence-0.1.95-py3-none-any.whl.

File metadata

File hashes

Hashes for athena_intelligence-0.1.95-py3-none-any.whl
Algorithm Hash digest
SHA256 82e864568b785192301757e938d4ccc358ec7bc5933651bfe1831ac525bb1bf2
MD5 7aca496ba5eb66852c4a66fbb08b2900
BLAKE2b-256 fa0aeb77691e5dba276e0eac4d4ec931e2784884c1c902e04ad05e75cc56d9da

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page