Skip to main content

A comprehensive, professional-grade agentic Retrieval-Augmented Generation (RAG) library

Project description

๐Ÿค– Agentic RAG

AI Prishtina Logo

Python 3.9+ License: AGPL v3+ Code Coverage PyPI version

A comprehensive, professional-grade agentic Retrieval-Augmented Generation (RAG) library that combines the power of large language models with intelligent agents, advanced retrieval mechanisms, and tool integration for building sophisticated AI applications.

โ˜• Support This Project

If you find this project helpful, please consider supporting it:

Donate

๐ŸŒŸ Key Features

๐Ÿง  Agentic Intelligence

  • Query Planning & Decomposition: Intelligent multi-step query planning with reasoning
  • Working & Long-term Memory: Persistent memory systems for context retention
  • Tool Integration: Extensible tool ecosystem (web search, calculator, code execution)
  • Multi-step Reasoning: Complex problem-solving with iterative refinement

๐Ÿ” Advanced Retrieval

  • Multiple Vector Stores: ChromaDB, Pinecone, Weaviate, FAISS support
  • Hybrid Retrieval: Combines semantic and keyword-based search
  • Graph RAG: Knowledge graph integration for enhanced context understanding
  • Smart Reranking: Cross-encoder and ColBERT reranking capabilities

๐Ÿ“š Document Processing

  • Multi-format Support: PDF, DOCX, TXT, Markdown, HTML, and more
  • Intelligent Chunking: Fixed-size, semantic, and recursive chunking strategies
  • Metadata Extraction: Automatic extraction of document metadata
  • Multi-modal Processing: Image, audio, and video content support (optional)

๐Ÿš€ LLM Integration

  • Multiple Providers: OpenAI, Anthropic, Cohere, and local models
  • Streaming Support: Real-time response streaming
  • Prompt Management: Advanced prompt templating and optimization
  • Response Generation: Intelligent response synthesis and formatting

๐Ÿ“Š Evaluation & Monitoring

  • Comprehensive Metrics: Relevance, faithfulness, answer quality, and latency
  • Benchmarking Suite: Performance evaluation and comparison tools
  • Real-time Monitoring: System performance and quality tracking

๐Ÿ”ง Developer Experience

  • Plug-and-Play Architecture: Modular components for easy customization
  • Type Safety: Full type hints and Pydantic validation
  • Rich Configuration: YAML, environment variables, and programmatic config
  • Extensive Examples: Complete examples and tutorials

๐Ÿš€ Quick Start

Installation

# Basic installation
pip install ai-prishtina-agentic-rag

# With all optional dependencies
pip install ai-prishtina-agentic-rag[all]

# Development installation
pip install ai-prishtina-agentic-rag[dev]

Basic Usage

from agentic_rag import AgenticRAG
from agentic_rag.utils.config import Config

# Initialize the system
config = Config()
rag = AgenticRAG(config=config, enable_agent=True)

# Add documents
documents = [
    {"content": "Your document content here...", "metadata": {"source": "doc1.pdf"}},
    # ... more documents
]
rag.add_documents(documents)

# Query with agentic capabilities
response = await rag.aquery(
    "What are the key findings about climate change impacts?",
    enable_planning=True,
    use_tools=True
)

print(f"Answer: {response.answer}")
print(f"Sources: {response.sources}")
print(f"Reasoning: {response.reasoning_steps}")

๐Ÿ“– Documentation

Core Components

๐Ÿค– AgenticRAG - Main Interface

The central orchestrator that coordinates all components:

from agentic_rag import AgenticRAG, Config

rag = AgenticRAG(
    config=config,
    enable_agent=True,        # Enable agentic capabilities
    enable_memory=True,       # Enable memory systems
    enable_tools=True,        # Enable tool integration
    enable_streaming=True     # Enable response streaming
)

๐Ÿง  Memory Systems

Persistent memory for context retention:

from agentic_rag.core.memory import WorkingMemory, LongTermMemory

# Working memory for current session
working_memory = WorkingMemory(capacity=10)

# Long-term memory for persistent storage
long_term_memory = LongTermMemory(
    storage_path="./memory",
    embedding_model="sentence-transformers/all-MiniLM-L6-v2"
)

๐Ÿ” Vector Stores

Multiple vector database options:

from agentic_rag.retrieval import (
    ChromaVectorStore,
    PineconeVectorStore,
    WeaviateVectorStore,
    FAISSVectorStore
)

# ChromaDB (great for development)
vector_store = ChromaVectorStore(collection_name="my_docs")

# Pinecone (production-ready)
vector_store = PineconeVectorStore(
    api_key="your-key",
    environment="us-west1-gcp",
    index_name="my-index"
)

๐Ÿค– LLM Providers

Support for multiple LLM providers:

from agentic_rag.llm import OpenAIProvider, AnthropicProvider, LocalModelProvider

# OpenAI
llm = OpenAIProvider(
    api_key="your-key",
    model="gpt-4",
    temperature=0.7
)

# Anthropic Claude
llm = AnthropicProvider(
    api_key="your-key",
    model="claude-3-sonnet-20240229"
)

# Local model
llm = LocalModelProvider(
    model_path="./models/llama-2-7b",
    device="cuda"
)

Advanced Features

๐Ÿ› ๏ธ Tool Integration

Extend capabilities with tools:

from agentic_rag.tools import WebSearchTool, CalculatorTool, CodeExecutorTool

# Register tools
rag.register_tool(WebSearchTool(api_key="your-search-api-key"))
rag.register_tool(CalculatorTool())
rag.register_tool(CodeExecutorTool(allowed_languages=["python", "javascript"]))

# Use tools in queries
response = await rag.aquery(
    "Search for recent papers on transformer architectures and calculate the average citation count",
    use_tools=True
)

๐Ÿ“Š Graph RAG

Knowledge graph integration:

from agentic_rag.graph import KnowledgeGraph

# Enable graph RAG
graph = KnowledgeGraph()
rag = AgenticRAG(config=config, knowledge_graph=graph)

# Automatic entity extraction and relationship building
rag.add_documents(documents, extract_entities=True)

๐Ÿ”„ Streaming Responses

Real-time response streaming:

async for chunk in rag.astream("Tell me about quantum computing"):
    print(chunk.content, end="", flush=True)

๐Ÿ—๏ธ Architecture

The library follows a modular, plug-and-play architecture:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   AgenticRAG    โ”‚โ”€โ”€โ”€โ”€โ”‚  QueryPlanner    โ”‚โ”€โ”€โ”€โ”€โ”‚   Memory        โ”‚
โ”‚   (Orchestrator)โ”‚    โ”‚  (Intelligence)  โ”‚    โ”‚   (Context)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ–ผ                       โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Retrieval     โ”‚    โ”‚   LLM Providers  โ”‚    โ”‚     Tools       โ”‚
โ”‚   (Vector/Graph)โ”‚    โ”‚   (OpenAI/etc)   โ”‚    โ”‚   (Web/Calc)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ–ผ                       โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Document      โ”‚    โ”‚   Evaluation     โ”‚    โ”‚   Configuration โ”‚
โ”‚   Processing    โ”‚    โ”‚   & Monitoring   โ”‚    โ”‚   & Logging     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“Š Performance & Evaluation

Metrics & Benchmarking

from agentic_rag.evaluation import ComprehensiveEvaluator, RAGBenchmark

# Comprehensive evaluation
evaluator = ComprehensiveEvaluator()
results = await evaluator.evaluate(
    rag_system=rag,
    test_queries=test_queries,
    ground_truth=ground_truth
)

print(f"Relevance Score: {results.relevance_score:.3f}")
print(f"Faithfulness Score: {results.faithfulness_score:.3f}")
print(f"Answer Quality: {results.answer_quality:.3f}")
print(f"Average Latency: {results.avg_latency:.2f}s")

# Benchmark against standard datasets
benchmark = RAGBenchmark()
benchmark_results = await benchmark.run(rag_system=rag)

Current Test Coverage

  • Overall Coverage: 55% (actively improving)
  • Core Components: Well tested (84-91% coverage)
  • Integration Tests: Comprehensive test suite (183 tests)
  • Test Results: 167 passed, 7 failed, 9 errors (91% pass rate)
  • Performance Tests: Latency and throughput benchmarks

๐Ÿ”ง Configuration

Environment Variables

# LLM Configuration
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
COHERE_API_KEY=your_cohere_key

# Vector Store Configuration
PINECONE_API_KEY=your_pinecone_key
PINECONE_ENVIRONMENT=us-west1-gcp
WEAVIATE_URL=http://localhost:8080

# Tool Configuration
SERP_API_KEY=your_search_api_key

YAML Configuration

# config.yaml
llm:
  provider: "openai"
  model: "gpt-4"
  temperature: 0.7
  max_tokens: 2000

vector_store:
  provider: "chroma"
  collection_name: "documents"

retrieval:
  top_k: 5
  rerank: true
  reranker_model: "cross-encoder/ms-marco-MiniLM-L-6-v2"

agent:
  enable_planning: true
  enable_memory: true
  enable_tools: true
  max_iterations: 5

tools:
  - name: "web_search"
    enabled: true
  - name: "calculator"
    enabled: true

๐Ÿ“š Examples

Basic RAG System

# examples/basic_example.py
from agentic_rag import AgenticRAG
from agentic_rag.document_processing import DocumentLoader

# Load documents
loader = DocumentLoader()
documents = loader.load_directory("./documents")

# Initialize RAG
rag = AgenticRAG()
rag.add_documents([doc.dict() for doc in documents])

# Query
response = await rag.aquery("What is the main topic of these documents?")
print(response.answer)

Advanced Agentic RAG

# examples/advanced_rag.py
from agentic_rag import AgenticRAG
from agentic_rag.tools import WebSearchTool, CalculatorTool
from agentic_rag.core.memory import LongTermMemory

# Setup with advanced features
rag = AgenticRAG(
    enable_agent=True,
    enable_memory=True,
    memory_system=LongTermMemory(storage_path="./memory")
)

# Register tools
rag.register_tool(WebSearchTool(api_key="your-key"))
rag.register_tool(CalculatorTool())

# Complex multi-step query
response = await rag.aquery(
    "Research the latest developments in quantum computing, "
    "find the top 3 companies by investment, and calculate "
    "the total funding amount",
    enable_planning=True,
    use_tools=True
)

Plug-and-Play Components

# examples/plug_and_play_demo.py
from agentic_rag import AgenticRAG
from agentic_rag.retrieval import PineconeVectorStore
from agentic_rag.llm import AnthropicProvider

# Custom component configuration
vector_store = PineconeVectorStore(
    api_key="your-key",
    environment="us-west1-gcp"
)

llm_provider = AnthropicProvider(
    api_key="your-key",
    model="claude-3-sonnet-20240229"
)

# Plug components together
rag = AgenticRAG(
    vector_store=vector_store,
    llm_provider=llm_provider,
    enable_agent=True
)

๐Ÿงช Testing

Run the comprehensive test suite:

# Run all tests
pytest

# Run with coverage
pytest --cov=agentic_rag --cov-report=html

# Run specific test categories
pytest tests/test_vector_stores.py
pytest tests/test_llm_providers.py
pytest tests/test_complete_features.py

# Run performance benchmarks
pytest tests/test_evaluation.py -v

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

# Clone the repository
git clone https://github.com/your-org/ai-prishtina-agentic-rag.git
cd ai-prishtina-agentic-rag

# Install in development mode
pip install -e .[dev]

# Install pre-commit hooks
pre-commit install

# Run tests
pytest

Code Quality

We maintain high code quality standards:

  • Type Safety: Full type hints with mypy validation
  • Code Formatting: Black and isort for consistent formatting
  • Linting: Flake8 for code quality checks
  • Testing: Comprehensive test suite with pytest
  • Documentation: Detailed docstrings and examples

๐Ÿ“„ License

This project is dual-licensed under:

  • GNU Affero General Public License v3 or later (AGPLv3+) - for open source projects
  • Commercial License - for proprietary/commercial use

Open Source License (AGPLv3+)

This software is free for use in open source projects under the GNU Affero General Public License v3 or later. This means:

  • โœ… Free to use for open source projects
  • โœ… Modify and distribute with source code
  • โœ… Network use requires source disclosure
  • โš ๏ธ Copyleft: Derivative works must also be AGPLv3+

Commercial License

For commercial use, proprietary applications, or if you prefer not to comply with AGPLv3+ requirements:

  • ๐Ÿ’ผ Commercial licensing available for proprietary use
  • ๐Ÿš€ No copyleft obligations for your application
  • ๐Ÿ›Ÿ Priority support and maintenance included
  • ๐Ÿ“ž Contact: info@albanmaxhuni.com

See the LICENSE file for complete details.

๐Ÿ™ Acknowledgments

  • Built with โค๏ธ by the AI Prishtina team
  • Inspired by the latest research in RAG and agentic AI systems
  • Thanks to the open-source community for the foundational libraries

๐Ÿ“ž Support & Contact


Made with ๐Ÿค– by AI Prishtina | Empowering the future of intelligent information retrieval

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

ai_prishtina_agentic_rag-0.1.2.tar.gz (91.1 kB view details)

Uploaded Source

Built Distribution

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

ai_prishtina_agentic_rag-0.1.2-py3-none-any.whl (77.8 kB view details)

Uploaded Python 3

File details

Details for the file ai_prishtina_agentic_rag-0.1.2.tar.gz.

File metadata

  • Download URL: ai_prishtina_agentic_rag-0.1.2.tar.gz
  • Upload date:
  • Size: 91.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for ai_prishtina_agentic_rag-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f4f0942be70a723800244055f1f4f4dba55cec64a40d7d31d70849d3f1aa996b
MD5 8591073ac1b6e7a9cd870a9e04a7c510
BLAKE2b-256 5f24d2adeea53f405d8146e75f0ab6967fa1c513c3b7f9d27c133d2071f76115

See more details on using hashes here.

File details

Details for the file ai_prishtina_agentic_rag-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_prishtina_agentic_rag-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c565cc5b5e8ddb4b0a5e9a73a69ca877e776b3e6f5451a3a3a01dd6cddcf38bf
MD5 1168421e6dab0f465d485a11fff8ee17
BLAKE2b-256 3b20d8afe9e821716ae25d21d5bea8f2187e581f24ef1be7000eee77e8b78aa9

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