Skip to main content

Production-ready RAG infrastructure for multilingual applications

Project description

Maktaba

CI PyPI version Version Python 3.10+ License: MIT

The library for building libraries - By NuhaTech

From the Arabic word for library, Maktaba is a modern RAG infrastructure for building intelligent knowledge systems in any language.

Features

  • 🔌 Provider-agnostic: Works with OpenAI, Cohere, Azure, and more
  • 🚀 Production-ready: Built for scale with async-first design
  • 🧩 Modular: Use only what you need
  • 🌍 Multilingual: Optimized for Arabic and international languages
  • 📊 Type-safe: Full type hints and Pydantic validation
  • 🧪 Well-tested: Comprehensive test coverage
  • 🔍 Deep research: Built-in iterative planning for long-form reports

Installation

Using UV (Recommended)

# Install UV if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Add maktaba to your project
uv add maktaba

# With OpenAI + Qdrant
uv add "maktaba[openai,qdrant]"

# With all providers
uv add "maktaba[all]"

Using pip

# Basic installation
pip install maktaba

# With OpenAI + Qdrant
pip install "maktaba[openai,qdrant]"

# With all providers
pip install "maktaba[all]"

Quick Start

from maktaba.pipeline import QueryPipeline
from maktaba.embedding import OpenAIEmbedder
from maktaba.storage import QdrantStore
from maktaba.reranking import CohereReranker

# Create pipeline
pipeline = QueryPipeline(
    embedder=OpenAIEmbedder(api_key="..."),
    vector_store=QdrantStore(url="http://localhost:6333", collection_name="docs"),
    reranker=CohereReranker(api_key="...")
)

# Search with automatic reranking and citation formatting
result = await pipeline.search(
    query="What is Tawhid?",
    top_k=10,
    rerank=True
)

# Use in your LLM prompt
print(result["formatted_context"])  # [1]: content... [2]: content...
print(result["citations"])          # [{id: 1, source: "...", score: 0.95}, ...]

Deep Research Pipeline

Learn how to customise the default prompts via maktaba_templates.md.

from maktaba.pipeline import create_deep_research_pipeline
from maktaba.embedding import OpenAIEmbedder
from maktaba.storage import QdrantStore
from maktaba.llm import OpenAILLM

pipeline = create_deep_research_pipeline(
    embedder=OpenAIEmbedder(api_key="..."),
    store=QdrantStore(url="http://localhost:6333", collection_name="docs"),
    llm=OpenAILLM(api_key="...", model="gpt-4o-mini"),
)

result = await pipeline.run_research("Impacts of lunar dust on spacecraft design")

chunks = [chunk async for chunk in result.stream]
print("".join(chunks))       # Final long-form report
print(result.queries_used)   # Queries issued during research
print(result.source_indices) # 1-based indices of retained sources

For a full walkthrough (configuration knobs, streaming, stage overrides), see docs/DeepResearch.md and examples/deep_research_pipeline.py.

Development

Running Checks Before Push

Before pushing to the remote repository, run all quality checks:

Linux/Mac/Git Bash:

./scripts/check.sh

Windows CMD:

scripts\check.bat

This will run:

  • Ruff linting
  • MyPy type checking
  • Pytest tests

All checks must pass before pushing.

Documentation

  • Overview: docs/Overview.md
  • Quickstart: docs/Quickstart.md
  • Pipelines: docs/Pipelines.md
  • Providers: docs/Providers.md
  • Examples: docs/Examples.md
  • Troubleshooting: docs/Troubleshooting.md

Website (coming soon): maktaba.nuhatech.com

License

MIT License - see LICENSE

About NuhaTech

Built by NuhaTech - creators of Kutub and Muqabia.

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

maktaba-0.1.23.tar.gz (524.5 kB view details)

Uploaded Source

Built Distribution

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

maktaba-0.1.23-py3-none-any.whl (75.5 kB view details)

Uploaded Python 3

File details

Details for the file maktaba-0.1.23.tar.gz.

File metadata

  • Download URL: maktaba-0.1.23.tar.gz
  • Upload date:
  • Size: 524.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for maktaba-0.1.23.tar.gz
Algorithm Hash digest
SHA256 b06cedf742e10a7ab3a26cd8cca22bffbfe96a50dc07af345e251992b221b4bb
MD5 b2f506d52406f2b7b125ae263872f1c3
BLAKE2b-256 a20f795bc73cea61d7f4b48afa0d81348c2f04a9ffd5df7f7479c1f70fbf6c06

See more details on using hashes here.

Provenance

The following attestation bundles were made for maktaba-0.1.23.tar.gz:

Publisher: publish.yml on nuhatech/maktaba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file maktaba-0.1.23-py3-none-any.whl.

File metadata

  • Download URL: maktaba-0.1.23-py3-none-any.whl
  • Upload date:
  • Size: 75.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for maktaba-0.1.23-py3-none-any.whl
Algorithm Hash digest
SHA256 6da57c29fd539be735a688f3cc8ee3efe289160f53bdf5d4fc60df947ac56c63
MD5 595e7345836a0a439254f567af36ac41
BLAKE2b-256 f8418e1616630e2bb9accacdc16eb6c1ca2de6824b978c8ae8121f6edbc49a23

See more details on using hashes here.

Provenance

The following attestation bundles were made for maktaba-0.1.23-py3-none-any.whl:

Publisher: publish.yml on nuhatech/maktaba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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