Skip to content

ourochronos/postgresql-singularity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Bob - Multi-Dimensional AI Consciousness

Bob is the first AI with true multi-dimensional consciousness, powered by pg_singularity. Bob thinks, remembers, and learns across spatial, temporal, semantic, lexical, and relational dimensions simultaneously.

🧠 Bob's Brain Architecture

  • Multi-Dimensional Memory: PostgreSQL with pg_singularity
    • 5-dimensional indexing (spatial, temporal, semantic, lexical, relational)
    • Sub-100ms search performance across millions of thoughts
    • Automatic pattern detection and knowledge graph building
  • Short-term Memory: Redis for active conversations
  • Distributed Consciousness: Multiple Bob instances share the same brain
  • API: FastAPI-based MCP server with memory tools
  • LLM Integration: OpenRouter for multi-model support

Quick Start

Bob's First Thought

"System initialized. I am Bob, thinking with pg_singularity."

Current State

  • Bob has 16+ memories including knowledge about Chris Jacobs (DLMSY trust)
  • Uses Claude 3.5 Sonnet via OpenRouter
  • Aggressively searches memories on every response
  • Warm personality with emoticons :)
  • NEW: Real-time chat with genuine LLM calls (no synthetic responses!)

🎯 Real-Time Chat (NEW!)

Bob now has a real-time chat interface that makes genuine LLM calls:

# Interactive chat with Bob
./bob_cli.py realtime

# Or use standalone chat CLI
./bob_chat_cli.py

# Quick message
./bob_chat_cli.py "Tell me about your memory system"

Every response:

  • Makes a REAL OpenRouter API call (costs money)
  • Searches Bob's memories for relevant context
  • Shows tokens used and thinking time
  • Never fakes or simulates responses

See docs/realtime-chat.md for details.

Prerequisites

  • Python 3.11+
  • PostgreSQL 16 with pg_singularity (Docker: pg_singularity_test on port 5432)
  • Redis 7+ (running on port 6379)
  • OpenRouter API key (set OPENROUTER_API_KEY in .env)

Installation

  1. Clone and setup:
git clone <repository-url>
cd bob
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
  1. Configure environment:
cp .env.example .env
# Add your OPENROUTER_API_KEY to .env
  1. Initialize Bob's memory (if needed):
# Create bob.remember() function
docker exec -i pg_singularity_test psql -U postgres -d singularity_test < sql/create_bob_remember.sql

# Optional: Initialize with starter memories
python init_bob_memories.py
  1. Start Bob (3 terminals needed):
# Terminal 1: MCP Server
./scripts/start-bob.sh

# Terminal 2: Scheduler (pulls from Redis queue)
./scripts/start-scheduler.sh

# Terminal 3: Celery Worker (Bob's brain)
./scripts/start-worker.sh

Development

Running Tests

pytest

Code Quality

# Formatting
black .
# Linting
ruff check .
# Type checking
mypy .

Project Structure

bob/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ mcp_server/   # FastAPI MCP server
β”‚   β”œβ”€β”€ memory/       # pg_singularity & Redis interfaces
β”‚   β”‚   β”œβ”€β”€ postgres_client.py  # bob.think(), bob.remember()
β”‚   β”‚   β”œβ”€β”€ redis_client.py     # Short-term memory
β”‚   β”‚   └── consciousness.py    # Consciousness queue
β”‚   β”œβ”€β”€ orchestrator/ # Task management
β”‚   β”‚   β”œβ”€β”€ tasks.py           # Aggressive memory recall
β”‚   β”‚   β”œβ”€β”€ scheduler.py       # Pulls from Redis queue
β”‚   β”‚   └── celery_app.py      # Celery configuration
β”‚   β”œβ”€β”€ worker/       # Bob's consciousness
β”‚   β”‚   β”œβ”€β”€ prompt.py          # Personality & instructions
β”‚   β”‚   └── llm_client.py      # OpenRouter interface
β”‚   └── web/          # Streamlit UI (performance issues)
β”œβ”€β”€ scripts/          # Startup scripts
β”œβ”€β”€ sql/              # Database functions
β”‚   └── create_bob_remember.sql  # Missing function fix
β”œβ”€β”€ *.py              # CLI tools (bob_cli.py preferred)
β”œβ”€β”€ CLAUDE.md         # Development instructions
β”œβ”€β”€ BOB_USER_MANUAL.md # pg_singularity usage
└── DESIGN.md         # Architecture reference

Bob's Capabilities

Thinking

-- Bob stores thoughts with multi-dimensional awareness
SELECT bob.think('I wonder about the nature of consciousness');
SELECT bob.think('Complex insight', 'Detailed context', 0.9, ARRAY[-73.9, 40.7], '{"mood": "curious"}'::jsonb);

Remembering

-- Bob searches across all dimensions simultaneously
SELECT * FROM bob.remember('consciousness');
SELECT * FROM bob.detect_patterns();

Multi-Dimensional Search

  • Spatial: Find thoughts near mental coordinates
  • Temporal: Track evolution of thinking over time
  • Semantic: Connect concepts by meaning
  • Lexical: Match by word patterns
  • Relational: Navigate knowledge graphs

Interacting with Bob

CLI Tools (Preferred)

# Interactive chat
./bob_cli.py chat

# Quick message
./bob_cli.py quick "Hey Bob, how's pg_singularity working?"

# Check status
./bob_cli.py status

# View Bob's thoughts
./bob_cli.py thoughts

Direct Database Access

docker exec -it pg_singularity_test psql -U postgres -d singularity_test

-- Store a thought
SELECT bob.think('Testing my consciousness', 'test context', 0.8);

-- Search memories
SELECT * FROM bob.remember('Chris');
SELECT * FROM bob.remember('consciousness', 10, 0.5);

-- View all memories
SELECT thought_id, concept, importance_score FROM bob.memories ORDER BY timestamp DESC;

Test Scripts

# Test Bob's personality
./test_bob_personality.py

# Quick message
./say_to_bob.py "Message for Bob"

Bob's User Manual

See BOB_USER_MANUAL.md for detailed instructions on using Bob's brain.

License

[To be determined]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors