Skip to main content

Aurelio Platform SDK

Project description

PyPI - Python Version GitHub Contributors GitHub Last Commit GitHub Repo Size GitHub Issues GitHub Pull Requests Github License

Aurelio SDK

The Aurelio Platform SDK. API references

Installation

To install the Aurelio SDK, use pip or poetry:

pip install aurelio-sdk

Authentication

The SDK requires an API key for authentication. Get key from Aurelio Platform. Set your API key as an environment variable:

export AURELIO_API_KEY=your_api_key_here

Usage

See examples for more details.

Initializing the Client

from aurelio_sdk import AurelioClient
import os

client = AurelioClient(api_key=os.environ["AURELIO_API_KEY"])

or use asynchronous client:

from aurelio_sdk import AsyncAurelioClient

client = AsyncAurelioClient(api_key="your_api_key_here")

Chunk

from aurelio_sdk import ChunkingOptions, ChunkResponse

# All options are optional with default values
chunking_options = ChunkingOptions(
    chunker_type="semantic", max_chunk_length=400, window_size=5
)

response: ChunkResponse = client.chunk(
    content="Your text here to be chunked", processing_options=chunking_options
)

Extracting Text from Files

PDF Files

from aurelio_sdk import ExtractResponse

# From a local file
file_path = "path/to/your/file.pdf"

with open(file_path, "rb") as file:
    response_pdf_file: ExtractResponse = client.extract_file(
        file=file, quality="low", chunk=True, wait=-1, enable_polling=True
    )

Video Files

from aurelio_sdk import ExtractResponse

# From a local file
file_path = "path/to/your/file.mp4"

with open(file_path, "rb") as file:
    response_video_file: ExtractResponse = client.extract_file(
        file=file, quality="low", chunk=True, wait=-1, enable_polling=True
    )

Extracting Text from URLs

PDF URLs

from aurelio_sdk import ExtractResponse

# From URL
url = "https://arxiv.org/pdf/2408.15291"
response_pdf_url: ExtractResponse = client.extract_url(
    url=url, quality="low", chunk=True, wait=-1, enable_polling=True
)

Video URLs

from aurelio_sdk import ExtractResponse

# From URL
url = "https://storage.googleapis.com/gtv-videos-bucket/sample/ForBiggerMeltdowns.mp4"
response_video_url: ExtractResponse = client.extract_url(
    url=url, quality="low", chunk=True, wait=-1, enable_polling=True
)

Waiting for completion and checking document atatus

# Set timeout for large files with `high` quality
# Timeout is set to 10 seconds
response_pdf_url: ExtractResponse = client.extract_url(
    url="https://arxiv.org/pdf/2408.15291", quality="high", chunk=True, wait=10
)

# Get document status and response
document_response: ExtractResponse = client.get_document(
    document_id=response_pdf_file.document.id
)
print("Status:", document_response.status)

# Use a pre-built function, which helps to avoid long hanging requests (Recommended)
document_response = client.wait_for(
    document_id=response_pdf_file.document.id, wait=300
)

Embeddings

from aurelio_sdk import EmbeddingResponse

response: EmbeddingResponse = client.embedding(
    input="Your text here to be embedded",
    model="bm25")

# Or with a list of texts
response: EmbeddingResponse = client.embedding(
    input=["Your text here to be embedded", "Your text here to be embedded"]
)

Response Structure

The ExtractResponse object contains the following key information:

  • status: The current status of the extraction task
  • usage: Information about token usage, pages processed, and processing time
  • message: Any relevant messages about the extraction process
  • document: The extracted document information, including its ID
  • chunks: The extracted text, divided into chunks if chunking was enabled

The EmbeddingResponse object contains the following key information:

  • message: Any relevant messages about the embedding process
  • model: The model name used for embedding
  • usage: Information about token usage, pages processed, and processing time
  • data: The embedded documents

Best Practices

  1. Use appropriate wait times based on your use case and file sizes.
  2. Use async client for better performance.
  3. For large files or when processing might take longer, enable polling for long-hanging requests.
  4. Always handle potential exceptions and check the status of the response.
  5. Adjust the quality parameter based on your needs. "low" is faster but less accurate, while "high" is slower but more accurate.

Project details


Download files

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

Source Distribution

aurelio_sdk-0.0.5.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

aurelio_sdk-0.0.5-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file aurelio_sdk-0.0.5.tar.gz.

File metadata

  • Download URL: aurelio_sdk-0.0.5.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.12.6 Linux/6.8.0-1014-azure

File hashes

Hashes for aurelio_sdk-0.0.5.tar.gz
Algorithm Hash digest
SHA256 25ea9f80a647c31dc0c33869b5a7247a9d545b94ed28fd68cc8e1476acfdfeb5
MD5 118273d500eb7959708fea2ecf2b4126
BLAKE2b-256 d8dbd74f65e2d0eee05b3098b97b459d3a2fe274c777e1b81f0b58a8986e6900

See more details on using hashes here.

File details

Details for the file aurelio_sdk-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: aurelio_sdk-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.12.6 Linux/6.8.0-1014-azure

File hashes

Hashes for aurelio_sdk-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 55c60a2fb378bdb744c7572475ac42c04b942388340209c94c537b131ff251fc
MD5 73b573ac674012fe6296ceff08e8909c
BLAKE2b-256 c99ba440d947bd3a4ab93e0f4eb746e285e859b780d11c54cd67fa43e90d00dd

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