Aurelio Platform SDK
Project description
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:
# timeout -1 means no timeout
response_pdf_file: ExtractResponse = client.extract_file(
file=file, quality="low", chunk=True, timeout=-1
)
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:
# timeout -1 means no timeout
response_video_file: ExtractResponse = client.extract_file(
file=file, quality="low", chunk=True, timeout=-1
)
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, timeout=-1
)
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, timeout=-1
)
Handling Timeouts and Checking Document Status
# 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, timeout=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_completion(
document_id=response_pdf_file.document.id, timeout=300
)
Embeddings
from aurelio_sdk import EmbeddingResponse
response: EmbeddingResponse = client.embedding(input="Your text here to be embedded")
# 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 taskusage
: Information about token usage, pages processed, and processing timemessage
: Any relevant messages about the extraction processdocument
: The extracted document information, including its IDchunks
: 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 processmodel
: The model name used for embeddingusage
: Information about token usage, pages processed, and processing timedata
: The embedded documents
Best Practices
- Use appropriate timeouts based on your use case and file sizes.
- Use async client for better performance.
- For large files or when processing might take longer, use the
wait_for_document_completion
method to avoid long-hanging requests. - Always handle potential exceptions and check the status of the response.
- Adjust the
quality
parameter based on your needs. "low" is faster but less accurate, while "high" is slower but more accurate.
Support
For any issues or questions, please contact Aurelio support or refer to the official documentation.
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
Built Distribution
File details
Details for the file aurelio_sdk-0.0.3.tar.gz
.
File metadata
- Download URL: aurelio_sdk-0.0.3.tar.gz
- Upload date:
- Size: 8.8 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9bf36646201dba211df7bf563825fb4c60c4a39241625f0f838a48a641e126b |
|
MD5 | 982a05fc118519ec77521fe050a85f7f |
|
BLAKE2b-256 | 45d05ec8febd6702070556a393bc28524dbd631113e4f05dec146bf9dd014a36 |
File details
Details for the file aurelio_sdk-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: aurelio_sdk-0.0.3-py3-none-any.whl
- Upload date:
- Size: 10.4 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e6bfd38defd2cfac656fafe8693e588b2ed6dca13c37079afd3cc0cd08ba950 |
|
MD5 | 85a3a71bfc6bbb3a85392583c84db2dc |
|
BLAKE2b-256 | 1ca6785591fd51efa53bbc9a3758811a6e28492d1532140a39b15fce9bf03aa5 |