Skip to main content

Condy: Python Client for Condensation.ai

A modern, async Python client library for interacting with the Condensation.ai API, providing seamless access to document processing and RAG (Retrieval-Augmented Generation) capabilities.

Features

  • 🚀 Fully async implementation using httpx
  • 📄 Document processing and chunking
  • 🔍 RAG (Retrieval-Augmented Generation) querying
  • 💪 Type hints and modern Python practices
  • ⚡ Efficient markdown processing and page management
  • 🛡️ Comprehensive error handling
  • 📝 Rich document metadata support

Installation

pip install condy

Quick Start

import asyncio
from condy import CondyClient

async def main():
    # Initialize the client
    client = CondyClient(api_key="your-api-key")
    
    # Process a document from URL with metadata
    doc_output = await client.process_document(
        url="https://example.com/document.md",
        filename="document.md",
        file_key="custom-key",
        public_url="https://example.com/document.md"
    )
    
    # Query the document using RAG
    response = await client.query_rag(
        question="What are the key points?",
        document_id=doc_output.document_id
    )
    
    print(response.answer)

asyncio.run(main())

Core Features

Document Processing

# Upload pages directly with metadata
pages = {
    1: "Page 1 content",
    2: "Page 2 content"
}
doc_output = await client.upload_pages(
    pages=pages,
    filename="document.txt",
    file_key="unique-identifier",
    public_url="https://example.com/document.txt"
)

# Or process markdown from URL with metadata
doc_output = await client.process_document(
    url="https://example.com/document.md",
    filename="document.md",
    file_key="doc-123",
    public_url="https://example.com/document.md"
)

RAG Queries

# Query a document
response = await client.query_rag(
    question="What does the document say about X?",
    document_id="doc-id",
    max_chunks=5
)

# Access the response
print(response.answer)
print(response.source_pages)  # List of source pages used

Chunk Management

# Fetch document chunks
chunks = await client.fetch_chunks(
    document_id="doc-id",
    include_embeddings=False  # Set to True to include vector embeddings
)

Configuration

The client can be configured with custom settings:

client = CondyClient(
    api_key="your-api-key",
    base_url="https://custom-url.example.com",  # Optional
    timeout=60.0  # Custom timeout in seconds
)

Document Metadata

The library supports rich document metadata:

# Process document with full metadata
doc_output = await client.process_document(
    url="https://example.com/doc.pdf",
    content_type="pdf",
    filename="important-doc.pdf",  # Optional: Custom filename
    file_key="doc-2023-01",       # Optional: Unique identifier
    public_url="https://example.com/doc.pdf"  # Optional: Public access URL
)

Error Handling

The library provides specific exceptions for different error cases:

  • NetworkError: For connection and network-related issues
  • TimeoutError: For request timeout issues
  • APIError: For API-specific errors with status codes and details
from condy import NetworkError, TimeoutError, APIError

try:
    response = await client.query_rag(question="...", document_id="...")
except TimeoutError:
    print("Request timed out")
except NetworkError:
    print("Network error occurred")
except APIError as e:
    print(f"API error: {e.status_code} - {e.detail}")

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

The usage of the library is subject to the Condensation.ai Terms of Service.

Support

For support, please contact support@condensation.ai.

Metadata

Release files for condy 0.3.9

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

Source distribution (sdist)

Source distribution for condy 0.3.9
File Size Uploaded Provenance Actions
condy-0.3.9.tar.gz 9.8 kB Without provenance Details for condy-0.3.9.tar.gz

Built distribution (wheel)

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

Total release size: 19.6 kB

Release files / condy-0.3.9.tar.gz

Download URL condy-0.3.9.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b30de1ac23242307a1c194b4c3880c043fa09d7780be75e73ebae3d752d9c4f1
BLAKE2b-256 checksum
How to use checksums
d625de10286d3727bea91c38c26a19e9fe0a3845c544e317245e373edccc8d92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / condy-0.3.9-py3-none-any.whl

Download URL condy-0.3.9-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb0db26e0e85c752084aaa1286e1a0d7c8ed57a8d1ff8899c0e8226729a0aeb4
BLAKE2b-256 checksum
How to use checksums
b3c087c952536bff60c67dbe3567113689b8ab0d30139e2cb77f937dd9bc2e84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Security for condy 0.3.9

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.

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