Cognitive processing system for HEAVEN - Handles knowledge synthesis across any corpus size
Project description
Brain Agent
Neural-inspired knowledge retrieval system built on heaven-base.
Overview
Brain Agent provides a sophisticated system for organizing and querying knowledge from document collections. It uses a "neural" metaphor where documents become "neurons" that can be activated based on relevance to queries.
Components
- BrainAgent: Main agent class for knowledge retrieval
- CognizeTool: Identifies relevant neurons for a query
- InstructTool: Generates instructions from activated neurons
- QueryBrainTool: Simple interface for querying registered brains
- SynthesizerReplicant: Alternative replicant-based interface
Installation
# Install heaven-base first
pip install git+https://github.com/sancovp/heaven-base.git@v1.2.0
# Install brain-agent
pip install -e .
Usage
from brain_agent import BrainAgent, register_brain
# Register a brain (document collection)
register_brain(
directory="/path/to/documents",
brain_name="my_knowledge_base",
chunk_size=-1 # whole files
)
# Create and query brain agent
agent = BrainAgent()
result = await agent.query("brain=my_knowledge_base query=What is machine learning?")
Dependencies
- heaven-base>=1.2.0 (for core agent framework)
- langchain-core (for message types)
- Various LLM providers (OpenAI, Google, etc.)
License
Private - All rights reserved.
Hierarchical Brains (v0.2.0)
Brains whose neurons are brains. A Brain implements the same 2-stage Neuron
protocol its own neurons use — cognize (cheap relevance vote off the brain's
_digest.md) and instruct (a full recursive cognize→instruct→synthesize
pass) — so hierarchies nest to arbitrary depth. Digests build bottom-up
(build_digests): the level touching raw files gets an LLM fold; levels above
concatenate child digests verbatim, so distinctive vocabulary survives to the
root.
from brain_agent.hierarchical import Brain, build_digests
await build_digests(Path("corpus")) # the pyramid is just directories
answer = await Brain(Path("corpus")).query("...")
HTTP server (judge + fill)
brain-agent-http serves the brain over HTTP for coordinate/configuration
engines: the caller owns addressing (which parts exist, which slots are empty);
the server owns judgment and generation.
POST /judge— {parts, rule} → one verdict per part (complies / violates / not_applicable) with a verbatim witness quote, machine-verified to appear in the source (witness_verified). Exhaustive: every part judged, none skipped. Returns aglobal_sectionflag (no violations anywhere).POST /fill— {slot_label, siblings, n, brain_root?} → candidate spectrum completions; ifbrain_rootis given the proposals are grounded in a witnessed brain synthesis (groundedflag reports honestly).POST /brains/build,POST /brains/query,POST /neuron/cognize,POST /neuron/instruct,GET /health.
Models: any Anthropic-compatible endpoint (HBRAIN_MODEL, default
MiniMax-M2.7-highspeed via MINIMAX_API_KEY; Claude models via
ANTHROPIC_API_KEY).
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file brain_agent-0.2.0.tar.gz.
File metadata
- Download URL: brain_agent-0.2.0.tar.gz
- Upload date:
- Size: 39.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d311ae9bb013045006b0402bec3ae37e09611c6dd4d6923236f7e52ac2976ef7
|
|
| MD5 |
faf4827f92dfa3249950058f6560218b
|
|
| BLAKE2b-256 |
1c64a16bd2d34fb7f10a0df041afdc83322241179c36278a6e691adc4119cde4
|
File details
Details for the file brain_agent-0.2.0-py3-none-any.whl.
File metadata
- Download URL: brain_agent-0.2.0-py3-none-any.whl
- Upload date:
- Size: 32.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c07126a0274ded736ce547245782d5c956e74de6b1a1363bf5e757b360213b19
|
|
| MD5 |
fa2de7c8194fd77e34d0c55a0887b50e
|
|
| BLAKE2b-256 |
4b5555ab3d5fd865326e8511b25ed89ba8808655ce889ed656e2e5e03b8015b3
|