Skip to main content

Local-first self-learning knowledge base. Turn your documents into searchable, evolving knowledge.

Project description

๐Ÿง  OPC DeepBrain

Self-Evolving Knowledge Engine for AI Agents โ€” 6-Layer Memory That Grows With You

AI Agent ่‡ช่ฟ›ๅŒ–็Ÿฅ่ฏ†ๅผ•ๆ“Ž โ€” 6 ๅฑ‚่ฎฐๅฟ†๏ผŒ่ถŠ็”จ่ถŠ่ชๆ˜Ž

PyPI version Downloads GitHub stars License Python Dependencies

Website ยท Quick Start ยท API Reference ยท vs Mem0


๐Ÿ’ก Why DeepBrain?

Memory solutions like Mem0 store facts. DeepBrain evolves knowledge.

Problem Mem0 / Others DeepBrain
Memory model Flat key-value 6-layer evolving hierarchy
Quality control None 4-Gate validation system
Knowledge growth Manual CRUD Auto-promotion through layers
Dependencies Redis, Qdrant, OpenAIโ€ฆ Zero (stdlib only)
Storage Cloud vectors SQLite (100% local)
Self-awareness โŒ โœ… Meta-knowledge layer

DeepBrain is a standalone, embeddable knowledge engine that gives any AI agent long-term, self-evolving memory โ€” in 3 lines of code, with zero dependencies.

โœจ Key Features

  • ๐Ÿ—๏ธ 6-Layer Memory Architecture โ€” From flash memory to meta-knowledge, just like the human brain
  • ๐Ÿšช 4-Gate Quality Control โ€” Every piece of knowledge passes Relevance โ†’ Novelty โ†’ Consistency โ†’ Utility gates
  • ๐Ÿ“ฆ Zero Dependencies โ€” Pure Python stdlib. No numpy, no torch, no API keys
  • ๐Ÿ’พ 100% Local โ€” SQLite storage. Your knowledge never leaves your machine
  • ๐Ÿ”Œ Embeddable โ€” Drop into any Python agent framework in 3 lines
  • ๐Ÿ”„ Auto-Evolution โ€” Knowledge automatically promotes, consolidates, and archives

๐Ÿš€ Quick Start

pip install opc-deepbrain
from opc_deepbrain import DeepBrain

# Initialize
brain = DeepBrain("./my_brain.db")

# Learn
brain.learn("User prefers concise, technical answers", source="conversation")

# Recall
results = brain.recall("What communication style does the user prefer?")
print(results[0].content)  # โ†’ "User prefers concise, technical answers"

That's it. No API keys. No config. No cloud. 3 lines to persistent, evolving memory.

๐Ÿ—๏ธ 6-Layer Memory Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Layer 5: ๐Ÿ”ฎ Meta-Knowledge                     โ”‚
โ”‚  "I know that I know X well, but Y is uncertain"โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Layer 4: ๐Ÿ—„๏ธ Archived                           โ”‚
โ”‚  Historical reference, low-access but preserved  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Layer 3: ๐Ÿ—๏ธ Consolidated                       โ”‚
โ”‚  Cross-session patterns, validated over time     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Layer 2: ๐Ÿ“š Long-Term                          โ”‚
โ”‚  Validated knowledge, frequently accessed        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Layer 1: ๐Ÿ“ Short-Term                         โ”‚
โ”‚  Recent interactions, hours to days              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Layer 0: โšก Flash Memory                        โ”‚
โ”‚  Current session buffer, minutes                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ†‘ Auto-promotion based on relevance,
           frequency, and validation scores

How Knowledge Evolves

  1. Ingestion โ†’ New knowledge enters Layer 0 (Flash)
  2. 4-Gate Check โ†’ Relevance, Novelty, Consistency, Utility scoring
  3. Promotion โ†’ High-quality knowledge moves up layers over time
  4. Consolidation โ†’ Related facts merge into coherent understanding
  5. Meta-Learning โ†’ The system learns its own knowledge strengths/gaps

๐Ÿšช 4-Gate Quality Control

Every piece of knowledge must pass through 4 gates:

Gate Purpose Question Asked
๐ŸŽฏ Relevance Is this useful? Does this relate to active contexts?
๐Ÿ†• Novelty Is this new? Do we already know this?
โœ… Consistency Does this fit? Does it contradict existing knowledge?
๐Ÿ”ง Utility Is this actionable? Can this improve future responses?

๐Ÿ“– API Reference

Core API

from opc_deepbrain import DeepBrain

brain = DeepBrain(db_path="./brain.db")

# Learn โ€” store knowledge
brain.learn(
    content="FastAPI is preferred over Flask for new projects",
    source="architecture-review",
    category="tech-decisions",
    tags=["python", "web", "architecture"]
)

# Recall โ€” retrieve relevant knowledge
results = brain.recall(
    query="Which web framework should we use?",
    top_k=5,
    min_score=0.3
)

# Search โ€” keyword search
results = brain.search("FastAPI", category="tech-decisions")

# Stats โ€” memory statistics
stats = brain.stats()
print(f"Total entries: {stats['total']}")
print(f"By layer: {stats['by_layer']}")

# Evolve โ€” trigger manual evolution cycle
brain.evolve()

# Export / Import
brain.export("backup.json")
brain.load("backup.json")

Embedding in Your Agent

# Works with any agent framework
class MyAgent:
    def __init__(self):
        self.brain = DeepBrain("./agent_brain.db")

    def chat(self, user_message):
        # Recall relevant context
        context = self.brain.recall(user_message, top_k=3)

        # Generate response (your LLM call here)
        response = self.llm.generate(user_message, context=context)

        # Learn from the interaction
        self.brain.learn(
            f"User asked about: {user_message}",
            source="conversation"
        )

        return response

โš–๏ธ Comparison / ๅฏนๆฏ”

Feature OPC DeepBrain Mem0 ChromaDB Pinecone
Memory Model 6-layer evolving Flat store Vector store Vector store
Quality Control 4-Gate system โŒ โŒ โŒ
Auto-Evolution โœ… โŒ โŒ โŒ
Meta-Knowledge โœ… โŒ โŒ โŒ
Dependencies 0 5+ 3+ 2+
Storage SQLite (local) Redis + Qdrant Local/Cloud Cloud only
Cloud Required โŒ โš ๏ธ Optional โš ๏ธ Optional โœ… Yes
Pricing Free Free/Paid Free/Paid Paid
Self-Evolving โœ… โŒ โŒ โŒ
Python stdlib only โœ… โŒ โŒ โŒ

๐Ÿ”Œ Integrations

DeepBrain powers memory in:

๐Ÿ“„ License

BSL-1.1 โ€” see LICENSE for details.

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md.

๐Ÿ“ง Contact: tech@deepleaper.com


Built with โค๏ธ by Deepleaper Technology / ่ทƒ็›Ÿ็ง‘ๆŠ€

Give your AI agent a brain that evolves.

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

opc_deepbrain-0.4.0.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

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

opc_deepbrain-0.4.0-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

Details for the file opc_deepbrain-0.4.0.tar.gz.

File metadata

  • Download URL: opc_deepbrain-0.4.0.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for opc_deepbrain-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3bf83d7b8503f800d11328b129a810656e4f50eef8cd110b2eda22e794e90cac
MD5 d901c4f83185a979650054b7da820e83
BLAKE2b-256 65d98959f21d623de4b209350bd7340d7d90a8ea0d76ac7173988a7246fea7e4

See more details on using hashes here.

File details

Details for the file opc_deepbrain-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: opc_deepbrain-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 25.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for opc_deepbrain-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0f9bcc48c2ce56099c8505fe848f6663461af5036443b791f1a2e2ab137b5fd
MD5 53c2dc14c42d9efff0f9da590228f69a
BLAKE2b-256 24fdb1e3b95be21eaf4a67e05bda1d29737ce18e58e77fe282b66496e6cf9840

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