Ghost Brain
The intelligent AI brain component for the Ghost project, providing memory management, RAG capabilities, and LLM integration.
Features
- Memory Management: SQLite-based conversation history with embeddings
- RAG System: Semantic search with citations using
txtai - LLM Integration: Support for OpenAI and Google Gemini models
- HTTP API: RESTful interface for plugin communication
- Intelligent Chunking: Automatic conversation segmentation and summarization
- Flexible Deployment: Run locally, on remote desktops, or in the cloud
- Mobile Support: Connect mobile Obsidian to desktop brain servers
Installation
pip install -e .
Usage
Command Line Interface (CLI)
Ghost Brain provides a comprehensive CLI for easy configuration and server management:
# Start server with default settings
ghost-brain server
# Start server on custom port
ghost-brain server --port 9000
# Start server with debug logging
ghost-brain server --host 0.0.0.0 --port 8000 --log-level debug
# Start server with custom database and backend
ghost-brain server --db-path ./data/memory.db --memory-backend txtai
# Show current configuration
ghost-brain config
# Show configuration in JSON format
ghost-brain config --format json
# Show environment variables documentation
ghost-brain env-docs
# Show version information
ghost-brain version
CLI Commands
| Command | Description | Options |
|---|---|---|
server |
Start the brain server | --host, --port, --log-level, --reload, --db-path, --memory-backend, etc. |
config |
Show current configuration | --format {text,json,env} |
env-docs |
Show environment variables documentation | None |
version |
Show version information | None |
CLI Examples
Development
# Start with auto-reload for development
ghost-brain server --reload --log-level debug
# Use custom database path
ghost-brain server --db-path ./dev/memory.db
# Override multiple settings
ghost-brain server --port 9000 --memory-backend txtai --temperature 0.5
Production
# Start on all interfaces
ghost-brain server --host 0.0.0.0 --port 8000
# Use production settings
ghost-brain server --log-level info --memory-backend txtai
Configuration Management
# Check current configuration
ghost-brain config
# Export configuration as environment variables
ghost-brain config --format env > .env
# Get configuration in JSON for automation
ghost-brain config --format json
As a Service
ghost-brain
As a Python Package
from ghost_brain import Brain
brain = Brain()
response = await brain.process_message("Hello, how are you?")
Deployment Options
Local Development
# Start brain server locally
python -m ghost_brain.server
# Default: http://localhost:8000
Remote Desktop (for mobile users)
# Install on desktop
python -m pip install ghost-brain
# Start brain server
python -m ghost_brain.server
# Find desktop IP
ifconfig # Mac/Linux
ipconfig # Windows
# Mobile users connect to: http://YOUR_DESKTOP_IP:8000
Cloud Deployment
# Deploy to Railway, Heroku, etc.
# Users connect to: https://your-deployment-url.com
Team Sharing
# Deploy to shared server
# All team members use same URL in their Obsidian settings
Development
# Create the dev environment
pip install -r requirements.txt
# Install in editable mode
pip install -e .
# Run tests
pytest
# Start development server
uvicorn ghost_brain.server:app --reload
API Endpoints
POST /chat- Process a chat messageGET /health- Health checkPOST /memory/search- Search memoryGET /memory/stats- Get memory statisticsGET /settings- Get current settingsPOST /settings- Update settings
Configuration
Ghost Brain can be configured entirely through environment variables, making it perfect for cloud deployments, Docker containers, and team sharing.
Environment Variables (Recommended)
The brain server supports comprehensive configuration via environment variables:
# API Keys
OPENAI_API_KEY=sk-your-openai-key
GEMINI_API_KEY=your-gemini-key
# Server Configuration
BRAIN_SERVER_PORT=8000
BRAIN_SERVER_HOST=0.0.0.0
# Memory Configuration
BRAIN_DB_PATH=./data/memory.db
BRAIN_MEMORY_BACKEND=txtai
# General Settings
BRAIN_LOG_LEVEL=info
BRAIN_SYSTEM_PROMPT="You are a helpful AI assistant."
📖 Complete Environment Variables Documentation
Quick Configuration Examples
Local Development
# Start with custom port
BRAIN_SERVER_PORT=9000 python -m ghost_brain.server
# Start with debug logging
BRAIN_LOG_LEVEL=debug python -m ghost_brain.server
Cloud Deployment (Railway)
# Set in Railway environment variables
OPENAI_API_KEY=sk-your-key
BRAIN_SERVER_HOST=0.0.0.0
BRAIN_SERVER_PORT=8000
BRAIN_DB_PATH=/app/data/memory.db
Team Sharing
# Shared server configuration
BRAIN_SERVER_HOST=0.0.0.0
BRAIN_SERVER_PORT=8000
BRAIN_DB_PATH=/shared/memory.db
BRAIN_MEMORY_BACKEND=txtai
Brain Server Settings (Obsidian Plugin)
The Obsidian plugin supports configurable brain server connections:
- Local Mode: Default localhost:8000 configuration
- Custom Mode: Connect to any brain server URL
- Port Configuration: Customize local brain server port
- Status Monitoring: Real-time connection health checks
Settings Interface
brainServer: {
useCustomBrainServer: boolean;
brainServerUrl: string;
brainServerPort: number;
}
Configuration Testing
Test your configuration:
# Run configuration test
python test_environment_config.py
# Check configuration via API
curl http://localhost:8000/config/environment-variables
Architecture
The brain consists of several core modules:
- Memory Manager: Handles conversation storage and retrieval
- LLM Handler: Manages API calls to language models
- RAG Engine: Provides semantic search capabilities
- HTTP Server: Exposes functionality via REST API
- Settings Manager: Handles configuration and deployment options
Use Cases
Desktop Users
- Default localhost:8000 configuration
- No changes needed
- Brain server runs on same machine
Mobile Users
- Install brain on desktop
- Use desktop IP address in mobile settings
- No Python installation needed on mobile
Cloud/Team Users
- Deploy brain to cloud service
- Share one brain server across team members
- Centralized memory and processing
Testing
# Test brain server connectivity
python test_brain_server.py
# Test Obsidian integration
python test_obsidian_integration.py
# Test settings integration
python test_settings_integration.py
Contributing
We welcome contributions to Ghost Brain!
Adding New Chat Archive Importers
If you want to add support for importing chat archives from other AI providers (Claude, Gemini, Bing, etc.), please:
- Open an issue or discussion with a sample export file and format description.
- Submit a pull request with a new parser or endpoint for the provider's format.
- See CONTRIBUTING.md for detailed guidelines on code style, testing, and submitting PRs.
We encourage community contributions to expand Ghost Brain's compatibility with more chat platforms!
Metadata
Release files for ghost-brain 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ghost-brain-0.1.3.tar.gz | 27.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ghost_brain-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 56.0 kB
Release files / ghost-brain-0.1.3.tar.gz
| Download URL | ghost-brain-0.1.3.tar.gz |
|---|---|
| Size | 27.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8945fc75fea80dbacacdcd5ba2391f335a721d426d5b523b6df1cb45b857fce9
|
|
BLAKE2b-256 checksum How to use checksums |
32255e069cd335db2d1c76d42370951573485f3ad648576d57240b2cf4cf3a96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Release files / ghost_brain-0.1.3-py3-none-any.whl
| Download URL | ghost_brain-0.1.3-py3-none-any.whl |
|---|---|
| Size | 28.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2d7172fad08783c5ab8b82efe8e8a7fbbc7aa83035b141424b368783bf39867c
|
|
BLAKE2b-256 checksum How to use checksums |
9a3281ff250de2b1cd86ac02ee52e34be9c251c56098a87f55b58c48570e3bbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Security for ghost-brain 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.