Skip to main content

Adaptensor Python SDK

PyPI version Python 3.8+ License: MIT

Private Document AI Platform — Upload, index, and search your documents with AI. 100% self-hosted, no external APIs.

Features

  • 🔒 100% Private — Your data never leaves your infrastructure
  • ⚡ Fast Search — Sub-150ms semantic queries across thousands of documents
  • 📦 AdaptHex Compression — 4-8x smaller vectors with 99.6% accuracy
  • 🔌 Simple API — Upload, index, search in 3 lines of code
  • 🚀 TPU Accelerated — 25% cheaper than GPU clouds

Installation

pip install adaptensor

Quick Start

from adaptensor import Adaptensor

# Initialize client
client = Adaptensor(api_key="your-api-key")

# Upload documents
client.documents.upload("contract.pdf")
client.documents.upload("report.docx")

# Build search index
result = client.documents.index()
print(f"Indexed {result.total_chunks} chunks")

# Search
results = client.query("liability clauses", top_k=5)

for chunk in results:
    print(f"[{chunk.score:.2f}] {chunk.text[:100]}...")

Authentication

Set your API key via environment variable or pass directly:

# Environment variable
export ADAPTENSOR_API_KEY="your-api-key"
# Or pass directly
client = Adaptensor(api_key="your-api-key")

Upload Documents

Single File

doc = client.documents.upload("report.pdf")
print(f"Uploaded: {doc.doc_id} ({doc.size_bytes:,} bytes)")

Multiple Files

docs = client.documents.upload_many([
    "doc1.pdf",
    "doc2.pdf",
    "doc3.pdf"
], on_progress=lambda c, t, d: print(f"{c}/{t}: {d.filename}"))

Supported Formats

  • PDF (.pdf)
  • Word (.docx)
  • Text (.txt)
  • HTML (.html)
  • Markdown (.md)
  • CSV (.csv)

Build Index

After uploading documents, build the search index:

result = client.documents.index()

print(f"Status: {result.status}")
print(f"Documents: {result.documents_processed}")
print(f"Chunks: {result.total_chunks}")
print(f"Time: {result.elapsed_seconds:.1f}s")
results = client.query("contract termination", top_k=5)

for chunk in results:
    print(f"Score: {chunk.score:.3f}")
    print(f"Text: {chunk.text}")
    print(f"Source: {chunk.metadata.get('filename')}")
    print("---")

Search Result Object

results = client.query("machine learning")

print(f"Query: {results.query}")
print(f"Results: {results.count}")
print(f"Time: {results.elapsed_ms:.1f}ms")

# Iterate through results
for chunk in results:
    print(chunk.text)

Embeddings

Generate embeddings with optional AdaptHex compression:

# With compression (default)
result = client.embed("machine learning algorithms")
print(f"Dimensions: {result.dimensions}")
print(f"Hex: {result.hex_embedding[:50]}...")

# Without compression
result = client.embed("machine learning", quantize=False)
print(f"Vector: {result.embedding[:5]}...")

Compression Modes

Mode Compression Accuracy
hex8 4x 99.6%
hex4 8x 95.8%
binary 32x ~85%
# Use different compression modes
result = client.embed("text", mode="hex4")  # 8x compression

RAG Chat (Coming Soon)

response = client.chat("What are the key terms in the contract?")
print(response)

Error Handling

from adaptensor import (
    Adaptensor,
    AdaptensorError,
    AuthenticationError,
    DocumentNotFoundError,
    APIError
)

try:
    client = Adaptensor(api_key="invalid-key")
    client.query("test")
except AuthenticationError:
    print("Invalid API key")
except APIError as e:
    print(f"API error: {e} (status: {e.status_code})")
except AdaptensorError as e:
    print(f"General error: {e}")

Configuration

client = Adaptensor(
    api_key="your-api-key",
    base_url="https://your-instance.adaptensor.com",  # Custom endpoint
    timeout=600  # Request timeout in seconds
)

Health Check

if client.health():
    print("API is healthy")
else:
    print("API is down")

Usage Statistics

stats = client.stats()
print(f"Documents: {stats['documents']}")
print(f"Chunks: {stats['chunks']}")
print(f"Queries: {stats['queries']}")

Full Example

from adaptensor import Adaptensor

# Initialize
client = Adaptensor()

# Upload a batch of legal documents
docs = client.documents.upload_many([
    "contracts/agreement_2024.pdf",
    "contracts/amendment_1.pdf",
    "contracts/amendment_2.pdf",
])
print(f"Uploaded {len(docs)} documents")

# Index everything
result = client.documents.index()
print(f"Indexed {result.total_chunks} chunks in {result.elapsed_seconds:.1f}s")

# Search for specific clauses
results = client.query("indemnification obligations", top_k=10)

print(f"\nFound {results.count} results in {results.elapsed_ms:.1f}ms:\n")
for i, chunk in enumerate(results, 1):
    print(f"{i}. [{chunk.score:.2f}] {chunk.metadata.get('filename')}")
    print(f"   {chunk.text[:150]}...")
    print()

Requirements

  • Python 3.8+
  • requests >= 2.25.0

License

MIT License - see LICENSE for details.


Adaptensor — Your Data. Your Infrastructure. Your AI.

Metadata

Release files for adaptensor 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adaptensor 0.2.0
File Size Uploaded Provenance
adaptensor-0.2.0.tar.gz 13.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for adaptensor 0.2.0
File Interpreter ABI Platform
adaptensor-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.6 kB

Release files / adaptensor-0.2.0.tar.gz

Download URL adaptensor-0.2.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
97f0542bdc1610613256ccfe6705354511114d2050e981cb887090f0886f79db
BLAKE2b-256 checksum
How to use checksums
0a71eb20032459792dad3e71816800298285abbe882709decf48d2fd6173ffd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / adaptensor-0.2.0-py3-none-any.whl

Download URL adaptensor-0.2.0-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
181e03869544b8654bdddd15440e5c61649e64c28a1257d38fefeb26983beec7
BLAKE2b-256 checksum
How to use checksums
d02a639748f50cc309268354f0fac02d9dea61089f21c563fa4d5788d140be62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for adaptensor 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page