Skip to main content

Core Conversational AI Engine for the Nexus Ecosystem

Project description

NEXUS-AIDOS-BRAIN ๐Ÿง 

The Core Conversational AI Engine for the Nexus Ecosystem

NEXUS-AIDOS-BRAIN is a production-ready Python library that provides the foundational AI capabilities for building intelligent conversational systems. Built on LangChain and LangGraph, it offers a modular, extensible architecture for implementing RAG (Retrieval-Augmented Generation), memory management, semantic caching, and multi-agent workflows.

๐ŸŒŸ Features

Core Capabilities

  • ๐Ÿ”— Conversational RAG Pipeline: Context-aware document retrieval with conversation memory
  • ๐Ÿง  Multi-tier Memory Management: Redis-backed conversation history with buffer and summary modes
  • โšก Semantic Caching: Intelligent response caching with embedding-based similarity matching
  • ๐ŸŽฏ Custom Retrievers: Flexible retrieval architecture supporting multiple vector stores (Qdrant)
  • ๐Ÿค– Agent Orchestration: LangGraph-based multi-agent workflows with state management
  • ๐Ÿ“Š Workspace Isolation: Multi-tenant support with workspace-based data segregation

Advanced Features

  • Query Enhancement: Prompt-style context injection without additional LLM calls
  • Source Tracking: Complete provenance tracking for retrieved documents
  • Configurable Chunking: Token-based text chunking with overlap for optimal retrieval
  • OpenRouter Integration: Support for 200+ LLM models via OpenRouter
  • Production Ready: Comprehensive logging, error handling, and monitoring

๐Ÿ—๏ธ Architecture

nexus_aidos/
โ”œโ”€โ”€ core/              # Core conversational engine
โ”‚   โ”œโ”€โ”€ engine.py      # Main conversational engine
โ”‚   โ””โ”€โ”€ pipeline.py    # RAG pipeline orchestration
โ”œโ”€โ”€ memory/            # Memory management
โ”‚   โ”œโ”€โ”€ redis_memory.py    # Redis-backed conversation memory
โ”‚   โ””โ”€โ”€ buffer_memory.py   # Buffer and summary memory
โ”œโ”€โ”€ retrieval/         # Document retrieval
โ”‚   โ”œโ”€โ”€ retrievers.py      # Custom retriever implementations
โ”‚   โ””โ”€โ”€ embeddings.py      # Embedding generation
โ”œโ”€โ”€ cache/             # Caching services
โ”‚   โ”œโ”€โ”€ semantic_cache.py  # Semantic similarity caching
โ”‚   โ””โ”€โ”€ exact_cache.py     # Exact match caching
โ”œโ”€โ”€ chains/            # LangChain components
โ”‚   โ”œโ”€โ”€ rag_chain.py       # Conversational RAG chain
โ”‚   โ””โ”€โ”€ query_transform.py # Query transformation
โ”œโ”€โ”€ config/            # Configuration management
โ”‚   โ””โ”€โ”€ settings.py        # Configuration classes
โ””โ”€โ”€ utils/             # Utilities
    โ”œโ”€โ”€ logging.py         # Logging utilities
    โ””โ”€โ”€ workspace.py       # Workspace utilities

๐Ÿš€ Quick Start

Installation

pip install -e ./NEXUS-AIDOS-BRAIN

Basic Usage

from nexus_aidos import NexusEngine
from nexus_aidos.config import EngineConfig

# Initialize the engine
config = EngineConfig(
    redis_url="redis://localhost:6379",
    qdrant_url="https://your-qdrant-instance.com",
    qdrant_api_key="your-api-key",
    openrouter_api_key="your-openrouter-key"
)

engine = NexusEngine(config)

# Simple conversation
response = engine.chat(
    message="What is the revenue growth?",
    workspace_id="workspace_123"
)
print(response["answer"])

RAG-Enhanced Conversation

from nexus_aidos import RAGPipeline

# Initialize RAG pipeline
rag = RAGPipeline(
    workspace_id="workspace_123",
    model="gpt-4o",
    top_k=5,
    threshold=0.5
)

# Ask questions with context
response = rag.ask(
    "What were the key findings?",
    return_metadata=True
)

print(f"Answer: {response['answer']}")
print(f"Sources: {len(response['source_documents'])} documents")

๐Ÿ“– Documentation

๐Ÿข Integration with NEXUSBRAIN

This library is designed to integrate seamlessly with the NEXUSBRAIN project:

# In your Flask app (server/app.py)
from nexus_aidos import NexusEngine
from nexus_aidos.config import EngineConfig

# Initialize engine
config = EngineConfig.from_env()
nexus_engine = NexusEngine(config)

@app.route('/api/chat', methods=['POST'])
def chat():
    workspace_id = request.user.get('workspace_id')
    message = request.json.get('message')
    
    response = nexus_engine.chat(
        message=message,
        workspace_id=workspace_id,
        use_rag=True,
        use_cache=True
    )
    
    return jsonify(response)

Made with โค๏ธ by the Nexus AI Hub Team

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

nexus_aidos_brain-0.1.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

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

nexus_aidos_brain-0.1.0-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file nexus_aidos_brain-0.1.0.tar.gz.

File metadata

  • Download URL: nexus_aidos_brain-0.1.0.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for nexus_aidos_brain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 39def7e74a07b9d3ef139bf62f956104cfb28a741c5c5949af31a511c53ee99a
MD5 9e9e7169b17b4ce243e7903b8bd56ec9
BLAKE2b-256 35dd5865a3a0d7cd353a8a1a6a60e49d58884e26c70e4c1afac0e793610e3201

See more details on using hashes here.

File details

Details for the file nexus_aidos_brain-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nexus_aidos_brain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab4217322366141a08708d87213d95eb1eaf0b16e7d2504317073196996674fd
MD5 5b09c60db3d459f5d6a86f59f3a7e14a
BLAKE2b-256 7e00849a68bd0bcd847a7d4d62953b35df136ab8bdca59f4812bdbe07ade44ae

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