condy


Namecondy JSON
Version 0.3.9 PyPI version JSON
download
home_pageNone
SummaryPython client for the Condensation.ai API
upload_time2024-10-30 20:05:38
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords ai api-client condensation rag
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```bash
pip install condy
```

## Quick Start

```python
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

```python
# 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

```python
# 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

```python
# 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:

```python
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:

```python
# 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

```python
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](https://condensation.ai/terms-and-conditions).

## Support

For support, please contact support@condensation.ai.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "condy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "ai, api-client, condensation, rag",
    "author": null,
    "author_email": "Rach Pradhan <rach@condensation.ai>",
    "download_url": "https://files.pythonhosted.org/packages/d6/25/de10286d3727bea91c38c26a19e9fe0a3845c544e317245e373edccc8d92/condy-0.3.9.tar.gz",
    "platform": null,
    "description": "# Condy: Python Client for Condensation.ai\n\nA modern, async Python client library for interacting with the Condensation.ai API, providing seamless access to document processing and RAG (Retrieval-Augmented Generation) capabilities.\n\n## Features\n\n- \ud83d\ude80 Fully async implementation using `httpx`\n- \ud83d\udcc4 Document processing and chunking\n- \ud83d\udd0d RAG (Retrieval-Augmented Generation) querying\n- \ud83d\udcaa Type hints and modern Python practices\n- \u26a1 Efficient markdown processing and page management\n- \ud83d\udee1\ufe0f Comprehensive error handling\n- \ud83d\udcdd Rich document metadata support\n\n## Installation\n\n```bash\npip install condy\n```\n\n## Quick Start\n\n```python\nimport asyncio\nfrom condy import CondyClient\n\nasync def main():\n    # Initialize the client\n    client = CondyClient(api_key=\"your-api-key\")\n    \n    # Process a document from URL with metadata\n    doc_output = await client.process_document(\n        url=\"https://example.com/document.md\",\n        filename=\"document.md\",\n        file_key=\"custom-key\",\n        public_url=\"https://example.com/document.md\"\n    )\n    \n    # Query the document using RAG\n    response = await client.query_rag(\n        question=\"What are the key points?\",\n        document_id=doc_output.document_id\n    )\n    \n    print(response.answer)\n\nasyncio.run(main())\n```\n\n## Core Features\n\n### Document Processing\n\n```python\n# Upload pages directly with metadata\npages = {\n    1: \"Page 1 content\",\n    2: \"Page 2 content\"\n}\ndoc_output = await client.upload_pages(\n    pages=pages,\n    filename=\"document.txt\",\n    file_key=\"unique-identifier\",\n    public_url=\"https://example.com/document.txt\"\n)\n\n# Or process markdown from URL with metadata\ndoc_output = await client.process_document(\n    url=\"https://example.com/document.md\",\n    filename=\"document.md\",\n    file_key=\"doc-123\",\n    public_url=\"https://example.com/document.md\"\n)\n```\n\n### RAG Queries\n\n```python\n# Query a document\nresponse = await client.query_rag(\n    question=\"What does the document say about X?\",\n    document_id=\"doc-id\",\n    max_chunks=5\n)\n\n# Access the response\nprint(response.answer)\nprint(response.source_pages)  # List of source pages used\n```\n\n### Chunk Management\n\n```python\n# Fetch document chunks\nchunks = await client.fetch_chunks(\n    document_id=\"doc-id\",\n    include_embeddings=False  # Set to True to include vector embeddings\n)\n```\n\n## Configuration\n\nThe client can be configured with custom settings:\n\n```python\nclient = CondyClient(\n    api_key=\"your-api-key\",\n    base_url=\"https://custom-url.example.com\",  # Optional\n    timeout=60.0  # Custom timeout in seconds\n)\n```\n\n## Document Metadata\n\nThe library supports rich document metadata:\n\n```python\n# Process document with full metadata\ndoc_output = await client.process_document(\n    url=\"https://example.com/doc.pdf\",\n    content_type=\"pdf\",\n    filename=\"important-doc.pdf\",  # Optional: Custom filename\n    file_key=\"doc-2023-01\",       # Optional: Unique identifier\n    public_url=\"https://example.com/doc.pdf\"  # Optional: Public access URL\n)\n```\n\n## Error Handling\n\nThe library provides specific exceptions for different error cases:\n\n- `NetworkError`: For connection and network-related issues\n- `TimeoutError`: For request timeout issues\n- `APIError`: For API-specific errors with status codes and details\n\n```python\nfrom condy import NetworkError, TimeoutError, APIError\n\ntry:\n    response = await client.query_rag(question=\"...\", document_id=\"...\")\nexcept TimeoutError:\n    print(\"Request timed out\")\nexcept NetworkError:\n    print(\"Network error occurred\")\nexcept APIError as e:\n    print(f\"API error: {e.status_code} - {e.detail}\")\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThe usage of the library is subject to the [Condensation.ai Terms of Service](https://condensation.ai/terms-and-conditions).\n\n## Support\n\nFor support, please contact support@condensation.ai.",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python client for the Condensation.ai API",
    "version": "0.3.9",
    "project_urls": {
        "Documentation": "https://justrach/condy",
        "Homepage": "https://github.com/yourusername/condy",
        "Repository": "https://github.com/justrach/condy.git",
        "bug tracker": "https://github.com/yourusername/condy/issues"
    },
    "split_keywords": [
        "ai",
        " api-client",
        " condensation",
        " rag"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3c087c952536bff60c67dbe3567113689b8ab0d30139e2cb77f937dd9bc2e84",
                "md5": "0a968580a365c376a491e3a51f8a86c8",
                "sha256": "eb0db26e0e85c752084aaa1286e1a0d7c8ed57a8d1ff8899c0e8226729a0aeb4"
            },
            "downloads": -1,
            "filename": "condy-0.3.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0a968580a365c376a491e3a51f8a86c8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9840,
            "upload_time": "2024-10-30T20:05:36",
            "upload_time_iso_8601": "2024-10-30T20:05:36.747911Z",
            "url": "https://files.pythonhosted.org/packages/b3/c0/87c952536bff60c67dbe3567113689b8ab0d30139e2cb77f937dd9bc2e84/condy-0.3.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d625de10286d3727bea91c38c26a19e9fe0a3845c544e317245e373edccc8d92",
                "md5": "8e6d48bc7438943ea9445a4847dce6b3",
                "sha256": "b30de1ac23242307a1c194b4c3880c043fa09d7780be75e73ebae3d752d9c4f1"
            },
            "downloads": -1,
            "filename": "condy-0.3.9.tar.gz",
            "has_sig": false,
            "md5_digest": "8e6d48bc7438943ea9445a4847dce6b3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9755,
            "upload_time": "2024-10-30T20:05:38",
            "upload_time_iso_8601": "2024-10-30T20:05:38.175720Z",
            "url": "https://files.pythonhosted.org/packages/d6/25/de10286d3727bea91c38c26a19e9fe0a3845c544e317245e373edccc8d92/condy-0.3.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-30 20:05:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yourusername",
    "github_project": "condy",
    "github_not_found": true,
    "lcname": "condy"
}
        
Elapsed time: 0.68544s