Skip to main content

A lightweight async package for building Multi-Modal RAG applications

Project description

Orbitron

A lightweight, async Python package for building Multi-Modal Retrieval-Augmented Generation (RAG) applications.

Orbitron Orbitron simplifies the process of indexing visual content (images, pages from PDFs) and retrieving the most relevant items based on text queries. It integrates with Cohere's multimodal embeddings and Qdrant vector stores out-of-the-box.

Key Features:

  • Multi-Modal Indexing: Supports indexing individual image files (.png, .jpg, .jpeg, .bmp) and extracting/indexing images from PDF pages.
  • Cohere Integration: Uses Cohere's powerful embed-v4.0 model for generating multimodal embeddings.
  • Vectorstore Integration: Provides a ready-to-use vector store implementation (currently supports Qdrant).
  • Simple API: Easy-to-use interface for indexing and retrieval.

Table of Contents

Installation

You can install orbitron using pip:

pip install orbitron

Requirements:

  • Python 3.11+

Dependencies

Poppler (External System Dependency)

Orbitron uses the pdf2image library to extract images from PDF files. pdf2image relies on the Poppler PDF rendering library utilities being installed on your system and available in your PATH.

Installation Instructions:

  • Debian/Ubuntu:
    sudo apt-get update && sudo apt-get install poppler-utils
    
  • macOS (using Homebrew):
    brew install poppler
    
  • Windows:
    • Download the latest Poppler binaries (e.g., from here).
    • Extract the archive.
    • Add the bin/ directory from the extracted archive to your system's PATH environment variable.

You can check if Poppler is likely installed and accessible using:

from orbitron.utils import check_poppler_installed

if check_poppler_installed():
    print("Poppler utilities seem to be installed and accessible.")
else:
    print("Warning: Poppler utilities (needed for PDF indexing) not found in PATH.")

Python Dependencies

Orbitron's core Python dependencies (like cohere, qdrant-client, pdf2image, Pillow, numpy) are listed in pyproject.toml and will be installed automatically by pip.

Quickstart

This example demonstrates indexing a PDF and retrieving relevant pages based on a text query using an in-memory Qdrant database.

import asyncio
import os
from pathlib import Path

from dotenv import load_dotenv
from qdrant_client import AsyncQdrantClient

from orbitron import MultiModalRAG, QdrantVectorStore


async def main():
    # Load environment variables
    load_dotenv()

    # Configuration
    pdf_path = "YOUR_FILE.pdf"

    cohere_api_key = os.getenv("COHERE_API_KEY")

    try:
        # Initialize vector store
        qdrant_client = AsyncQdrantClient(":memory:")
        vector_store = QdrantVectorStore(qdrant_client, collection_name="my_docs")

        # Initialize RAG client
        rag = MultiModalRAG(vector_store, cohere_api_key, verbose=True)

        # Index PDF
        summary = await rag.index(pdf_path)
        print(f"Indexing summary: {summary}")

        query = "" # Replace with your query

        # Retrieve results
        results = await rag.retrieve(query, top_k=3)

        # Display results
        for i, result in enumerate(results, 1):
            print(f"\nResult {i}:")
            print(f"  Source: {result.source_file}")
            print(f"  Page: {result.page_number}")
            print(f"  Score: {result.score:.4f}")
            print(f"  Image Path: {result.image_path}")

    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    asyncio.run(main())

Output Directory

The output_dir parameter in MultiModalRAG specifies where supporting files are stored, primarily the images extracted from PDFs.

  • Default: If output_dir is not provided, it defaults to ./.orbitron/data (a directory named .orbitron containing data) relative to the current working directory where your Python script is executed.
  • Specified Path: If you provide a path (e.g., output_dir="my_data" or output_dir="/abs/path/data"), Orbitron will resolve it:
    • Relative paths are interpreted relative to the current working directory.
    • Absolute paths are used directly.

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Reporting Issues: Use the GitHub issue tracker to report bugs, suggest features, or ask questions. Provide clear steps to reproduce bugs.
  2. Pull Requests:
    • Fork the repository.
    • Create a new branch for your feature or bug fix.
    • Install development dependencies: pip install -e .[dev]
    • Make your changes.
    • Ensure code is formatted (black .), sorted (isort .), and passes type checks (mypy src). Add tests if applicable.
    • Commit your changes with clear messages.
    • Push your branch and open a pull request against the main branch.

License

This project is licensed under the MIT License. See the LICENSE file for details.


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

orbitron-0.1.0a1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orbitron-0.1.0a1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file orbitron-0.1.0a1.tar.gz.

File metadata

  • Download URL: orbitron-0.1.0a1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.24

File hashes

Hashes for orbitron-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 0be6c2fd3bc0c5f5b6e39e1bbaf3efa0410f87503e77ffab9ee2eec890e739fe
MD5 109532fc55db5fac355eee48318842d4
BLAKE2b-256 0d655a19c92fc7ddf93ed1b69f03502cac1d42def9c7b61242980dc00d65ee64

See more details on using hashes here.

File details

Details for the file orbitron-0.1.0a1-py3-none-any.whl.

File metadata

  • Download URL: orbitron-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.24

File hashes

Hashes for orbitron-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 e3519ae982a87b1d935763a7ab9a12c778077ab6f37d05540f47abd5ec69f166
MD5 5488e3b9c325b92e7b1e7b302313167a
BLAKE2b-256 90c07a4e4e2991973940e4ed295bbe34ae3746c25f302397c77be1c4311e3093

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page