Skip to main content

Self-Healing Knowledge Graph for RAG Pipelines - pip-installable library

Project description

๐Ÿ›ก๏ธ Sentinel: Self-Healing Temporal Knowledge Graph

Sentinel is an autonomous knowledge graph that automatically scrapes, extracts, stores, and maintains structured knowledge from the web. It uses AI to understand content, tracks changes over time, and heals itself when information becomes stale.

Python 3.11+ License: MIT Code style: black

๐ŸŒŸ Key Features

  • ๐Ÿค– Autonomous: Automatically scrapes, extracts, and updates knowledge
  • โฐ Temporal: Track how knowledge evolves over time
  • ๐Ÿ”ง Self-Healing: Detects and updates stale information automatically
  • ๐Ÿง  AI-Powered: Uses LLMs to extract entities and relationships
  • ๐Ÿ“Š Graph-Based: Stores knowledge in a Neo4j temporal graph
  • ๐ŸŒ Web Scraping: Intelligent scraping with Firecrawl or local fallback
  • ๐Ÿ’ป Developer-Friendly: Simple Python API and CLI tool
  • ๐ŸŽจ Beautiful UI: 3D graph visualization with Next.js

๐Ÿš€ Quick Start

Installation

pip install sentinel-core[all]

Setup

# Interactive setup wizard
python sentinel_cli.py init

# Or manually create .env file
cat > .env << EOF
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=your-password
OLLAMA_MODEL=ollama/phi3
EOF

Start Services

# Start Neo4j
docker run -d -p 7687:7687 -p 7474:7474 \
  -e NEO4J_AUTH=neo4j/password \
  neo4j:latest

# Start Ollama (for local LLM)
ollama serve
ollama pull phi3

Your First Knowledge Graph

# Process a URL
python sentinel_cli.py watch https://stripe.com/pricing

# Check status
python sentinel_cli.py status

# View in UI
cd sentinel_platform/ui
npm install && npm run dev
# Visit http://localhost:3000

๐Ÿ“š Usage

Python API

import asyncio
from sentinel_core import Sentinel, GraphManager, GraphExtractor
from sentinel_core.scraper import get_scraper

async def main():
    # Initialize
    graph = GraphManager()
    scraper = get_scraper()
    extractor = GraphExtractor(model_name="ollama/phi3")
    sentinel = Sentinel(graph, scraper, extractor)
    
    # Process URL
    result = await sentinel.process_url("https://example.com")
    print(f"Extracted {result['extracted_nodes']} nodes!")
    
    # Query graph
    snapshot = graph.get_graph_snapshot()
    print(f"Total: {snapshot['metadata']['node_count']} nodes")
    
    graph.close()

asyncio.run(main())

CLI Tool

# Show version
python sentinel_cli.py version

# Check system status
python sentinel_cli.py status

# Process a URL
python sentinel_cli.py watch https://example.com

# Run healing cycle
python sentinel_cli.py heal --days 7

# Interactive setup
python sentinel_cli.py init

๐ŸŽฏ Use Cases

1. Product Pricing Monitoring

Track pricing changes across competitors automatically.

urls = [
    "https://stripe.com/pricing",
    "https://paypal.com/pricing",
    "https://square.com/pricing"
]

for url in urls:
    await sentinel.process_url(url)

2. Documentation Tracking

Monitor documentation changes for your favorite libraries.

docs = {
    "React": "https://react.dev/learn",
    "Next.js": "https://nextjs.org/docs",
}

for name, url in docs.items():
    await sentinel.process_url(url)

# Auto-heal to detect changes
await sentinel.run_healing_cycle(days_threshold=7)

3. News Aggregation

Build a knowledge graph from multiple news sources.

news_sources = [
    "https://techcrunch.com/",
    "https://theverge.com/",
]

for url in news_sources:
    await sentinel.process_url(url)

4. Research Paper Tracking

Track research papers and their citations.

papers = [
    "https://arxiv.org/abs/2303.08774",  # GPT-4
    "https://arxiv.org/abs/2005.14165",  # GPT-3
]

for paper in papers:
    await sentinel.process_url(paper)

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Sentinel System                       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚ Scraper  โ”‚โ”€โ”€โ”€โ–ถโ”‚ Extractor โ”‚โ”€โ”€โ”€โ–ถโ”‚ Graph Store  โ”‚    โ”‚
โ”‚  โ”‚(Firecrawlโ”‚    โ”‚  (LLM +   โ”‚    โ”‚   (Neo4j)    โ”‚    โ”‚
โ”‚  โ”‚or Local) โ”‚    โ”‚Instructor)โ”‚    โ”‚   Temporal   โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”‚       โ”‚                                    โ”‚            โ”‚
โ”‚       โ”‚          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚            โ”‚
โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚ Sentinel  โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ”‚                  โ”‚Orchestratorโ”‚                         โ”‚
โ”‚                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                         โ”‚
โ”‚                       โ”‚                                 โ”‚
โ”‚                       โ–ผ                                 โ”‚
โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                       โ”‚
โ”‚              โ”‚  Healing Loop   โ”‚                       โ”‚
โ”‚              โ”‚ (Auto-Updates)  โ”‚                       โ”‚
โ”‚              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                       โ”‚
โ”‚                                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“– Documentation

๐Ÿ› ๏ธ Development

Setup Development Environment

# Clone repository
git clone https://github.com/Om7035/Sentinel-The-Self-Healing-Knowledge-Graph
cd Sentinel-The-Self-Healing-Knowledge-Graph

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -e ".[all]"

# Run tests
pytest tests/

Project Structure

sentinel/
โ”œโ”€โ”€ sentinel_core/          # Core library (pip-installable)
โ”‚   โ”œโ”€โ”€ scraper/           # Web scraping (Firecrawl + Local)
โ”‚   โ”œโ”€โ”€ graph_store.py     # Neo4j temporal graph
โ”‚   โ”œโ”€โ”€ graph_extractor.py # LLM-based extraction
โ”‚   โ””โ”€โ”€ orchestrator.py    # Main Sentinel class
โ”œโ”€โ”€ sentinel_platform/     # Demo platform
โ”‚   โ”œโ”€โ”€ api/              # FastAPI backend
โ”‚   โ””โ”€โ”€ ui/               # Next.js frontend
โ”œโ”€โ”€ tests/                # Test suite
โ”œโ”€โ”€ docs/                 # Documentation
โ””โ”€โ”€ sentinel_cli.py       # CLI tool

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“ License

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

๐Ÿ™ Acknowledgments

  • Built with LangChain, Neo4j, and FastAPI
  • Inspired by the need for self-maintaining knowledge systems
  • Special thanks to the open-source community

๐Ÿ“ง Contact

โญ Star History

If you find Sentinel useful, please consider giving it a star! โญ


Made with โค๏ธ by Om Kawale

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

sentinel_core-0.1.4.tar.gz (32.6 kB view details)

Uploaded Source

Built Distribution

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

sentinel_core-0.1.4-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

Details for the file sentinel_core-0.1.4.tar.gz.

File metadata

  • Download URL: sentinel_core-0.1.4.tar.gz
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for sentinel_core-0.1.4.tar.gz
Algorithm Hash digest
SHA256 11d6400178422d85f03e1f3c1bfcfb89d9e5e73b74f13544c8b656b8555dee9a
MD5 ea5198dd0d5da160083ddd18d7ec98c8
BLAKE2b-256 ae2f86332d803a68c1f3413f4c7d4025c51087256707e401e233f856319bfae5

See more details on using hashes here.

File details

Details for the file sentinel_core-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: sentinel_core-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 37.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for sentinel_core-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9a4837fa56f8cfc1f4d78b88b683624748d4369b6b5e9675f62d6c6f45781b8f
MD5 eaffd1f685a8530e044f658cfbd4cd9b
BLAKE2b-256 ef2742eda0314c93fc7e22164fd5bea95908538a6da0c63f2b24db935256f6cd

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