Skip to content

Commit 07f8736

Browse files
author
Robert Trenaman
committed
Initial commit: Cognitive Engine with explicit thought formation architecture
0 parents  commit 07f8736

131 files changed

Lines changed: 40639 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Cognitive Engine Configuration
2+
# Copy this file to .env and add your API keys
3+
4+
# OpenAI API Configuration
5+
OPENAI_API_KEY=your_openai_api_key_here
6+
7+
# Anthropic API Configuration (optional)
8+
ANTHROPIC_API_KEY=your_anthropic_api_key_here
9+
10+
# LLM Provider Selection
11+
DEFAULT_LLM_PROVIDER=openai
12+
13+
# Model Configuration
14+
DEFAULT_MODEL=gpt-4
15+
TEMPERATURE=0.7
16+
MAX_TOKENS=2000
17+
18+
# Cognitive Layer Configuration
19+
MAX_THOUGHTS_PER_GENERATION=5
20+
MAX_DELIBERATION_ITERATIONS=3
21+
CONFIDENCE_THRESHOLD=0.7
22+
SCORE_THRESHOLD=0.5
23+
24+
# Meta-Cognition Configuration
25+
MIN_ITERATIONS=1
26+
MAX_ITERATIONS=10
27+
EARLY_STOP_CONFIDENCE=0.95
28+
29+
# Memory Configuration
30+
MEMORY_BACKEND=sqlite
31+
MEMORY_PATH=cognitive_engine.db
32+
MAX_MEMORY_ENTRIES=10000
33+
34+
# Agent Configuration
35+
MAX_AGENT_STEPS=50
36+
AGENT_TIMEOUT_SECONDS=300
37+
38+
# Learning Configuration
39+
PATTERN_EXTRACTION_INTERVAL=100
40+
PATTERN_CONFIDENCE_THRESHOLD=0.8
41+
42+
# Prompt Evolution Configuration
43+
ENABLE_PROMPT_EVOLUTION=false
44+
PROMPT_EVOLUTION_INTERVAL=1000
45+
MUTATION_RATE=0.1
46+
47+
# Dashboard Configuration
48+
ENABLE_DASHBOARD=true
49+
DASHBOARD_HOST=localhost
50+
DASHBOARD_PORT=8000
51+
52+
# Logging Configuration
53+
LOG_LEVEL=INFO
54+
LOG_FILE=cognitive_engine.log

.gitignore

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Environment variables
2+
.env
3+
4+
# Python
5+
__pycache__/
6+
*.py[cod]
7+
*$py.class
8+
*.so
9+
.Python
10+
venv/
11+
env/
12+
ENV/
13+
.venv
14+
15+
# Database
16+
*.db
17+
*.sqlite
18+
*.sqlite3
19+
cognitive_engine.db
20+
21+
# Logs
22+
*.log
23+
cognitive_engine.log
24+
25+
# Documentation (excluded per request)
26+
docs/
27+
28+
# Training data and weights
29+
neural_network_weights.npz
30+
llm_training_data.json
31+
32+
# Reasoning traces
33+
reasoning_traces/
34+
35+
# IDE
36+
.vscode/
37+
.idea/
38+
*.swp
39+
*.swo
40+
*~
41+
42+
# OS
43+
.DS_Store
44+
Thumbs.db
45+
46+
# Memory and knowledge files (runtime data)
47+
cognitive_memory.json
48+
cognitive_knowledge.json
49+
50+
# Testing
51+
.pytest_cache/
52+
.coverage
53+
htmlcov/
54+
55+
# Jupyter Notebooks
56+
.ipynb_checkpoints/
57+
*.ipynb
58+
59+
# Temporary files
60+
*.tmp
61+
*.bak
62+
*.cache

README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Cognitive Engine
2+
3+
An AI system with explicit, persistent, and inspectable thought formation.
4+
5+
## Overview
6+
7+
The Cognitive Engine transforms AI from answering to thinking, from reacting to reasoning, from output to cognition. It implements a 4-part cognitive architecture with thought objects, three-layer memory, autonomous agent capabilities, learning systems, prompt evolution, and real-time cognitive telemetry.
8+
9+
## Architecture
10+
11+
### Core Components
12+
13+
- **Models**: Thought and ProblemState objects for structured cognition
14+
- **Layers**: Interpreter, Generator, Deliberator, Committer, Meta-Cognition
15+
- **Utilities**: Scoring, Memory (SQLite), Logging
16+
- **LLM Integration**: OpenAI/Anthropic client with layer-specific prompts
17+
18+
### Advanced Features
19+
20+
- **Autonomous Agent**: Think → Plan → Act → Observe → Reflect loop
21+
- **Tools**: Web search, code execution with safety constraints
22+
- **Learning**: Pattern extraction, rule synthesis, knowledge injection
23+
- **Prompt Evolution**: A/B testing, controlled self-improvement with rollback
24+
- **Dashboard**: Real-time WebSocket cognitive telemetry
25+
26+
## Installation
27+
28+
```bash
29+
# Create virtual environment
30+
python3 -m venv venv
31+
source venv/bin/activate
32+
33+
# Install dependencies
34+
pip install -r requirements.txt
35+
```
36+
37+
## Usage
38+
39+
### Interactive Mode
40+
41+
```bash
42+
python run.py
43+
# or
44+
python run.py interactive
45+
```
46+
47+
### Agent Mode
48+
49+
```bash
50+
python run.py agent
51+
```
52+
53+
### Dashboard Mode
54+
55+
```bash
56+
python run.py dashboard
57+
```
58+
59+
### Test Mode
60+
61+
```bash
62+
python run.py test
63+
```
64+
65+
## Configuration
66+
67+
Set environment variables or create `.env` file:
68+
69+
```
70+
OPENAI_API_KEY=your_key
71+
ANTHROPIC_API_KEY=your_key
72+
DEFAULT_LLM_PROVIDER=openai
73+
ENABLE_DASHBOARD=true
74+
```
75+
76+
## Project Structure
77+
78+
```
79+
cognitive_engine/
80+
├── core/ # Engine orchestration
81+
├── models/ # Thought and state objects
82+
├── layers/ # Cognitive layers
83+
├── utils/ # Scoring, memory, logging
84+
├── llm/ # LLM client and prompts
85+
├── agent/ # Autonomous agent
86+
├── tools/ # Tool registry
87+
├── learning/ # Pattern extraction and learning
88+
├── prompt_evolution/ # Prompt optimization
89+
├── dashboard/ # WebSocket telemetry
90+
├── ui/ # Dashboard frontend
91+
└── run.py # Entry point
92+
```
93+
94+
## Key Features
95+
96+
- **Explicit Thought Formation**: Thoughts are structured objects with state, history, and evaluative properties
97+
- **Three-Layer Memory**: Episodic (raw events), Pattern (structure extraction), Rule (learned strategies)
98+
- **Meta-Cognition**: Oversight layer governing thinking depth and stopping conditions
99+
- **Controlled Evolution**: Self-modification with A/B testing, evaluation, and rollback capability
100+
- **Cognitive Telemetry**: Real-time dashboard observing thought formation
101+
- **Safeguards**: Step limits, tool restrictions, goal validation, memory control
102+
103+
## License
104+
105+
MIT License

agent/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
Autonomous Agent for the Cognitive Engine
3+
"""
4+
5+
from .agent import CognitiveAgent
6+
from .goals import Goal, GoalManager, GoalStatus, GoalPriority
7+
from .planner import Planner, PlanStep
8+
from .executor import Executor
9+
from .observer import Observer
10+
11+
__all__ = [
12+
'CognitiveAgent',
13+
'Goal',
14+
'GoalManager',
15+
'GoalStatus',
16+
'GoalPriority',
17+
'Planner',
18+
'PlanStep',
19+
'Executor',
20+
'Observer'
21+
]

0 commit comments

Comments
 (0)