Spaces:
Running
Running
Commit ·
8146dee
1
Parent(s): 2302171
remove kafka
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- Orka Taxonomi.csv +1 -1
- README.md +3 -9
- coverage.xml +0 -0
- docs/CONFIGURATION.md +1 -1
- docs/DEVELOPER_GUIDE_INTELLIGENT_QA_FLOW.md +0 -2
- docs/GIT_TIMELINE_PROJECT_EVOLUTION.md +2 -2
- docs/KAFKA_SCHEMA_REGISTRY_SETUP.md +0 -320
- docs/MEMORY_BACKENDS.md +137 -164
- docs/MEMORY_SYSTEM_GUIDE.md +16 -22
- docs/ONTOLOGY.md +2 -9
- docs/README_BACKENDS.md +138 -153
- docs/SCHEMA_MANAGEMENT.md +0 -351
- docs/api-reference.md +1 -13
- docs/architecture.md +8 -8
- docs/best-practices.md +2 -2
- docs/faq.md +1 -1
- docs/getting-started.md +7 -7
- docs/index.md +5 -5
- docs/quickstart.md +2 -2
- docs/security.md +1 -1
- docs/sphinx/index.rst +0 -55
- docs/troubleshooting.md +17 -15
- docs/tutorials/getting-started-with-orka.md +2 -2
- docs/yaml-configuration-guide.md +3 -3
- examples/orka_framework_qa.yml +1 -5
- examples/routed_binary_memory_writer.yml +2 -6
- mypy.ini +0 -3
- orka/__init__.py +2 -3
- orka/cli/memory/commands.py +0 -14
- orka/cli/parser.py +4 -4
- orka/docker/README.md +100 -184
- orka/docker/V0.7.0_DOCKER_IMPROVEMENTS.md +0 -198
- orka/docker/cleanup-and-start.sh +1 -9
- orka/docker/cleanup.sh +2 -4
- orka/docker/docker-compose.yml +2 -149
- orka/docker/start-dual.sh +0 -78
- orka/docker/start-kafka.bat +0 -84
- orka/docker/start-kafka.sh +0 -84
- orka/docker/start-redis.bat +32 -16
- orka/fork_group_manager.py +2 -2
- orka/memory/__init__.py +3 -74
- orka/memory/base_logger.py +1 -1
- orka/memory/file_operations.py +7 -11
- orka/memory/kafka_logger.py +0 -586
- orka/memory/schema_manager.py +0 -321
- orka/memory_logger.py +47 -121
- orka/orchestrator/base.py +22 -52
- orka/orka_start.py +11 -26
- orka/schemas/avro/memory_entry.avsc +0 -116
- orka/schemas/protobuf/memory_entry.proto +0 -52
Orka Taxonomi.csv
CHANGED
|
@@ -12,7 +12,7 @@
|
|
| 12 |
11,7,Synthesis Agent
|
| 13 |
12,7,Consensus Scoring
|
| 14 |
13,1,Observability
|
| 15 |
-
14,13,Trace Logging (Redis/
|
| 16 |
15,13,Execution Replay
|
| 17 |
16,13,Metrics & Telemetry
|
| 18 |
17,13,Langfuse Evaluation Hooks
|
|
|
|
| 12 |
11,7,Synthesis Agent
|
| 13 |
12,7,Consensus Scoring
|
| 14 |
13,1,Observability
|
| 15 |
+
14,13,Trace Logging (Redis/RedisStack)
|
| 16 |
15,13,Execution Replay
|
| 17 |
16,13,Metrics & Telemetry
|
| 18 |
17,13,Langfuse Evaluation Hooks
|
README.md
CHANGED
|
@@ -65,9 +65,9 @@ Get OrKa running with enterprise-grade performance in 2 minutes:
|
|
| 65 |
|
| 66 |
```bash
|
| 67 |
# 1. Install OrKa with all dependencies
|
| 68 |
-
pip install orka-reasoning fastapi uvicorn
|
| 69 |
|
| 70 |
-
# Optional: Install
|
| 71 |
pip install orka-reasoning[schema]
|
| 72 |
|
| 73 |
# 2. Create a .env file in your project directory
|
|
@@ -99,9 +99,6 @@ source .env
|
|
| 99 |
# For RedisStack (default, includes vector search):
|
| 100 |
orka-start
|
| 101 |
|
| 102 |
-
# For Kafka streaming:
|
| 103 |
-
ORKA_MEMORY_BACKEND=kafka orka-start
|
| 104 |
-
|
| 105 |
# For basic Redis (no vector search):
|
| 106 |
ORKA_MEMORY_BACKEND=redis ORKA_FORCE_BASIC_REDIS=true orka-start
|
| 107 |
|
|
@@ -782,11 +779,8 @@ orka run ./my-workflow.yml "Your input here"
|
|
| 782 |
# Check system health
|
| 783 |
orka system status
|
| 784 |
|
| 785 |
-
# Start OrKa with
|
| 786 |
orka-redis
|
| 787 |
-
|
| 788 |
-
# Start OrKa with Kafka (for production)
|
| 789 |
-
orka-kafka
|
| 790 |
```
|
| 791 |
|
| 792 |
---
|
|
|
|
| 65 |
|
| 66 |
```bash
|
| 67 |
# 1. Install OrKa with all dependencies
|
| 68 |
+
pip install orka-reasoning fastapi uvicorn
|
| 69 |
|
| 70 |
+
# Optional: Install additional features
|
| 71 |
pip install orka-reasoning[schema]
|
| 72 |
|
| 73 |
# 2. Create a .env file in your project directory
|
|
|
|
| 99 |
# For RedisStack (default, includes vector search):
|
| 100 |
orka-start
|
| 101 |
|
|
|
|
|
|
|
|
|
|
| 102 |
# For basic Redis (no vector search):
|
| 103 |
ORKA_MEMORY_BACKEND=redis ORKA_FORCE_BASIC_REDIS=true orka-start
|
| 104 |
|
|
|
|
| 779 |
# Check system health
|
| 780 |
orka system status
|
| 781 |
|
| 782 |
+
# Start OrKa with RedisStack (recommended)
|
| 783 |
orka-redis
|
|
|
|
|
|
|
|
|
|
| 784 |
```
|
| 785 |
|
| 786 |
---
|
coverage.xml
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
docs/CONFIGURATION.md
CHANGED
|
@@ -46,7 +46,7 @@ orchestrator:
|
|
| 46 |
strategy: sequential
|
| 47 |
memory_config:
|
| 48 |
# Backend selection
|
| 49 |
-
backend: redisstack # Options: redis, redisstack
|
| 50 |
|
| 51 |
# Memory decay configuration
|
| 52 |
decay:
|
|
|
|
| 46 |
strategy: sequential
|
| 47 |
memory_config:
|
| 48 |
# Backend selection
|
| 49 |
+
backend: redisstack # Options: redis, redisstack
|
| 50 |
|
| 51 |
# Memory decay configuration
|
| 52 |
decay:
|
docs/DEVELOPER_GUIDE_INTELLIGENT_QA_FLOW.md
CHANGED
|
@@ -97,7 +97,6 @@ flowchart TB
|
|
| 97 |
subgraph "External Services"
|
| 98 |
OPENAI[OpenAI API]
|
| 99 |
DDGO[DuckDuckGo Search]
|
| 100 |
-
KAFKA[Kafka Streams]
|
| 101 |
end
|
| 102 |
|
| 103 |
CLI --> YAML
|
|
@@ -120,7 +119,6 @@ flowchart TB
|
|
| 120 |
|
| 121 |
LLM_A <--> OPENAI
|
| 122 |
SEARCH <--> DDGO
|
| 123 |
-
REDIS <--> KAFKA
|
| 124 |
|
| 125 |
style REDIS fill:#f9f,stroke:#333,stroke-width:3px
|
| 126 |
style ORCH fill:#bbf,stroke:#333,stroke-width:2px
|
|
|
|
| 97 |
subgraph "External Services"
|
| 98 |
OPENAI[OpenAI API]
|
| 99 |
DDGO[DuckDuckGo Search]
|
|
|
|
| 100 |
end
|
| 101 |
|
| 102 |
CLI --> YAML
|
|
|
|
| 119 |
|
| 120 |
LLM_A <--> OPENAI
|
| 121 |
SEARCH <--> DDGO
|
|
|
|
| 122 |
|
| 123 |
style REDIS fill:#f9f,stroke:#333,stroke-width:3px
|
| 124 |
style ORCH fill:#bbf,stroke:#333,stroke-width:2px
|
docs/GIT_TIMELINE_PROJECT_EVOLUTION.md
CHANGED
|
@@ -157,7 +157,7 @@ timeline
|
|
| 157 |
- ✅ **RedisStack HNSW**: 100x performance improvement
|
| 158 |
- ✅ **Memory Decay**: Intelligent memory management
|
| 159 |
- ✅ **Production Tools**: CLI dashboard and monitoring
|
| 160 |
-
- ✅ **Enterprise Features**:
|
| 161 |
|
| 162 |
**Evidence in Codebase:**
|
| 163 |
```python
|
|
@@ -436,7 +436,7 @@ journey
|
|
| 436 |
### Community & Ecosystem Growth
|
| 437 |
|
| 438 |
**Adoption Indicators:**
|
| 439 |
-
- 🏢 **Enterprise Features**:
|
| 440 |
- 📚 **Documentation Quality**: 25+ comprehensive guides
|
| 441 |
- 🔧 **Developer Experience**: CLI tools, examples, debugging guides
|
| 442 |
- 🎯 **Use Case Diversity**: Q&A, content analysis, knowledge management
|
|
|
|
| 157 |
- ✅ **RedisStack HNSW**: 100x performance improvement
|
| 158 |
- ✅ **Memory Decay**: Intelligent memory management
|
| 159 |
- ✅ **Production Tools**: CLI dashboard and monitoring
|
| 160 |
+
- ✅ **Enterprise Features**: RedisStack clustering, enterprise scaling
|
| 161 |
|
| 162 |
**Evidence in Codebase:**
|
| 163 |
```python
|
|
|
|
| 436 |
### Community & Ecosystem Growth
|
| 437 |
|
| 438 |
**Adoption Indicators:**
|
| 439 |
+
- 🏢 **Enterprise Features**: RedisStack clustering, monitoring dashboards
|
| 440 |
- 📚 **Documentation Quality**: 25+ comprehensive guides
|
| 441 |
- 🔧 **Developer Experience**: CLI tools, examples, debugging guides
|
| 442 |
- 🎯 **Use Case Diversity**: Q&A, content analysis, knowledge management
|
docs/KAFKA_SCHEMA_REGISTRY_SETUP.md
DELETED
|
@@ -1,320 +0,0 @@
|
|
| 1 |
-
# 🎯 OrKa Kafka Schema Registry Integration
|
| 2 |
-
|
| 3 |
-
## ✅ **COMPLETED SUCCESSFULLY!**
|
| 4 |
-
|
| 5 |
-
You now have a fully functional **Kafka Schema Registry** integration with **OrKa objects** that provides:
|
| 6 |
-
|
| 7 |
-
- **✅ Schema validation** for all Kafka messages
|
| 8 |
-
- **✅ Schema Registry UI** for visual management
|
| 9 |
-
- **✅ Avro/Protobuf serialization** support
|
| 10 |
-
- **✅ Schema evolution** and compatibility tracking
|
| 11 |
-
- **✅ Native OrKa integration** with automatic schema handling
|
| 12 |
-
|
| 13 |
-
---
|
| 14 |
-
|
| 15 |
-
## 🌐 **ACCESS YOUR SCHEMA REGISTRY UI**
|
| 16 |
-
|
| 17 |
-
### **Schema Registry UI**
|
| 18 |
-
```
|
| 19 |
-
URL: http://localhost:8082
|
| 20 |
-
```
|
| 21 |
-
**Features:**
|
| 22 |
-
- 📊 Browse all registered schemas
|
| 23 |
-
- 📈 View schema evolution history
|
| 24 |
-
- 🔍 Test schema compatibility
|
| 25 |
-
- 📋 Monitor schema usage and metrics
|
| 26 |
-
- 🛠️ Manage schema subjects and versions
|
| 27 |
-
|
| 28 |
-
### **Schema Registry API**
|
| 29 |
-
```
|
| 30 |
-
URL: http://localhost:8081
|
| 31 |
-
```
|
| 32 |
-
**Endpoints:**
|
| 33 |
-
- `GET /subjects` - List all subjects
|
| 34 |
-
- `GET /subjects/{subject}/versions/latest` - Get latest schema
|
| 35 |
-
- `POST /subjects/{subject}/versions` - Register new schema
|
| 36 |
-
- `POST /compatibility/subjects/{subject}/versions/latest` - Test compatibility
|
| 37 |
-
|
| 38 |
-
---
|
| 39 |
-
|
| 40 |
-
## 📊 **CURRENT SCHEMA STATUS**
|
| 41 |
-
|
| 42 |
-
**Registered Subjects:**
|
| 43 |
-
- ✅ `orka-memory-events-value` (Avro schema for memory events)
|
| 44 |
-
- ✅ `test-orka-schema-value` (Test schema for validation)
|
| 45 |
-
|
| 46 |
-
**Schema Details:**
|
| 47 |
-
- **Format:** Avro (with Protobuf support available)
|
| 48 |
-
- **Location:** `orka/schemas/avro/memory_entry.avsc`
|
| 49 |
-
- **Features:** Memory entries with metadata, vector embeddings, timestamps
|
| 50 |
-
|
| 51 |
-
---
|
| 52 |
-
|
| 53 |
-
## 🚀 **USAGE EXAMPLES**
|
| 54 |
-
|
| 55 |
-
### **1. Using OrKa with Schema Registry (Automatic)**
|
| 56 |
-
|
| 57 |
-
```python
|
| 58 |
-
import os
|
| 59 |
-
|
| 60 |
-
# Enable schema registry in OrKa
|
| 61 |
-
os.environ["ORKA_MEMORY_BACKEND"] = "kafka"
|
| 62 |
-
os.environ["KAFKA_USE_SCHEMA_REGISTRY"] = "true"
|
| 63 |
-
os.environ["KAFKA_SCHEMA_REGISTRY_URL"] = "http://localhost:8081"
|
| 64 |
-
|
| 65 |
-
from orka.memory_logger import create_memory_logger
|
| 66 |
-
|
| 67 |
-
# Create logger with automatic schema validation
|
| 68 |
-
memory_logger = create_memory_logger("kafka")
|
| 69 |
-
|
| 70 |
-
# Log events - automatically validated against schema
|
| 71 |
-
memory_logger.log(
|
| 72 |
-
agent_id="my_agent",
|
| 73 |
-
event_type="ProcessingComplete",
|
| 74 |
-
payload={"result": "success", "confidence": 0.95},
|
| 75 |
-
run_id="prod-001",
|
| 76 |
-
step=1
|
| 77 |
-
)
|
| 78 |
-
```
|
| 79 |
-
|
| 80 |
-
### **2. Manual Schema Management**
|
| 81 |
-
|
| 82 |
-
```python
|
| 83 |
-
from orka.memory.schema_manager import create_schema_manager, SchemaFormat
|
| 84 |
-
|
| 85 |
-
# Create schema manager
|
| 86 |
-
schema_manager = create_schema_manager(
|
| 87 |
-
registry_url='http://localhost:8081',
|
| 88 |
-
format=SchemaFormat.AVRO
|
| 89 |
-
)
|
| 90 |
-
|
| 91 |
-
# Register a new schema for a topic
|
| 92 |
-
schema_id = schema_manager.register_schema('my-topic-value', 'memory_entry')
|
| 93 |
-
|
| 94 |
-
# Get serializer for producing messages
|
| 95 |
-
serializer = schema_manager.get_serializer('my-topic')
|
| 96 |
-
|
| 97 |
-
# Get deserializer for consuming messages
|
| 98 |
-
deserializer = schema_manager.get_deserializer('my-topic')
|
| 99 |
-
```
|
| 100 |
-
|
| 101 |
-
### **3. Confluent Kafka Producer with Schema**
|
| 102 |
-
|
| 103 |
-
```python
|
| 104 |
-
from confluent_kafka import Producer
|
| 105 |
-
from confluent_kafka.serialization import SerializationContext, MessageField
|
| 106 |
-
|
| 107 |
-
# Configure producer
|
| 108 |
-
producer = Producer({'bootstrap.servers': 'localhost:9092'})
|
| 109 |
-
|
| 110 |
-
# Create message matching schema
|
| 111 |
-
message = {
|
| 112 |
-
"id": "msg-001",
|
| 113 |
-
"content": json.dumps({"analysis": "Schema validation successful"}),
|
| 114 |
-
"metadata": {
|
| 115 |
-
"source": "my-agent",
|
| 116 |
-
"confidence": 0.98,
|
| 117 |
-
"timestamp": time.time(),
|
| 118 |
-
"agent_id": "agent_001",
|
| 119 |
-
"tags": ["production", "validated"]
|
| 120 |
-
},
|
| 121 |
-
"ts": int(time.time() * 1000000000),
|
| 122 |
-
"match_type": "exact",
|
| 123 |
-
"stream_key": "orka:main"
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
# Serialize and send
|
| 127 |
-
serialized = serializer(message, SerializationContext('my-topic', MessageField.VALUE))
|
| 128 |
-
producer.produce(topic='my-topic', value=serialized)
|
| 129 |
-
```
|
| 130 |
-
|
| 131 |
-
---
|
| 132 |
-
|
| 133 |
-
## 🔧 **INFRASTRUCTURE MANAGEMENT**
|
| 134 |
-
|
| 135 |
-
### **Start Kafka + Schema Registry**
|
| 136 |
-
```bash
|
| 137 |
-
# Start all services
|
| 138 |
-
docker-compose --profile kafka up -d
|
| 139 |
-
|
| 140 |
-
# Or start individually
|
| 141 |
-
docker-compose up -d zookeeper kafka schema-registry schema-registry-ui
|
| 142 |
-
```
|
| 143 |
-
|
| 144 |
-
### **Check Status**
|
| 145 |
-
```bash
|
| 146 |
-
# Test Schema Registry
|
| 147 |
-
curl http://localhost:8081/subjects
|
| 148 |
-
|
| 149 |
-
# Test Schema Registry UI
|
| 150 |
-
curl http://localhost:8082
|
| 151 |
-
|
| 152 |
-
# List Kafka topics
|
| 153 |
-
docker exec kafka kafka-topics --list --bootstrap-server localhost:9092
|
| 154 |
-
```
|
| 155 |
-
|
| 156 |
-
### **Stop Services**
|
| 157 |
-
```bash
|
| 158 |
-
# Stop all services
|
| 159 |
-
docker-compose --profile kafka down
|
| 160 |
-
|
| 161 |
-
# Remove volumes (optional)
|
| 162 |
-
docker volume prune
|
| 163 |
-
```
|
| 164 |
-
|
| 165 |
-
---
|
| 166 |
-
|
| 167 |
-
## 📋 **SCHEMA STRUCTURE**
|
| 168 |
-
|
| 169 |
-
### **Avro Schema (`orka/schemas/avro/memory_entry.avsc`)**
|
| 170 |
-
```json
|
| 171 |
-
{
|
| 172 |
-
"type": "record",
|
| 173 |
-
"name": "MemoryEntry",
|
| 174 |
-
"namespace": "orka.memory",
|
| 175 |
-
"fields": [
|
| 176 |
-
{"name": "id", "type": "string"},
|
| 177 |
-
{"name": "content", "type": "string"},
|
| 178 |
-
{"name": "metadata", "type": {
|
| 179 |
-
"type": "record",
|
| 180 |
-
"name": "MemoryMetadata",
|
| 181 |
-
"fields": [
|
| 182 |
-
{"name": "source", "type": "string"},
|
| 183 |
-
{"name": "confidence", "type": "double"},
|
| 184 |
-
{"name": "timestamp", "type": "double"},
|
| 185 |
-
{"name": "agent_id", "type": "string"},
|
| 186 |
-
{"name": "tags", "type": {"type": "array", "items": "string"}},
|
| 187 |
-
// ... more fields
|
| 188 |
-
]
|
| 189 |
-
}},
|
| 190 |
-
{"name": "ts", "type": "long"},
|
| 191 |
-
{"name": "match_type", "type": {"type": "enum", "symbols": ["exact", "semantic", "fuzzy"]}},
|
| 192 |
-
{"name": "stream_key", "type": "string"}
|
| 193 |
-
]
|
| 194 |
-
}
|
| 195 |
-
```
|
| 196 |
-
|
| 197 |
-
### **Protobuf Schema (`orka/schemas/protobuf/memory_entry.proto`)**
|
| 198 |
-
```protobuf
|
| 199 |
-
syntax = "proto3";
|
| 200 |
-
package orka.memory;
|
| 201 |
-
|
| 202 |
-
message MemoryEntry {
|
| 203 |
-
string id = 1;
|
| 204 |
-
string content = 2;
|
| 205 |
-
MemoryMetadata metadata = 3;
|
| 206 |
-
int64 ts = 5;
|
| 207 |
-
MatchType match_type = 6;
|
| 208 |
-
string stream_key = 7;
|
| 209 |
-
}
|
| 210 |
-
|
| 211 |
-
message MemoryMetadata {
|
| 212 |
-
string source = 1;
|
| 213 |
-
double confidence = 2;
|
| 214 |
-
double timestamp = 5;
|
| 215 |
-
string agent_id = 6;
|
| 216 |
-
repeated string tags = 8;
|
| 217 |
-
}
|
| 218 |
-
```
|
| 219 |
-
|
| 220 |
-
---
|
| 221 |
-
|
| 222 |
-
## 🎁 **BENEFITS ACHIEVED**
|
| 223 |
-
|
| 224 |
-
### **✅ Data Quality**
|
| 225 |
-
- **Strong typing** prevents malformed messages
|
| 226 |
-
- **Schema validation** ensures data consistency
|
| 227 |
-
- **Version control** tracks schema evolution
|
| 228 |
-
- **Compatibility checking** prevents breaking changes
|
| 229 |
-
|
| 230 |
-
### **✅ Performance**
|
| 231 |
-
- **Avro compression** reduces message size ~40-60%
|
| 232 |
-
- **Binary serialization** faster than JSON
|
| 233 |
-
- **Schema caching** minimizes registry lookups
|
| 234 |
-
- **Batch processing** improves throughput
|
| 235 |
-
|
| 236 |
-
### **✅ Monitoring & Debugging**
|
| 237 |
-
- **Schema Registry UI** for visual management
|
| 238 |
-
- **Schema evolution history** for debugging
|
| 239 |
-
- **Compatibility testing** before deployment
|
| 240 |
-
- **Usage metrics** for optimization
|
| 241 |
-
|
| 242 |
-
### **✅ Integration**
|
| 243 |
-
- **Native OrKa support** with automatic schema handling
|
| 244 |
-
- **Confluent ecosystem** compatibility
|
| 245 |
-
- **Multiple serialization formats** (Avro/Protobuf)
|
| 246 |
-
- **Backward compatibility** with existing code
|
| 247 |
-
|
| 248 |
-
---
|
| 249 |
-
|
| 250 |
-
## 🧪 **TESTING YOUR SETUP**
|
| 251 |
-
|
| 252 |
-
### **Run Integration Tests**
|
| 253 |
-
```bash
|
| 254 |
-
python test_schema_registry_integration.py
|
| 255 |
-
```
|
| 256 |
-
|
| 257 |
-
### **Test Schema Registration**
|
| 258 |
-
```bash
|
| 259 |
-
# Register a new schema
|
| 260 |
-
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
|
| 261 |
-
--data '{"schema": "..."}' \
|
| 262 |
-
http://localhost:8081/subjects/my-topic-value/versions
|
| 263 |
-
|
| 264 |
-
# Test compatibility
|
| 265 |
-
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
|
| 266 |
-
--data '{"schema": "..."}' \
|
| 267 |
-
http://localhost:8081/compatibility/subjects/my-topic-value/versions/latest
|
| 268 |
-
```
|
| 269 |
-
|
| 270 |
-
---
|
| 271 |
-
|
| 272 |
-
## 📚 **NEXT STEPS**
|
| 273 |
-
|
| 274 |
-
1. **🌐 Explore the UI**: Visit http://localhost:8082 to browse schemas
|
| 275 |
-
2. **🔄 Test Schema Evolution**: Modify schemas and test compatibility
|
| 276 |
-
3. **📊 Monitor Usage**: Check schema metrics and message validation
|
| 277 |
-
4. **🚀 Production Setup**: Configure security and clustering for production
|
| 278 |
-
5. **📈 Performance Tuning**: Optimize serialization and caching settings
|
| 279 |
-
|
| 280 |
-
---
|
| 281 |
-
|
| 282 |
-
## 🛠️ **TROUBLESHOOTING**
|
| 283 |
-
|
| 284 |
-
### **Common Issues**
|
| 285 |
-
|
| 286 |
-
| Problem | Solution |
|
| 287 |
-
|---------|----------|
|
| 288 |
-
| Schema Registry not accessible | `docker-compose --profile kafka up -d` |
|
| 289 |
-
| Schema registration fails | Check schema syntax and registry logs |
|
| 290 |
-
| Message validation errors | Verify message matches schema structure |
|
| 291 |
-
| UI not loading | Check if schema-registry-ui container is running |
|
| 292 |
-
|
| 293 |
-
### **Environment Variables**
|
| 294 |
-
```bash
|
| 295 |
-
# Required for schema registry
|
| 296 |
-
KAFKA_SCHEMA_REGISTRY_URL=http://localhost:8081
|
| 297 |
-
KAFKA_USE_SCHEMA_REGISTRY=true
|
| 298 |
-
KAFKA_BOOTSTRAP_SERVERS=localhost:9092
|
| 299 |
-
|
| 300 |
-
# Optional
|
| 301 |
-
ORKA_SCHEMA_FORMAT=avro # or protobuf
|
| 302 |
-
SCHEMA_REGISTRY_COMPATIBILITY_LEVEL=BACKWARD
|
| 303 |
-
```
|
| 304 |
-
|
| 305 |
-
---
|
| 306 |
-
|
| 307 |
-
## 🎉 **CONGRATULATIONS!**
|
| 308 |
-
|
| 309 |
-
You now have a **production-ready Kafka Schema Registry integration** with OrKa that provides:
|
| 310 |
-
|
| 311 |
-
- ✅ **Schema validation** for all messages
|
| 312 |
-
- ✅ **Visual management** through the UI
|
| 313 |
-
- ✅ **Automatic serialization** in OrKa workflows
|
| 314 |
-
- ✅ **Schema evolution** and compatibility
|
| 315 |
-
- ✅ **Performance optimization** through Avro/Protobuf
|
| 316 |
-
|
| 317 |
-
**🌐 Access your Schema Registry UI**: http://localhost:8082
|
| 318 |
-
**🔗 API Endpoint**: http://localhost:8081
|
| 319 |
-
|
| 320 |
-
Happy schema-validated messaging! 🚀
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docs/MEMORY_BACKENDS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# Orka Memory Backends
|
| 2 |
|
| 3 |
-
Orka supports
|
| 4 |
|
| 5 |
## Overview
|
| 6 |
|
|
@@ -13,18 +13,18 @@ The memory system in Orka serves several purposes:
|
|
| 13 |
|
| 14 |
## Supported Backends
|
| 15 |
|
| 16 |
-
###
|
| 17 |
-
- **Best for**:
|
| 18 |
-
- **Features**:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
- **Persistence**: Redis streams and data structures
|
| 20 |
- **Scalability**: Single Redis instance or Redis Cluster
|
| 21 |
|
| 22 |
-
### Kafka
|
| 23 |
-
- **Best for**: Event-driven architectures, microservices, high-throughput scenarios
|
| 24 |
-
- **Features**: Event streaming, basic coordination (in-memory fork/join)
|
| 25 |
-
- **Persistence**: Kafka topics with configurable retention
|
| 26 |
-
- **Scalability**: Native Kafka clustering and partitioning
|
| 27 |
-
|
| 28 |
## Configuration
|
| 29 |
|
| 30 |
### Environment Variables
|
|
@@ -32,120 +32,96 @@ The memory system in Orka serves several purposes:
|
|
| 32 |
Set the memory backend using environment variables:
|
| 33 |
|
| 34 |
```bash
|
| 35 |
-
# For
|
| 36 |
-
export ORKA_MEMORY_BACKEND=
|
| 37 |
export REDIS_URL=redis://localhost:6380/0
|
| 38 |
|
| 39 |
-
# For
|
| 40 |
-
export ORKA_MEMORY_BACKEND=
|
| 41 |
-
export
|
| 42 |
-
export KAFKA_TOPIC_PREFIX=orka-memory
|
| 43 |
```
|
| 44 |
|
| 45 |
-
###
|
| 46 |
|
| 47 |
```bash
|
| 48 |
-
# Basic
|
| 49 |
-
export ORKA_MEMORY_BACKEND=
|
| 50 |
export REDIS_URL=redis://localhost:6380/0
|
| 51 |
|
| 52 |
-
#
|
| 53 |
export REDIS_URL=redis://:password@localhost:6380/0
|
| 54 |
|
| 55 |
# Redis Cluster
|
| 56 |
export REDIS_URL=redis://node1:6380,node2:6380,node3:6380/0
|
| 57 |
```
|
| 58 |
|
| 59 |
-
###
|
| 60 |
|
| 61 |
```bash
|
| 62 |
-
#
|
| 63 |
-
export ORKA_MEMORY_BACKEND=
|
| 64 |
-
export
|
| 65 |
-
export
|
| 66 |
-
|
| 67 |
-
# Kafka with multiple brokers
|
| 68 |
-
export KAFKA_BOOTSTRAP_SERVERS=broker1:9092,broker2:9092,broker3:9092
|
| 69 |
-
|
| 70 |
-
# Custom topic prefix
|
| 71 |
-
export KAFKA_TOPIC_PREFIX=my-app-events
|
| 72 |
```
|
| 73 |
|
| 74 |
-
##
|
| 75 |
-
|
| 76 |
-
You can also specify memory configuration in your orchestrator YAML:
|
| 77 |
-
|
| 78 |
-
### Redis Example
|
| 79 |
-
```yaml
|
| 80 |
-
orchestrator:
|
| 81 |
-
id: "my-orchestrator"
|
| 82 |
-
strategy: "parallel"
|
| 83 |
-
memory:
|
| 84 |
-
store_type: "redis"
|
| 85 |
-
url: "redis://localhost:6380/0"
|
| 86 |
-
agents:
|
| 87 |
-
- "agent1"
|
| 88 |
-
- "agent2"
|
| 89 |
-
```
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
- "agent1"
|
| 102 |
-
- "agent2"
|
| 103 |
-
```
|
| 104 |
|
| 105 |
-
##
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|---------|-------|-------|
|
| 109 |
-
| Event Logging | ✅ Redis Streams | ✅ Kafka Topics |
|
| 110 |
-
| Hash Operations | ✅ Native Redis | ✅ In-Memory |
|
| 111 |
-
| Set Operations | ✅ Native Redis | ✅ In-Memory |
|
| 112 |
-
| Fork/Join Coordination | ✅ Distributed | ⚠️ In-Memory Only |
|
| 113 |
-
| Tail Operations | ✅ XREVRANGE | ⚠️ Local Buffer |
|
| 114 |
-
| Persistence | ✅ Redis RDB/AOF | ✅ Kafka Log Segments |
|
| 115 |
-
| Scalability | ✅ Redis Cluster | ✅ Kafka Partitions |
|
| 116 |
-
| Event Replay | ⚠️ Limited | ✅ Full History |
|
| 117 |
-
| Memory Usage | ⚠️ All in RAM | ✅ Disk + RAM |
|
| 118 |
-
|
| 119 |
-
## Installation Requirements
|
| 120 |
-
|
| 121 |
-
### Redis Backend
|
| 122 |
```bash
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
```
|
| 125 |
|
| 126 |
-
###
|
| 127 |
```bash
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
```
|
| 130 |
|
| 131 |
-
## Docker Setup
|
| 132 |
|
| 133 |
-
###
|
| 134 |
```yaml
|
| 135 |
version: '3.8'
|
| 136 |
services:
|
| 137 |
redis:
|
| 138 |
-
image: redis:7.2-
|
| 139 |
ports:
|
| 140 |
-
- "6380:
|
| 141 |
volumes:
|
| 142 |
- redis_data:/data
|
| 143 |
-
command:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
orka:
|
| 146 |
build: .
|
| 147 |
environment:
|
| 148 |
-
- ORKA_MEMORY_BACKEND=
|
| 149 |
- REDIS_URL=redis://redis:6380/0
|
| 150 |
depends_on:
|
| 151 |
- redis
|
|
@@ -154,35 +130,23 @@ volumes:
|
|
| 154 |
redis_data:
|
| 155 |
```
|
| 156 |
|
| 157 |
-
###
|
| 158 |
```yaml
|
| 159 |
version: '3.8'
|
| 160 |
services:
|
| 161 |
-
|
| 162 |
-
image:
|
| 163 |
-
environment:
|
| 164 |
-
ZOOKEEPER_CLIENT_PORT: 2181
|
| 165 |
-
|
| 166 |
-
kafka:
|
| 167 |
-
image: confluentinc/cp-kafka:latest
|
| 168 |
-
depends_on:
|
| 169 |
-
- zookeeper
|
| 170 |
ports:
|
| 171 |
-
- "
|
| 172 |
-
|
| 173 |
-
KAFKA_BROKER_ID: 1
|
| 174 |
-
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
| 175 |
-
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
|
| 176 |
-
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
| 177 |
|
| 178 |
orka:
|
| 179 |
build: .
|
| 180 |
environment:
|
| 181 |
-
- ORKA_MEMORY_BACKEND=
|
| 182 |
-
-
|
| 183 |
-
- KAFKA_TOPIC_PREFIX=orka-memory
|
| 184 |
depends_on:
|
| 185 |
-
-
|
| 186 |
```
|
| 187 |
|
| 188 |
## Usage Examples
|
|
@@ -192,17 +156,16 @@ services:
|
|
| 192 |
```python
|
| 193 |
from orka.memory_logger import create_memory_logger
|
| 194 |
|
| 195 |
-
#
|
| 196 |
-
|
| 197 |
-
backend="
|
| 198 |
redis_url="redis://localhost:6380/0"
|
| 199 |
)
|
| 200 |
|
| 201 |
-
#
|
| 202 |
-
|
| 203 |
-
backend="
|
| 204 |
-
|
| 205 |
-
topic_prefix="my-events"
|
| 206 |
)
|
| 207 |
```
|
| 208 |
|
|
@@ -213,84 +176,94 @@ from orka.orchestrator import Orchestrator
|
|
| 213 |
import os
|
| 214 |
|
| 215 |
# Set environment variable
|
| 216 |
-
os.environ["ORKA_MEMORY_BACKEND"] = "
|
| 217 |
-
os.environ["
|
| 218 |
|
| 219 |
-
# Initialize orchestrator (will automatically use
|
| 220 |
orchestrator = Orchestrator("config.yml")
|
| 221 |
result = await orchestrator.run("input data")
|
| 222 |
```
|
| 223 |
|
| 224 |
-
##
|
| 225 |
|
| 226 |
-
###
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
|
|
|
| 231 |
|
| 232 |
-
### Redis
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
|
|
|
| 236 |
|
| 237 |
-
## Migration
|
| 238 |
|
| 239 |
-
### Redis to
|
| 240 |
-
1.
|
| 241 |
-
2.
|
| 242 |
-
3.
|
| 243 |
-
4.
|
| 244 |
|
| 245 |
-
###
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
|
| 250 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
### Redis Monitoring
|
| 253 |
```bash
|
| 254 |
-
#
|
| 255 |
-
redis-cli
|
|
|
|
|
|
|
|
|
|
| 256 |
|
| 257 |
-
#
|
| 258 |
-
redis-cli
|
| 259 |
|
| 260 |
-
#
|
| 261 |
-
redis-cli
|
| 262 |
```
|
| 263 |
|
| 264 |
-
###
|
| 265 |
```bash
|
| 266 |
-
#
|
| 267 |
-
|
| 268 |
|
| 269 |
-
# Check
|
| 270 |
-
|
| 271 |
|
| 272 |
-
#
|
| 273 |
-
|
| 274 |
```
|
| 275 |
|
| 276 |
## Best Practices
|
| 277 |
|
| 278 |
-
1. **
|
| 279 |
-
- Use
|
| 280 |
-
- Use
|
| 281 |
|
| 282 |
-
2. **
|
| 283 |
-
-
|
| 284 |
-
-
|
| 285 |
|
| 286 |
-
3. **
|
| 287 |
-
-
|
| 288 |
-
-
|
| 289 |
|
| 290 |
-
4. **
|
| 291 |
-
-
|
| 292 |
-
-
|
| 293 |
|
| 294 |
5. **Production Deployment**:
|
| 295 |
-
- Use Redis Cluster
|
| 296 |
-
- Configure appropriate backup and retention policies
|
|
|
|
|
|
| 1 |
# Orka Memory Backends
|
| 2 |
|
| 3 |
+
Orka supports Redis-based memory backends for storing orchestration events, agent outputs, and system state. Choose between RedisStack (recommended) and basic Redis based on your performance requirements.
|
| 4 |
|
| 5 |
## Overview
|
| 6 |
|
|
|
|
| 13 |
|
| 14 |
## Supported Backends
|
| 15 |
|
| 16 |
+
### RedisStack (Recommended)
|
| 17 |
+
- **Best for**: Production AI workloads, high-performance applications
|
| 18 |
+
- **Features**: HNSW vector indexing, 100x faster search, advanced memory management
|
| 19 |
+
- **Performance**: Sub-millisecond search, 50,000+ operations/second
|
| 20 |
+
- **Scalability**: Single RedisStack instance or Redis Cluster
|
| 21 |
+
|
| 22 |
+
### Redis (Legacy)
|
| 23 |
+
- **Best for**: Development, single-node deployments, quick prototyping
|
| 24 |
+
- **Features**: Fast in-memory operations, simple setup, full feature support
|
| 25 |
- **Persistence**: Redis streams and data structures
|
| 26 |
- **Scalability**: Single Redis instance or Redis Cluster
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
## Configuration
|
| 29 |
|
| 30 |
### Environment Variables
|
|
|
|
| 32 |
Set the memory backend using environment variables:
|
| 33 |
|
| 34 |
```bash
|
| 35 |
+
# For RedisStack (default - recommended)
|
| 36 |
+
export ORKA_MEMORY_BACKEND=redisstack
|
| 37 |
export REDIS_URL=redis://localhost:6380/0
|
| 38 |
|
| 39 |
+
# For basic Redis
|
| 40 |
+
export ORKA_MEMORY_BACKEND=redis
|
| 41 |
+
export REDIS_URL=redis://localhost:6380/0
|
|
|
|
| 42 |
```
|
| 43 |
|
| 44 |
+
### RedisStack Configuration
|
| 45 |
|
| 46 |
```bash
|
| 47 |
+
# Basic RedisStack setup
|
| 48 |
+
export ORKA_MEMORY_BACKEND=redisstack
|
| 49 |
export REDIS_URL=redis://localhost:6380/0
|
| 50 |
|
| 51 |
+
# RedisStack with authentication
|
| 52 |
export REDIS_URL=redis://:password@localhost:6380/0
|
| 53 |
|
| 54 |
# Redis Cluster
|
| 55 |
export REDIS_URL=redis://node1:6380,node2:6380,node3:6380/0
|
| 56 |
```
|
| 57 |
|
| 58 |
+
### Basic Redis Configuration
|
| 59 |
|
| 60 |
```bash
|
| 61 |
+
# Force basic Redis mode
|
| 62 |
+
export ORKA_MEMORY_BACKEND=redis
|
| 63 |
+
export ORKA_FORCE_BASIC_REDIS=true
|
| 64 |
+
export REDIS_URL=redis://localhost:6380/0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
```
|
| 66 |
|
| 67 |
+
## Backend Comparison
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
+
| Feature | Basic Redis | RedisStack |
|
| 70 |
+
|---------|-------------|------------|
|
| 71 |
+
| Event Logging | ✅ Redis Streams | ✅ Redis Streams |
|
| 72 |
+
| Hash Operations | ✅ Native Redis | ✅ Native Redis |
|
| 73 |
+
| Set Operations | ✅ Native Redis | ✅ Native Redis |
|
| 74 |
+
| Vector Search | ❌ Not Available | ✅ HNSW Indexing |
|
| 75 |
+
| Search Performance | Standard | 100x Faster |
|
| 76 |
+
| Memory Efficiency | Standard | 60% Reduction |
|
| 77 |
+
| Concurrent Operations | Standard | 1000+ Simultaneous |
|
| 78 |
+
| Setup Complexity | Simple | Simple |
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
+
## Installation
|
| 81 |
|
| 82 |
+
### RedisStack Backend (Recommended)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
```bash
|
| 84 |
+
# Using Docker (recommended)
|
| 85 |
+
docker run -d -p 6380:6379 redis/redis-stack-server:latest
|
| 86 |
+
|
| 87 |
+
# Or install natively
|
| 88 |
+
# Windows: Download from https://redis.io/download
|
| 89 |
+
# macOS: brew install redis-stack
|
| 90 |
+
# Ubuntu: sudo apt install redis-stack-server
|
| 91 |
```
|
| 92 |
|
| 93 |
+
### Basic Redis Backend
|
| 94 |
```bash
|
| 95 |
+
# Using Docker
|
| 96 |
+
docker run -d -p 6380:6379 redis:latest
|
| 97 |
+
|
| 98 |
+
# Or install natively
|
| 99 |
+
# macOS: brew install redis
|
| 100 |
+
# Ubuntu: sudo apt install redis-server
|
| 101 |
```
|
| 102 |
|
| 103 |
+
## Docker Setup Examples
|
| 104 |
|
| 105 |
+
### RedisStack with Docker
|
| 106 |
```yaml
|
| 107 |
version: '3.8'
|
| 108 |
services:
|
| 109 |
redis:
|
| 110 |
+
image: redis/redis-stack-server:7.2.0-v6
|
| 111 |
ports:
|
| 112 |
+
- "6380:6379"
|
| 113 |
volumes:
|
| 114 |
- redis_data:/data
|
| 115 |
+
command: >
|
| 116 |
+
redis-stack-server
|
| 117 |
+
--appendonly yes
|
| 118 |
+
--maxmemory 2gb
|
| 119 |
+
--maxmemory-policy allkeys-lru
|
| 120 |
|
| 121 |
orka:
|
| 122 |
build: .
|
| 123 |
environment:
|
| 124 |
+
- ORKA_MEMORY_BACKEND=redisstack
|
| 125 |
- REDIS_URL=redis://redis:6380/0
|
| 126 |
depends_on:
|
| 127 |
- redis
|
|
|
|
| 130 |
redis_data:
|
| 131 |
```
|
| 132 |
|
| 133 |
+
### Basic Redis with Docker
|
| 134 |
```yaml
|
| 135 |
version: '3.8'
|
| 136 |
services:
|
| 137 |
+
redis:
|
| 138 |
+
image: redis:latest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
ports:
|
| 140 |
+
- "6380:6379"
|
| 141 |
+
command: redis-server --appendonly yes
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
orka:
|
| 144 |
build: .
|
| 145 |
environment:
|
| 146 |
+
- ORKA_MEMORY_BACKEND=redis
|
| 147 |
+
- REDIS_URL=redis://redis:6380/0
|
|
|
|
| 148 |
depends_on:
|
| 149 |
+
- redis
|
| 150 |
```
|
| 151 |
|
| 152 |
## Usage Examples
|
|
|
|
| 156 |
```python
|
| 157 |
from orka.memory_logger import create_memory_logger
|
| 158 |
|
| 159 |
+
# RedisStack backend (recommended)
|
| 160 |
+
redisstack_memory = create_memory_logger(
|
| 161 |
+
backend="redisstack",
|
| 162 |
redis_url="redis://localhost:6380/0"
|
| 163 |
)
|
| 164 |
|
| 165 |
+
# Basic Redis backend
|
| 166 |
+
redis_memory = create_memory_logger(
|
| 167 |
+
backend="redis",
|
| 168 |
+
redis_url="redis://localhost:6380/0"
|
|
|
|
| 169 |
)
|
| 170 |
```
|
| 171 |
|
|
|
|
| 176 |
import os
|
| 177 |
|
| 178 |
# Set environment variable
|
| 179 |
+
os.environ["ORKA_MEMORY_BACKEND"] = "redisstack"
|
| 180 |
+
os.environ["REDIS_URL"] = "redis://localhost:6380/0"
|
| 181 |
|
| 182 |
+
# Initialize orchestrator (will automatically use RedisStack)
|
| 183 |
orchestrator = Orchestrator("config.yml")
|
| 184 |
result = await orchestrator.run("input data")
|
| 185 |
```
|
| 186 |
|
| 187 |
+
## Performance Characteristics
|
| 188 |
|
| 189 |
+
### RedisStack Performance
|
| 190 |
+
- **Vector Search**: Sub-millisecond latency with HNSW indexing
|
| 191 |
+
- **Write Throughput**: 50,000+ memories/second sustained
|
| 192 |
+
- **Search Latency**: <5ms for complex hybrid queries
|
| 193 |
+
- **Memory Efficiency**: ~60% reduction in storage overhead
|
| 194 |
+
- **Concurrent Users**: 1000+ simultaneous search operations
|
| 195 |
|
| 196 |
+
### Basic Redis Performance
|
| 197 |
+
- **Write Throughput**: 10,000+ memories/second sustained
|
| 198 |
+
- **Read Latency**: <50ms average search latency
|
| 199 |
+
- **Memory Efficiency**: Standard Redis performance
|
| 200 |
+
- **Scalability**: Horizontal scaling with Redis Cluster support
|
| 201 |
|
| 202 |
+
## Migration Guide
|
| 203 |
|
| 204 |
+
### From Basic Redis to RedisStack
|
| 205 |
+
1. Stop your Orka application
|
| 206 |
+
2. Start RedisStack instead of basic Redis
|
| 207 |
+
3. Update environment variable: `ORKA_MEMORY_BACKEND=redisstack`
|
| 208 |
+
4. Restart Orka - existing data will be preserved
|
| 209 |
|
| 210 |
+
### Configuration Migration
|
| 211 |
+
```bash
|
| 212 |
+
# Old configuration
|
| 213 |
+
export ORKA_MEMORY_BACKEND=redis
|
| 214 |
|
| 215 |
+
# New configuration
|
| 216 |
+
export ORKA_MEMORY_BACKEND=redisstack
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
+
## Monitoring
|
| 220 |
|
| 221 |
### Redis Monitoring
|
| 222 |
```bash
|
| 223 |
+
# Connect to Redis CLI
|
| 224 |
+
redis-cli -p 6380
|
| 225 |
+
|
| 226 |
+
# Check Redis info
|
| 227 |
+
redis-cli -p 6380 info
|
| 228 |
|
| 229 |
+
# Monitor Redis operations
|
| 230 |
+
redis-cli -p 6380 monitor
|
| 231 |
|
| 232 |
+
# Check memory usage
|
| 233 |
+
redis-cli -p 6380 info memory
|
| 234 |
```
|
| 235 |
|
| 236 |
+
### RedisStack Monitoring
|
| 237 |
```bash
|
| 238 |
+
# Check loaded modules
|
| 239 |
+
redis-cli -p 6380 MODULE LIST
|
| 240 |
|
| 241 |
+
# Check vector index info
|
| 242 |
+
redis-cli -p 6380 FT.INFO orka_enhanced_memory
|
| 243 |
|
| 244 |
+
# Monitor search operations
|
| 245 |
+
redis-cli -p 6380 FT.SEARCH orka_enhanced_memory "*"
|
| 246 |
```
|
| 247 |
|
| 248 |
## Best Practices
|
| 249 |
|
| 250 |
+
1. **Backend Selection**:
|
| 251 |
+
- Use RedisStack for production AI workloads requiring fast search
|
| 252 |
+
- Use basic Redis for simple applications or development
|
| 253 |
|
| 254 |
+
2. **Memory Management**:
|
| 255 |
+
- Configure appropriate memory limits and eviction policies
|
| 256 |
+
- Enable persistence (AOF/RDB) for data durability
|
| 257 |
|
| 258 |
+
3. **Performance Optimization**:
|
| 259 |
+
- Use RedisStack HNSW indexing for vector search workloads
|
| 260 |
+
- Configure memory decay rules to manage data lifecycle
|
| 261 |
|
| 262 |
+
4. **Monitoring**:
|
| 263 |
+
- Monitor Redis memory usage and performance metrics
|
| 264 |
+
- Set up alerts for memory usage and connection issues
|
| 265 |
|
| 266 |
5. **Production Deployment**:
|
| 267 |
+
- Use Redis Cluster for high availability
|
| 268 |
+
- Configure appropriate backup and retention policies
|
| 269 |
+
- Use RedisStack for maximum performance benefits
|
docs/MEMORY_SYSTEM_GUIDE.md
CHANGED
|
@@ -31,7 +31,7 @@ OrKa's memory system is inspired by human cognitive science and provides sophist
|
|
| 31 |
│ Memory │ │ Memory │ │ Memory │
|
| 32 |
│ Writers │ │ Storage │ │ Readers │
|
| 33 |
│ │ │ │ │ │
|
| 34 |
-
│ • Classification│ │ • Redis/
|
| 35 |
│ • Vectorization │────│ • Namespaces │────│ • Similarity │
|
| 36 |
│ • Metadata │ │ • Decay System │ │ • Temporal Rank │
|
| 37 |
│ • Compression │ │ • Indexing │ │ • Filtering │
|
|
@@ -93,36 +93,30 @@ export ORKA_MEMORY_DECAY_LONG_TERM_HOURS=168
|
|
| 93 |
export ORKA_MEMORY_DECAY_CHECK_INTERVAL_MINUTES=30
|
| 94 |
```
|
| 95 |
|
| 96 |
-
**
|
| 97 |
```bash
|
| 98 |
# Using Docker Compose
|
| 99 |
cat > docker-compose.yml << EOF
|
| 100 |
version: '3.8'
|
| 101 |
services:
|
| 102 |
-
|
| 103 |
-
image:
|
| 104 |
-
environment:
|
| 105 |
-
ZOOKEEPER_CLIENT_PORT: 2181
|
| 106 |
-
|
| 107 |
-
kafka:
|
| 108 |
-
image: confluentinc/cp-kafka:latest
|
| 109 |
-
depends_on:
|
| 110 |
-
- zookeeper
|
| 111 |
ports:
|
| 112 |
-
- "
|
|
|
|
|
|
|
| 113 |
environment:
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
EOF
|
| 119 |
|
| 120 |
docker-compose up -d
|
| 121 |
|
| 122 |
# Configure OrKa
|
| 123 |
-
export ORKA_MEMORY_BACKEND=
|
| 124 |
-
export
|
| 125 |
-
export KAFKA_TOPIC_PREFIX=orka-memory
|
| 126 |
```
|
| 127 |
|
| 128 |
### YAML Configuration
|
|
@@ -134,7 +128,7 @@ orchestrator:
|
|
| 134 |
strategy: sequential
|
| 135 |
memory_config:
|
| 136 |
# Backend configuration
|
| 137 |
-
backend: redis # or "
|
| 138 |
|
| 139 |
# Intelligent decay system
|
| 140 |
decay:
|
|
@@ -1298,8 +1292,8 @@ orka memory cleanup
|
|
| 1298 |
# Redis
|
| 1299 |
redis-cli ping # Should return PONG
|
| 1300 |
|
| 1301 |
-
#
|
| 1302 |
-
|
| 1303 |
```
|
| 1304 |
|
| 1305 |
### Debug Mode
|
|
|
|
| 31 |
│ Memory │ │ Memory │ │ Memory │
|
| 32 |
│ Writers │ │ Storage │ │ Readers │
|
| 33 |
│ │ │ │ │ │
|
| 34 |
+
│ • Classification│ │ • Redis/RedisStack │ │ • Context Search│
|
| 35 |
│ • Vectorization │────│ • Namespaces │────│ • Similarity │
|
| 36 |
│ • Metadata │ │ • Decay System │ │ • Temporal Rank │
|
| 37 |
│ • Compression │ │ • Indexing │ │ • Filtering │
|
|
|
|
| 93 |
export ORKA_MEMORY_DECAY_CHECK_INTERVAL_MINUTES=30
|
| 94 |
```
|
| 95 |
|
| 96 |
+
**RedisStack Backend (Production)**
|
| 97 |
```bash
|
| 98 |
# Using Docker Compose
|
| 99 |
cat > docker-compose.yml << EOF
|
| 100 |
version: '3.8'
|
| 101 |
services:
|
| 102 |
+
redis-stack:
|
| 103 |
+
image: redis/redis-stack:latest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
ports:
|
| 105 |
+
- "6380:6380"
|
| 106 |
+
volumes:
|
| 107 |
+
- redis_data:/data
|
| 108 |
environment:
|
| 109 |
+
- REDIS_ARGS=--save 60 1000
|
| 110 |
+
|
| 111 |
+
volumes:
|
| 112 |
+
redis_data:
|
| 113 |
EOF
|
| 114 |
|
| 115 |
docker-compose up -d
|
| 116 |
|
| 117 |
# Configure OrKa
|
| 118 |
+
export ORKA_MEMORY_BACKEND=redisstack
|
| 119 |
+
export REDIS_URL=redis://localhost:6380/0
|
|
|
|
| 120 |
```
|
| 121 |
|
| 122 |
### YAML Configuration
|
|
|
|
| 128 |
strategy: sequential
|
| 129 |
memory_config:
|
| 130 |
# Backend configuration
|
| 131 |
+
backend: redis # or "redisstack"
|
| 132 |
|
| 133 |
# Intelligent decay system
|
| 134 |
decay:
|
|
|
|
| 1292 |
# Redis
|
| 1293 |
redis-cli ping # Should return PONG
|
| 1294 |
|
| 1295 |
+
# RedisStack
|
| 1296 |
+
redis-cli FT._LIST # Should show HNSW indexes
|
| 1297 |
```
|
| 1298 |
|
| 1299 |
### Debug Mode
|
docs/ONTOLOGY.md
CHANGED
|
@@ -27,14 +27,12 @@ Purpose: a precise, implementation-aligned vocabulary of entities, identifiers,
|
|
| 27 |
- Example: `DuckDuckGoTool` in `orka/tools/search_tools.py`
|
| 28 |
|
| 29 |
- Memory Logger: persistent storage and search for memories and orchestration logs
|
| 30 |
-
- Implementations: `RedisStackMemoryLogger`, `RedisMemoryLogger`
|
| 31 |
- Concerns: serialization, decay, vector search, namespaces, categories
|
| 32 |
|
| 33 |
- Registry: runtime resource registry (LLM, embedder, memory, tools)
|
| 34 |
- Type: `Registry` (see `orka/contracts.py`)
|
| 35 |
|
| 36 |
-
- Schema Manager: serialization/deserialization schemas for Kafka/Avro/Protobuf
|
| 37 |
-
- Implements: `orka/memory/schema_manager.py`
|
| 38 |
|
| 39 |
## Data Contracts (authoritative types)
|
| 40 |
|
|
@@ -76,7 +74,6 @@ Defined in `orka/contracts.py`.
|
|
| 76 |
- ExecutionEngine constructs Context for each Agent using `input` and `previous_outputs`
|
| 77 |
- Agent produces Output; Orchestrator updates `previous_outputs` and decides next steps
|
| 78 |
- Memory Logger records events and stored knowledge as MemoryEntry
|
| 79 |
-
- Schema Manager defines serialization for external topics (e.g., Kafka)
|
| 80 |
- Tools are invoked by Agents within their implementation
|
| 81 |
|
| 82 |
## Lifecycle and Event Flow
|
|
@@ -198,8 +195,7 @@ graph LR
|
|
| 198 |
|
| 199 |
subgraph Infrastructure
|
| 200 |
REG[Registry]
|
| 201 |
-
MEM[Memory Logger\nRedisStack/Redis
|
| 202 |
-
SCH[SchemaManager]
|
| 203 |
TOOL[Tool\nDuckDuckGo]
|
| 204 |
end
|
| 205 |
|
|
@@ -212,7 +208,6 @@ graph LR
|
|
| 212 |
A -- may use --> TOOL
|
| 213 |
O -- provides --> REG
|
| 214 |
REG -- provides --> MEM
|
| 215 |
-
MEM -- serializes --> SCH
|
| 216 |
N1 -. control flow .- N2
|
| 217 |
N2 -. parallel .- N3
|
| 218 |
N4 -. iterate .- A
|
|
@@ -230,7 +225,6 @@ graph LR
|
|
| 230 |
|
| 231 |
## Validation and Schemas
|
| 232 |
|
| 233 |
-
- Use `SchemaManager` for Avro/Protobuf when integrating with Kafka
|
| 234 |
- For RedisStack, ensure serialized `metadata` contains self-describing fields (e.g., `log_type`, `category`, `namespace`)
|
| 235 |
|
| 236 |
## Practical Cross-References
|
|
@@ -240,4 +234,3 @@ graph LR
|
|
| 240 |
- Memory (RedisStack): `orka/memory/redisstack_logger.py`
|
| 241 |
- Memory (Redis): `orka/memory/redis_logger.py`
|
| 242 |
- Tools: `orka/tools/search_tools.py`
|
| 243 |
-
- Schema: `orka/memory/schema_manager.py`
|
|
|
|
| 27 |
- Example: `DuckDuckGoTool` in `orka/tools/search_tools.py`
|
| 28 |
|
| 29 |
- Memory Logger: persistent storage and search for memories and orchestration logs
|
| 30 |
+
- Implementations: `RedisStackMemoryLogger`, `RedisMemoryLogger`
|
| 31 |
- Concerns: serialization, decay, vector search, namespaces, categories
|
| 32 |
|
| 33 |
- Registry: runtime resource registry (LLM, embedder, memory, tools)
|
| 34 |
- Type: `Registry` (see `orka/contracts.py`)
|
| 35 |
|
|
|
|
|
|
|
| 36 |
|
| 37 |
## Data Contracts (authoritative types)
|
| 38 |
|
|
|
|
| 74 |
- ExecutionEngine constructs Context for each Agent using `input` and `previous_outputs`
|
| 75 |
- Agent produces Output; Orchestrator updates `previous_outputs` and decides next steps
|
| 76 |
- Memory Logger records events and stored knowledge as MemoryEntry
|
|
|
|
| 77 |
- Tools are invoked by Agents within their implementation
|
| 78 |
|
| 79 |
## Lifecycle and Event Flow
|
|
|
|
| 195 |
|
| 196 |
subgraph Infrastructure
|
| 197 |
REG[Registry]
|
| 198 |
+
MEM[Memory Logger\nRedisStack/Redis]
|
|
|
|
| 199 |
TOOL[Tool\nDuckDuckGo]
|
| 200 |
end
|
| 201 |
|
|
|
|
| 208 |
A -- may use --> TOOL
|
| 209 |
O -- provides --> REG
|
| 210 |
REG -- provides --> MEM
|
|
|
|
| 211 |
N1 -. control flow .- N2
|
| 212 |
N2 -. parallel .- N3
|
| 213 |
N4 -. iterate .- A
|
|
|
|
| 225 |
|
| 226 |
## Validation and Schemas
|
| 227 |
|
|
|
|
| 228 |
- For RedisStack, ensure serialized `metadata` contains self-describing fields (e.g., `log_type`, `category`, `namespace`)
|
| 229 |
|
| 230 |
## Practical Cross-References
|
|
|
|
| 234 |
- Memory (RedisStack): `orka/memory/redisstack_logger.py`
|
| 235 |
- Memory (Redis): `orka/memory/redis_logger.py`
|
| 236 |
- Tools: `orka/tools/search_tools.py`
|
|
|
docs/README_BACKENDS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# OrKa Backend Selection Guide
|
| 2 |
|
| 3 |
-
OrKa supports
|
| 4 |
|
| 5 |
## 🎯 **Backend Comparison**
|
| 6 |
|
|
@@ -8,8 +8,6 @@ OrKa supports multiple memory backends: **RedisStack** (default), **Redis** (leg
|
|
| 8 |
|---------|-------------|----------|---------------|------------------|
|
| 9 |
| **RedisStack** | ⚡ 100x faster | Production AI workloads | ✅ HNSW indexing | 🟢 Simple |
|
| 10 |
| **Redis** | 🔄 Standard | Development, legacy | ❌ Basic search | 🟢 Simple |
|
| 11 |
-
| **Kafka** | 🚀 Hybrid | Enterprise, audit trails | ✅ Via RedisStack | 🟡 Moderate |
|
| 12 |
-
| **Dual** | 🔄 Variable | Testing, migration | ✅ Via RedisStack | 🔴 Complex |
|
| 13 |
|
| 14 |
## 🚀 Quick Start Options
|
| 15 |
|
|
@@ -18,207 +16,194 @@ OrKa supports multiple memory backends: **RedisStack** (default), **Redis** (leg
|
|
| 18 |
# Start with RedisStack backend (default - recommended)
|
| 19 |
python -m orka.orka_start
|
| 20 |
|
| 21 |
-
# Start with Kafka backend (hybrid: Kafka events + RedisStack memory)
|
| 22 |
-
ORKA_MEMORY_BACKEND=kafka python -m orka.orka_start
|
| 23 |
-
|
| 24 |
-
# Start with dual backend (both Redis and Kafka)
|
| 25 |
-
ORKA_MEMORY_BACKEND=dual python -m orka.orka_start
|
| 26 |
-
|
| 27 |
# Force basic Redis (legacy/development only)
|
| 28 |
ORKA_FORCE_BASIC_REDIS=true python -m orka.orka_start
|
| 29 |
```
|
| 30 |
|
| 31 |
-
### Option 2:
|
| 32 |
-
```bash
|
| 33 |
-
# Start with basic Redis backend (legacy/development)
|
| 34 |
-
python orka/start_redis_only.py
|
| 35 |
-
|
| 36 |
-
# Start with Kafka backend (hybrid with RedisStack)
|
| 37 |
-
python -m orka.start_kafka
|
| 38 |
-
```
|
| 39 |
-
|
| 40 |
-
### Option 3: Docker Scripts (Alternative)
|
| 41 |
```bash
|
| 42 |
# Windows
|
| 43 |
orka\docker\start-redis.bat
|
| 44 |
-
orka\docker\start-kafka.bat
|
| 45 |
|
| 46 |
# Linux/macOS
|
| 47 |
./orka/docker/start-redis.sh
|
| 48 |
-
./orka/docker/start-kafka.sh
|
| 49 |
```
|
| 50 |
|
| 51 |
-
##
|
| 52 |
-
|
| 53 |
-
### RedisStack Backend (Default)
|
| 54 |
-
- **Orka API**: http://localhost:8000
|
| 55 |
-
- **RedisStack**: localhost:6380 (Redis + vector search modules)
|
| 56 |
-
|
| 57 |
-
### Basic Redis Backend (Legacy)
|
| 58 |
-
- **Orka API**: http://localhost:8000
|
| 59 |
-
- **Redis**: localhost:6380 (basic Redis only)
|
| 60 |
|
| 61 |
-
###
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
### Dual Backend
|
| 68 |
-
- **Orka API**: http://localhost:8002
|
| 69 |
-
- **Redis**: localhost:6380
|
| 70 |
-
- **Kafka**: localhost:9092
|
| 71 |
-
- **Zookeeper**: localhost:2181
|
| 72 |
|
| 73 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
-
##
|
| 76 |
-
- `ORKA_MEMORY_BACKEND`: Choose backend type (`redisstack`, `redis`, `kafka`, `dual`)
|
| 77 |
-
- `ORKA_FORCE_BASIC_REDIS`: Force basic Redis mode (`true`/`false`)
|
| 78 |
|
| 79 |
-
### RedisStack
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
#
|
| 83 |
-
-
|
| 84 |
-
|
| 85 |
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
-
###
|
| 89 |
```bash
|
| 90 |
-
#
|
| 91 |
-
|
|
|
|
| 92 |
|
| 93 |
-
#
|
| 94 |
-
|
| 95 |
-
docker-compose --profile kafka ps
|
| 96 |
-
docker-compose --profile dual ps
|
| 97 |
```
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
```
|
| 107 |
|
| 108 |
-
###
|
| 109 |
-
```
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
```
|
| 116 |
|
| 117 |
-
##
|
| 118 |
-
|
| 119 |
-
### Runtime Switch (Dual Backend)
|
| 120 |
-
When using dual backend, you can switch between Redis and Kafka at runtime by changing the `ORKA_MEMORY_BACKEND` environment variable in your application configuration.
|
| 121 |
|
| 122 |
-
###
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
```
|
| 128 |
|
| 129 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
-
##
|
| 132 |
|
| 133 |
-
|
| 134 |
```bash
|
| 135 |
-
#
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
netstat -an | grep 9092 # Kafka
|
| 141 |
```
|
| 142 |
|
| 143 |
-
|
| 144 |
-
- Redis: Usually ready in 5-10 seconds
|
| 145 |
-
- Kafka: Can take 15-30 seconds to initialize
|
| 146 |
-
- Check logs: `docker-compose logs <service-name>`
|
| 147 |
-
|
| 148 |
-
**Wrong backend selected:**
|
| 149 |
-
- Check environment variable: `echo $ORKA_MEMORY_BACKEND`
|
| 150 |
-
- Verify correct ports are being used (see endpoints above)
|
| 151 |
-
|
| 152 |
-
### Debug Commands
|
| 153 |
```bash
|
| 154 |
-
#
|
| 155 |
-
|
|
|
|
| 156 |
|
| 157 |
-
#
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
# View Orka memory logs
|
| 161 |
-
# Redis: docker-compose exec redis redis-cli monitor
|
| 162 |
-
# Kafka: docker-compose exec kafka kafka-console-consumer --bootstrap-server localhost:29092 --topic orka-memory-events --from-beginning
|
| 163 |
```
|
| 164 |
|
| 165 |
-
##
|
| 166 |
|
| 167 |
-
###
|
| 168 |
-
- **Best for**: Production AI workloads, vector search applications, intelligent memory
|
| 169 |
-
- **Features**: 100x faster vector search, HNSW indexing, semantic similarity, automatic fallback to basic Redis
|
| 170 |
-
- **Limitations**: Requires RedisStack installation (or falls back gracefully)
|
| 171 |
|
| 172 |
-
|
| 173 |
-
- **
|
| 174 |
-
- **
|
| 175 |
-
- **Limitations**: No vector search, basic text matching only
|
| 176 |
|
| 177 |
-
|
| 178 |
-
- **
|
| 179 |
-
- **
|
| 180 |
-
- **Limitations**: More complex setup, requires both Kafka and RedisStack infrastructure
|
| 181 |
|
| 182 |
-
|
| 183 |
-
- **
|
| 184 |
-
- **
|
| 185 |
-
- **Limitations**: Uses resources for both systems
|
| 186 |
|
| 187 |
-
##
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
-
#
|
| 190 |
-
|
| 191 |
-
# Your OrKa workflow code remains the same regardless of backend
|
| 192 |
-
from orka.orchestrator import Orchestrator
|
| 193 |
|
| 194 |
-
|
| 195 |
-
|
| 196 |
```
|
| 197 |
|
| 198 |
-
##
|
| 199 |
-
```python
|
| 200 |
-
import os
|
| 201 |
|
| 202 |
-
#
|
| 203 |
-
|
| 204 |
-
|
|
|
|
| 205 |
|
| 206 |
-
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
```
|
| 209 |
|
| 210 |
-
##
|
| 211 |
-
```python
|
| 212 |
-
from orka.memory_logger import create_memory_logger
|
| 213 |
|
| 214 |
-
|
| 215 |
-
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
-
#
|
| 218 |
-
import os
|
| 219 |
-
os.environ["ORKA_FORCE_BASIC_REDIS"] = "true"
|
| 220 |
-
memory = create_memory_logger("redis", redis_url="redis://localhost:6380")
|
| 221 |
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
|
|
|
|
|
| 1 |
# OrKa Backend Selection Guide
|
| 2 |
|
| 3 |
+
OrKa supports Redis-based memory backends: **RedisStack** (recommended) and **Redis** (basic). Choose the right backend for your use case.
|
| 4 |
|
| 5 |
## 🎯 **Backend Comparison**
|
| 6 |
|
|
|
|
| 8 |
|---------|-------------|----------|---------------|------------------|
|
| 9 |
| **RedisStack** | ⚡ 100x faster | Production AI workloads | ✅ HNSW indexing | 🟢 Simple |
|
| 10 |
| **Redis** | 🔄 Standard | Development, legacy | ❌ Basic search | 🟢 Simple |
|
|
|
|
|
|
|
| 11 |
|
| 12 |
## 🚀 Quick Start Options
|
| 13 |
|
|
|
|
| 16 |
# Start with RedisStack backend (default - recommended)
|
| 17 |
python -m orka.orka_start
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Force basic Redis (legacy/development only)
|
| 20 |
ORKA_FORCE_BASIC_REDIS=true python -m orka.orka_start
|
| 21 |
```
|
| 22 |
|
| 23 |
+
### Option 2: Docker Scripts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
```bash
|
| 25 |
# Windows
|
| 26 |
orka\docker\start-redis.bat
|
|
|
|
| 27 |
|
| 28 |
# Linux/macOS
|
| 29 |
./orka/docker/start-redis.sh
|
|
|
|
| 30 |
```
|
| 31 |
|
| 32 |
+
## 📊 **Performance Benchmarks**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
### Vector Search Performance
|
| 35 |
+
```
|
| 36 |
+
RedisStack HNSW: 1.2ms avg query time (100x faster)
|
| 37 |
+
Redis Basic: 120ms avg query time
|
| 38 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
### Memory Operations
|
| 41 |
+
```
|
| 42 |
+
RedisStack: 10,000 ops/sec
|
| 43 |
+
Redis: 8,000 ops/sec
|
| 44 |
+
```
|
| 45 |
|
| 46 |
+
## 🔧 **Configuration**
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
### RedisStack (Recommended)
|
| 49 |
+
```bash
|
| 50 |
+
# Environment variables
|
| 51 |
+
export ORKA_MEMORY_BACKEND=redisstack
|
| 52 |
+
export REDIS_URL=redis://localhost:6380/0
|
| 53 |
|
| 54 |
+
# Start OrKa
|
| 55 |
+
python -m orka.orka_start
|
| 56 |
+
```
|
| 57 |
|
| 58 |
+
**Features:**
|
| 59 |
+
- ✅ HNSW vector indexing for 100x faster semantic search
|
| 60 |
+
- ✅ Advanced memory decay and compression
|
| 61 |
+
- ✅ Real-time memory analytics
|
| 62 |
+
- ✅ Automatic index optimization
|
| 63 |
|
| 64 |
+
### Redis (Basic)
|
| 65 |
```bash
|
| 66 |
+
# Environment variables
|
| 67 |
+
export ORKA_MEMORY_BACKEND=redis
|
| 68 |
+
export REDIS_URL=redis://localhost:6379/0
|
| 69 |
|
| 70 |
+
# Start OrKa
|
| 71 |
+
python -m orka.orka_start
|
|
|
|
|
|
|
| 72 |
```
|
| 73 |
|
| 74 |
+
**Features:**
|
| 75 |
+
- ✅ Fast in-memory storage
|
| 76 |
+
- ✅ Basic memory operations
|
| 77 |
+
- ❌ No vector search capabilities
|
| 78 |
+
- ❌ Limited semantic search
|
| 79 |
+
|
| 80 |
+
## 🐳 **Docker Configuration**
|
| 81 |
+
|
| 82 |
+
### RedisStack Setup
|
| 83 |
+
```yaml
|
| 84 |
+
version: '3.8'
|
| 85 |
+
services:
|
| 86 |
+
redis-stack:
|
| 87 |
+
image: redis/redis-stack:latest
|
| 88 |
+
ports:
|
| 89 |
+
- "6380:6380"
|
| 90 |
+
volumes:
|
| 91 |
+
- redis_data:/data
|
| 92 |
+
environment:
|
| 93 |
+
- REDIS_ARGS=--save 60 1000
|
| 94 |
+
|
| 95 |
+
volumes:
|
| 96 |
+
redis_data:
|
| 97 |
```
|
| 98 |
|
| 99 |
+
### Basic Redis Setup
|
| 100 |
+
```yaml
|
| 101 |
+
version: '3.8'
|
| 102 |
+
services:
|
| 103 |
+
redis:
|
| 104 |
+
image: redis:latest
|
| 105 |
+
ports:
|
| 106 |
+
- "6379:6379"
|
| 107 |
+
volumes:
|
| 108 |
+
- redis_data:/data
|
| 109 |
+
|
| 110 |
+
volumes:
|
| 111 |
+
redis_data:
|
| 112 |
```
|
| 113 |
|
| 114 |
+
## 🔍 **Backend Selection Guide**
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
+
### Choose **RedisStack** if:
|
| 117 |
+
- ✅ You need semantic/vector search
|
| 118 |
+
- ✅ Building production AI applications
|
| 119 |
+
- ✅ Want 100x faster query performance
|
| 120 |
+
- ✅ Need advanced memory features
|
|
|
|
| 121 |
|
| 122 |
+
### Choose **Redis** if:
|
| 123 |
+
- ✅ Simple development setup
|
| 124 |
+
- ✅ Legacy system compatibility
|
| 125 |
+
- ✅ No vector search requirements
|
| 126 |
+
- ✅ Minimal resource usage
|
| 127 |
|
| 128 |
+
## 🛠️ **Advanced Configuration**
|
| 129 |
|
| 130 |
+
### Memory Decay Settings
|
| 131 |
```bash
|
| 132 |
+
# Enable intelligent memory decay
|
| 133 |
+
export ORKA_MEMORY_DECAY_ENABLED=true
|
| 134 |
+
export ORKA_MEMORY_DECAY_SHORT_TERM_HOURS=2
|
| 135 |
+
export ORKA_MEMORY_DECAY_LONG_TERM_HOURS=168
|
| 136 |
+
export ORKA_MEMORY_DECAY_CHECK_INTERVAL_MINUTES=30
|
|
|
|
| 137 |
```
|
| 138 |
|
| 139 |
+
### Performance Tuning
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
```bash
|
| 141 |
+
# Redis connection pooling
|
| 142 |
+
export REDIS_MAX_CONNECTIONS=100
|
| 143 |
+
export REDIS_CONNECTION_TIMEOUT=5
|
| 144 |
|
| 145 |
+
# Memory optimization
|
| 146 |
+
export ORKA_MEMORY_COMPRESSION_ENABLED=true
|
| 147 |
+
export ORKA_MEMORY_BATCH_SIZE=1000
|
|
|
|
|
|
|
|
|
|
| 148 |
```
|
| 149 |
|
| 150 |
+
## 🔧 **Troubleshooting**
|
| 151 |
|
| 152 |
+
### Common Issues
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
+
**"FT.CREATE unknown command"**
|
| 155 |
+
- **Cause:** Using basic Redis instead of RedisStack
|
| 156 |
+
- **Solution:** Switch to RedisStack or use `ORKA_FORCE_BASIC_REDIS=true`
|
|
|
|
| 157 |
|
| 158 |
+
**Slow vector search performance**
|
| 159 |
+
- **Cause:** HNSW index not created or optimized
|
| 160 |
+
- **Solution:** Check index status with `redis-cli FT._LIST`
|
|
|
|
| 161 |
|
| 162 |
+
**Connection refused errors**
|
| 163 |
+
- **Cause:** Redis/RedisStack not running
|
| 164 |
+
- **Solution:** Start Redis with `docker run -p 6380:6380 redis/redis-stack`
|
|
|
|
| 165 |
|
| 166 |
+
### Health Checks
|
| 167 |
+
```bash
|
| 168 |
+
# Check Redis connection
|
| 169 |
+
redis-cli ping
|
| 170 |
|
| 171 |
+
# Check RedisStack features
|
| 172 |
+
redis-cli FT._LIST
|
|
|
|
|
|
|
| 173 |
|
| 174 |
+
# Monitor OrKa memory
|
| 175 |
+
orka memory watch
|
| 176 |
```
|
| 177 |
|
| 178 |
+
## 📈 **Migration Guide**
|
|
|
|
|
|
|
| 179 |
|
| 180 |
+
### From Basic Redis to RedisStack
|
| 181 |
+
```bash
|
| 182 |
+
# 1. Stop current Redis
|
| 183 |
+
docker stop redis
|
| 184 |
|
| 185 |
+
# 2. Start RedisStack
|
| 186 |
+
docker run -d -p 6380:6380 redis/redis-stack
|
| 187 |
+
|
| 188 |
+
# 3. Update environment
|
| 189 |
+
export ORKA_MEMORY_BACKEND=redisstack
|
| 190 |
+
export REDIS_URL=redis://localhost:6380/0
|
| 191 |
+
|
| 192 |
+
# 4. Restart OrKa
|
| 193 |
+
python -m orka.orka_start
|
| 194 |
```
|
| 195 |
|
| 196 |
+
## 🎯 **Best Practices**
|
|
|
|
|
|
|
| 197 |
|
| 198 |
+
1. **Production:** Always use RedisStack for production workloads
|
| 199 |
+
2. **Development:** RedisStack recommended, Redis acceptable for simple testing
|
| 200 |
+
3. **Monitoring:** Use `orka memory watch` to monitor performance
|
| 201 |
+
4. **Backup:** Configure Redis persistence with `--save` options
|
| 202 |
+
5. **Security:** Use Redis AUTH and network isolation in production
|
| 203 |
|
| 204 |
+
## 📚 **Additional Resources**
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
+
- [Memory System Guide](MEMORY_SYSTEM_GUIDE.md)
|
| 207 |
+
- [Configuration Guide](CONFIGURATION.md)
|
| 208 |
+
- [Troubleshooting Guide](troubleshooting.md)
|
| 209 |
+
- [Performance Tuning](best-practices.md)
|
docs/SCHEMA_MANAGEMENT.md
DELETED
|
@@ -1,351 +0,0 @@
|
|
| 1 |
-
# OrKa Schema Management
|
| 2 |
-
|
| 3 |
-
## 🎯 Overview
|
| 4 |
-
|
| 5 |
-
OrKa has transitioned from raw JSON blobs to proper schema-based message serialization using **Confluent Schema Registry**. This provides strong type safety, schema evolution, and prevents the technical debt associated with unstructured data.
|
| 6 |
-
|
| 7 |
-
## 🏗️ Architecture
|
| 8 |
-
|
| 9 |
-
```
|
| 10 |
-
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
|
| 11 |
-
│ OrKa Memory │───▶│ Schema Registry │───▶│ Kafka Topics │
|
| 12 |
-
│ Producer │ │ (Port 8081) │ │ (Avro/Proto) │
|
| 13 |
-
└─────────────────┘ └──────────────────┘ └─────────────────┘
|
| 14 |
-
│
|
| 15 |
-
▼
|
| 16 |
-
┌──────────────────┐
|
| 17 |
-
│ Schema Evolution │
|
| 18 |
-
│ & Compatibility │
|
| 19 |
-
└──────────────────┘
|
| 20 |
-
```
|
| 21 |
-
|
| 22 |
-
## 🚀 Quick Start
|
| 23 |
-
|
| 24 |
-
### 1. Install Dependencies
|
| 25 |
-
|
| 26 |
-
```bash
|
| 27 |
-
pip install -r requirements-schema.txt
|
| 28 |
-
```
|
| 29 |
-
|
| 30 |
-
### 2. Start Schema Registry
|
| 31 |
-
|
| 32 |
-
```bash
|
| 33 |
-
# Start Kafka with Schema Registry
|
| 34 |
-
docker-compose --profile kafka up -d
|
| 35 |
-
|
| 36 |
-
# Verify Schema Registry is running
|
| 37 |
-
curl http://localhost:8081/subjects
|
| 38 |
-
```
|
| 39 |
-
|
| 40 |
-
### 3. Basic Usage
|
| 41 |
-
|
| 42 |
-
```python
|
| 43 |
-
from orka.memory.schema_manager import create_schema_manager, SchemaFormat
|
| 44 |
-
|
| 45 |
-
# Initialize schema manager
|
| 46 |
-
schema_manager = create_schema_manager(
|
| 47 |
-
registry_url='http://localhost:8081',
|
| 48 |
-
format=SchemaFormat.AVRO # or SchemaFormat.PROTOBUF
|
| 49 |
-
)
|
| 50 |
-
|
| 51 |
-
# Register schemas
|
| 52 |
-
schema_manager.register_schema('orka-memory-topic-value', 'memory_entry')
|
| 53 |
-
|
| 54 |
-
# Use in your code
|
| 55 |
-
serializer = schema_manager.get_serializer('orka-memory-topic')
|
| 56 |
-
deserializer = schema_manager.get_deserializer('orka-memory-topic')
|
| 57 |
-
```
|
| 58 |
-
|
| 59 |
-
## 📊 Available Schemas
|
| 60 |
-
|
| 61 |
-
### Avro Schema (`orka/schemas/avro/memory_entry.avsc`)
|
| 62 |
-
|
| 63 |
-
```json
|
| 64 |
-
{
|
| 65 |
-
"type": "record",
|
| 66 |
-
"name": "MemoryEntry",
|
| 67 |
-
"namespace": "orka.memory",
|
| 68 |
-
"fields": [
|
| 69 |
-
{"name": "id", "type": "string"},
|
| 70 |
-
{"name": "content", "type": "string"},
|
| 71 |
-
{"name": "metadata", "type": {
|
| 72 |
-
"type": "record",
|
| 73 |
-
"name": "MemoryMetadata",
|
| 74 |
-
"fields": [
|
| 75 |
-
{"name": "source", "type": "string"},
|
| 76 |
-
{"name": "confidence", "type": "double"},
|
| 77 |
-
{"name": "timestamp", "type": "double"},
|
| 78 |
-
{"name": "agent_id", "type": "string"},
|
| 79 |
-
{"name": "tags", "type": {"type": "array", "items": "string"}},
|
| 80 |
-
// ... more fields
|
| 81 |
-
]
|
| 82 |
-
}},
|
| 83 |
-
{"name": "similarity", "type": ["null", "double"]},
|
| 84 |
-
{"name": "ts", "type": "long"},
|
| 85 |
-
{"name": "match_type", "type": {
|
| 86 |
-
"type": "enum",
|
| 87 |
-
"symbols": ["exact", "semantic", "fuzzy", "stream", "hybrid"]
|
| 88 |
-
}},
|
| 89 |
-
{"name": "stream_key", "type": "string"}
|
| 90 |
-
]
|
| 91 |
-
}
|
| 92 |
-
```
|
| 93 |
-
|
| 94 |
-
### Protobuf Schema (`orka/schemas/protobuf/memory_entry.proto`)
|
| 95 |
-
|
| 96 |
-
```protobuf
|
| 97 |
-
syntax = "proto3";
|
| 98 |
-
package orka.memory;
|
| 99 |
-
|
| 100 |
-
message MemoryEntry {
|
| 101 |
-
string id = 1;
|
| 102 |
-
string content = 2;
|
| 103 |
-
MemoryMetadata metadata = 3;
|
| 104 |
-
optional double similarity = 4;
|
| 105 |
-
int64 ts = 5;
|
| 106 |
-
MatchType match_type = 6;
|
| 107 |
-
string stream_key = 7;
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
message MemoryMetadata {
|
| 111 |
-
string source = 1;
|
| 112 |
-
double confidence = 2;
|
| 113 |
-
repeated string tags = 8;
|
| 114 |
-
// ... more fields
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
enum MatchType {
|
| 118 |
-
SEMANTIC = 0;
|
| 119 |
-
EXACT = 1;
|
| 120 |
-
FUZZY = 2;
|
| 121 |
-
STREAM = 3;
|
| 122 |
-
HYBRID = 4;
|
| 123 |
-
}
|
| 124 |
-
```
|
| 125 |
-
|
| 126 |
-
## 🔄 Migration from JSON
|
| 127 |
-
|
| 128 |
-
### Automated Migration
|
| 129 |
-
|
| 130 |
-
```bash
|
| 131 |
-
# Analyze your existing JSON messages
|
| 132 |
-
python scripts/migrate_to_schemas.py --analyze logs/orka_trace_*.json --generate-code --create-plan
|
| 133 |
-
|
| 134 |
-
# This generates:
|
| 135 |
-
# - migration_code.py (code templates)
|
| 136 |
-
# - migration_plan.md (step-by-step plan)
|
| 137 |
-
```
|
| 138 |
-
|
| 139 |
-
### Manual Migration Steps
|
| 140 |
-
|
| 141 |
-
1. **Install Schema Dependencies**
|
| 142 |
-
```bash
|
| 143 |
-
pip install orka-reasoning[schema]
|
| 144 |
-
```
|
| 145 |
-
|
| 146 |
-
2. **Update Producers**
|
| 147 |
-
```python
|
| 148 |
-
# OLD: Raw JSON
|
| 149 |
-
producer.produce(topic, value=json.dumps(memory_obj).encode())
|
| 150 |
-
|
| 151 |
-
# NEW: Schema-based
|
| 152 |
-
from orka.memory.schema_manager import create_schema_manager
|
| 153 |
-
schema_manager = create_schema_manager()
|
| 154 |
-
serializer = schema_manager.get_serializer(topic)
|
| 155 |
-
|
| 156 |
-
producer.produce(
|
| 157 |
-
topic=topic,
|
| 158 |
-
value=serializer(memory_obj, SerializationContext(topic, MessageField.VALUE))
|
| 159 |
-
)
|
| 160 |
-
```
|
| 161 |
-
|
| 162 |
-
3. **Update Consumers**
|
| 163 |
-
```python
|
| 164 |
-
# OLD: Raw JSON
|
| 165 |
-
memory_obj = json.loads(message.value().decode())
|
| 166 |
-
|
| 167 |
-
# NEW: Schema-based
|
| 168 |
-
deserializer = schema_manager.get_deserializer(topic)
|
| 169 |
-
memory_obj = deserializer(message.value(), SerializationContext(topic, MessageField.VALUE))
|
| 170 |
-
```
|
| 171 |
-
|
| 172 |
-
## 🛠️ Schema Registry Management
|
| 173 |
-
|
| 174 |
-
### Available Endpoints
|
| 175 |
-
|
| 176 |
-
| Service | URL | Description |
|
| 177 |
-
|---------|-----|-------------|
|
| 178 |
-
| Schema Registry | `http://localhost:8081` | Main registry API |
|
| 179 |
-
| Schema Registry UI | `http://localhost:8082` | Web interface for schemas |
|
| 180 |
-
|
| 181 |
-
### Common Operations
|
| 182 |
-
|
| 183 |
-
```bash
|
| 184 |
-
# List all subjects
|
| 185 |
-
curl http://localhost:8081/subjects
|
| 186 |
-
|
| 187 |
-
# Get schema for a subject
|
| 188 |
-
curl http://localhost:8081/subjects/orka-memory-topic-value/versions/latest
|
| 189 |
-
|
| 190 |
-
# Register a new schema
|
| 191 |
-
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
|
| 192 |
-
--data '{"schema": "..."}' \
|
| 193 |
-
http://localhost:8081/subjects/orka-memory-topic-value/versions
|
| 194 |
-
|
| 195 |
-
# Check compatibility
|
| 196 |
-
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
|
| 197 |
-
--data '{"schema": "..."}' \
|
| 198 |
-
http://localhost:8081/compatibility/subjects/orka-memory-topic-value/versions/latest
|
| 199 |
-
```
|
| 200 |
-
|
| 201 |
-
## 🔄 Schema Evolution
|
| 202 |
-
|
| 203 |
-
### Backward Compatible Changes ✅
|
| 204 |
-
|
| 205 |
-
- Adding optional fields with defaults
|
| 206 |
-
- Adding new enum values (at the end)
|
| 207 |
-
- Removing fields (with proper handling)
|
| 208 |
-
|
| 209 |
-
### Breaking Changes ❌
|
| 210 |
-
|
| 211 |
-
- Removing required fields
|
| 212 |
-
- Changing field types
|
| 213 |
-
- Reordering fields (Protobuf)
|
| 214 |
-
- Changing enum values
|
| 215 |
-
|
| 216 |
-
### Evolution Example
|
| 217 |
-
|
| 218 |
-
```python
|
| 219 |
-
# Version 1: Original schema
|
| 220 |
-
{
|
| 221 |
-
"name": "MemoryEntry",
|
| 222 |
-
"fields": [
|
| 223 |
-
{"name": "id", "type": "string"},
|
| 224 |
-
{"name": "content", "type": "string"}
|
| 225 |
-
]
|
| 226 |
-
}
|
| 227 |
-
|
| 228 |
-
# Version 2: Added optional field (backward compatible)
|
| 229 |
-
{
|
| 230 |
-
"name": "MemoryEntry",
|
| 231 |
-
"fields": [
|
| 232 |
-
{"name": "id", "type": "string"},
|
| 233 |
-
{"name": "content", "type": "string"},
|
| 234 |
-
{"name": "confidence", "type": ["null", "double"], "default": null}
|
| 235 |
-
]
|
| 236 |
-
}
|
| 237 |
-
```
|
| 238 |
-
|
| 239 |
-
## 📊 Monitoring & Debugging
|
| 240 |
-
|
| 241 |
-
### Real-time Logs
|
| 242 |
-
|
| 243 |
-
```bash
|
| 244 |
-
# Schema Registry logs
|
| 245 |
-
docker logs -f docker-schema-registry-1
|
| 246 |
-
|
| 247 |
-
# Kafka logs with schema info
|
| 248 |
-
docker logs -f docker-kafka-1 | grep -i schema
|
| 249 |
-
|
| 250 |
-
# All services
|
| 251 |
-
docker-compose logs -f schema-registry kafka
|
| 252 |
-
```
|
| 253 |
-
|
| 254 |
-
### Schema Registry UI
|
| 255 |
-
|
| 256 |
-
Visit `http://localhost:8082` to:
|
| 257 |
-
- Browse registered schemas
|
| 258 |
-
- View schema evolution history
|
| 259 |
-
- Test schema compatibility
|
| 260 |
-
- Manage schema subjects
|
| 261 |
-
|
| 262 |
-
### Troubleshooting
|
| 263 |
-
|
| 264 |
-
| Problem | Solution |
|
| 265 |
-
|---------|----------|
|
| 266 |
-
| Schema not found | Check registration: `curl http://localhost:8081/subjects` |
|
| 267 |
-
| Serialization error | Validate data against schema |
|
| 268 |
-
| Compatibility error | Review schema evolution rules |
|
| 269 |
-
| Registry unreachable | Verify Docker services: `docker ps` |
|
| 270 |
-
|
| 271 |
-
## 🎛️ Configuration
|
| 272 |
-
|
| 273 |
-
### Environment Variables
|
| 274 |
-
|
| 275 |
-
```bash
|
| 276 |
-
# Schema Registry URL
|
| 277 |
-
KAFKA_SCHEMA_REGISTRY_URL=http://schema-registry:8081
|
| 278 |
-
|
| 279 |
-
# Schema format preference
|
| 280 |
-
ORKA_SCHEMA_FORMAT=avro # or protobuf
|
| 281 |
-
|
| 282 |
-
# Schema compatibility level
|
| 283 |
-
SCHEMA_REGISTRY_COMPATIBILITY_LEVEL=BACKWARD
|
| 284 |
-
```
|
| 285 |
-
|
| 286 |
-
### Docker Compose Configuration
|
| 287 |
-
|
| 288 |
-
```yaml
|
| 289 |
-
services:
|
| 290 |
-
schema-registry:
|
| 291 |
-
image: confluentinc/cp-schema-registry:latest
|
| 292 |
-
ports:
|
| 293 |
-
- "8081:8081"
|
| 294 |
-
environment:
|
| 295 |
-
SCHEMA_REGISTRY_HOST_NAME: schema-registry
|
| 296 |
-
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: kafka:29092
|
| 297 |
-
SCHEMA_REGISTRY_LISTENERS: http://0.0.0.0:8081
|
| 298 |
-
```
|
| 299 |
-
|
| 300 |
-
## 🏎️ Performance Considerations
|
| 301 |
-
|
| 302 |
-
### Avro vs Protobuf
|
| 303 |
-
|
| 304 |
-
| Feature | Avro | Protobuf |
|
| 305 |
-
|---------|------|----------|
|
| 306 |
-
| **Size** | Smaller (no field tags) | Slightly larger |
|
| 307 |
-
| **Speed** | Fast | Very fast |
|
| 308 |
-
| **Schema Evolution** | Excellent | Good |
|
| 309 |
-
| **Language Support** | Good | Excellent |
|
| 310 |
-
| **Best For** | Data pipelines | Microservices |
|
| 311 |
-
|
| 312 |
-
### Recommendations
|
| 313 |
-
|
| 314 |
-
- **Use Avro** for data-heavy applications with frequent schema changes
|
| 315 |
-
- **Use Protobuf** for high-performance APIs and cross-language compatibility
|
| 316 |
-
- **Enable compression** at Kafka level for additional space savings
|
| 317 |
-
- **Cache serializers/deserializers** to avoid schema registry lookups
|
| 318 |
-
|
| 319 |
-
## 🔒 Security
|
| 320 |
-
|
| 321 |
-
### Schema Registry Security
|
| 322 |
-
|
| 323 |
-
```yaml
|
| 324 |
-
# Add to docker-compose.yml for production
|
| 325 |
-
environment:
|
| 326 |
-
SCHEMA_REGISTRY_AUTHENTICATION_METHOD: BASIC
|
| 327 |
-
SCHEMA_REGISTRY_AUTHENTICATION_REALM: SchemaRegistry
|
| 328 |
-
SCHEMA_REGISTRY_AUTHENTICATION_ROLES: admin,user
|
| 329 |
-
```
|
| 330 |
-
|
| 331 |
-
### Access Control
|
| 332 |
-
|
| 333 |
-
- Implement role-based access to schema subjects
|
| 334 |
-
- Use HTTPS for schema registry in production
|
| 335 |
-
- Restrict schema modification permissions
|
| 336 |
-
- Monitor schema changes and access patterns
|
| 337 |
-
|
| 338 |
-
## 📚 Additional Resources
|
| 339 |
-
|
| 340 |
-
- [Confluent Schema Registry Documentation](https://docs.confluent.io/platform/current/schema-registry/)
|
| 341 |
-
- [Avro Specification](https://avro.apache.org/docs/current/spec.html)
|
| 342 |
-
- [Protocol Buffers Documentation](https://developers.google.com/protocol-buffers)
|
| 343 |
-
- [Schema Evolution Best Practices](https://docs.confluent.io/platform/current/schema-registry/avro.html#schema-evolution)
|
| 344 |
-
|
| 345 |
-
---
|
| 346 |
-
|
| 347 |
-
**Next Steps**: After implementing schema management, consider adding:
|
| 348 |
-
- Schema validation in CI/CD pipelines
|
| 349 |
-
- Automated schema testing
|
| 350 |
-
- Data lineage tracking
|
| 351 |
-
- Schema governance policies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docs/api-reference.md
CHANGED
|
@@ -14,7 +14,6 @@ Complete API documentation for OrKa's core components, including classes, method
|
|
| 14 |
- [Environment Variables](#environment-variables)
|
| 15 |
3. [Memory Backend](#memory-backend)
|
| 16 |
- [RedisStack](#redisstack)
|
| 17 |
-
- [Kafka](#kafka)
|
| 18 |
4. [CLI Reference](#cli-reference)
|
| 19 |
|
| 20 |
## Core Components
|
|
@@ -299,17 +298,6 @@ Performance:
|
|
| 299 |
- Concurrent Searches: 1000+
|
| 300 |
- Index Updates: Automatic
|
| 301 |
|
| 302 |
-
### Kafka
|
| 303 |
-
|
| 304 |
-
Optional streaming backend for production deployments.
|
| 305 |
-
|
| 306 |
-
Configuration:
|
| 307 |
-
```yaml
|
| 308 |
-
memory_config:
|
| 309 |
-
backend: kafka
|
| 310 |
-
bootstrap_servers: localhost:9092
|
| 311 |
-
schema_registry_url: http://localhost:8081
|
| 312 |
-
topic_prefix: orka-memory
|
| 313 |
```
|
| 314 |
|
| 315 |
Features:
|
|
@@ -335,7 +323,7 @@ orka memory cleanup
|
|
| 335 |
|
| 336 |
# Start OrKa services
|
| 337 |
orka-start # Development (Redis)
|
| 338 |
-
orka-
|
| 339 |
|
| 340 |
# Check system health
|
| 341 |
orka system status
|
|
|
|
| 14 |
- [Environment Variables](#environment-variables)
|
| 15 |
3. [Memory Backend](#memory-backend)
|
| 16 |
- [RedisStack](#redisstack)
|
|
|
|
| 17 |
4. [CLI Reference](#cli-reference)
|
| 18 |
|
| 19 |
## Core Components
|
|
|
|
| 298 |
- Concurrent Searches: 1000+
|
| 299 |
- Index Updates: Automatic
|
| 300 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
```
|
| 302 |
|
| 303 |
Features:
|
|
|
|
| 323 |
|
| 324 |
# Start OrKa services
|
| 325 |
orka-start # Development (Redis)
|
| 326 |
+
orka-start # Production (RedisStack)
|
| 327 |
|
| 328 |
# Check system health
|
| 329 |
orka system status
|
docs/architecture.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
# OrKa Architecture V0.7.0 ***(Patent Pending)***
|
| 4 |
|
| 5 |
-
OrKa (Orchestrator Kit for Agentic Reasoning) is built on a revolutionary architecture: modular AI agents orchestrated through a declarative YAML interface, with **100x faster vector search** powered by RedisStack HNSW indexing
|
| 6 |
|
| 7 |
This document breaks down the key architectural components and how they work together in the V0.7.0 unified architecture.
|
| 8 |
|
|
@@ -20,7 +20,7 @@ This document breaks down the key architectural components and how they work tog
|
|
| 20 |
- **Agents:** Pluggable units of reasoning (e.g., classifier, validator, search agent).
|
| 21 |
- **Orchestrator:** Controls the flow of data between agents with RedisStack memory.
|
| 22 |
- **RedisStack HNSW:** Ultra-fast vector indexing for semantic memory search.
|
| 23 |
-
- **
|
| 24 |
- **YAML Config:** Describes the orchestration graph with memory configuration.
|
| 25 |
|
| 26 |
---
|
|
@@ -148,10 +148,10 @@ registry.register_agent("my_custom_agent", MyCustomAgent)
|
|
| 148 |
- **Performance**: Sub-millisecond search latency, 50x write throughput improvement
|
| 149 |
- **Features**: Automatic index creation, graceful fallback to basic Redis
|
| 150 |
|
| 151 |
-
###
|
| 152 |
-
- **Event Streaming**:
|
| 153 |
-
- **Memory Layer**: RedisStack HNSW for all memory operations
|
| 154 |
-
- **
|
| 155 |
|
| 156 |
### Basic Redis (Legacy)
|
| 157 |
- **Compatibility Mode**: Available via `ORKA_FORCE_BASIC_REDIS=true`
|
|
@@ -165,7 +165,7 @@ registry.register_agent("my_custom_agent", MyCustomAgent)
|
|
| 165 |
OrKa V0.7.0 is fully driven by `orka.yaml`, which defines:
|
| 166 |
- Agent IDs and types with RedisStack memory loggers
|
| 167 |
- Memory configuration with decay rules and HNSW settings
|
| 168 |
-
- Backend selection (redisstack/
|
| 169 |
- Performance monitoring and observability settings
|
| 170 |
|
| 171 |
This allows reproducible reasoning pipelines with enterprise-grade memory.
|
|
@@ -210,7 +210,7 @@ All agent outputs are logged with HNSW-optimized metadata:
|
|
| 210 |
## ✅ V0.7.0 Completed Features
|
| 211 |
|
| 212 |
- ✅ **RedisStack HNSW Integration** - 100x faster vector search across all components
|
| 213 |
-
- ✅ **
|
| 214 |
- ✅ **Professional CLI Dashboard** - Real-time HNSW performance monitoring
|
| 215 |
- ✅ **Zero-Breaking Migration** - Complete backward compatibility maintained
|
| 216 |
- ✅ **Unified Architecture** - All components use RedisStack with intelligent fallback
|
|
|
|
| 2 |
|
| 3 |
# OrKa Architecture V0.7.0 ***(Patent Pending)***
|
| 4 |
|
| 5 |
+
OrKa (Orchestrator Kit for Agentic Reasoning) is built on a revolutionary architecture: modular AI agents orchestrated through a declarative YAML interface, with **100x faster vector search** powered by RedisStack HNSW indexing.
|
| 6 |
|
| 7 |
This document breaks down the key architectural components and how they work together in the V0.7.0 unified architecture.
|
| 8 |
|
|
|
|
| 20 |
- **Agents:** Pluggable units of reasoning (e.g., classifier, validator, search agent).
|
| 21 |
- **Orchestrator:** Controls the flow of data between agents with RedisStack memory.
|
| 22 |
- **RedisStack HNSW:** Ultra-fast vector indexing for semantic memory search.
|
| 23 |
+
- **Redis Streams:** High-performance event streaming and memory operations.
|
| 24 |
- **YAML Config:** Describes the orchestration graph with memory configuration.
|
| 25 |
|
| 26 |
---
|
|
|
|
| 148 |
- **Performance**: Sub-millisecond search latency, 50x write throughput improvement
|
| 149 |
- **Features**: Automatic index creation, graceful fallback to basic Redis
|
| 150 |
|
| 151 |
+
### RedisStack (Enterprise)
|
| 152 |
+
- **Event Streaming**: Redis Streams handle message queuing and event replay
|
| 153 |
+
- **Memory Layer**: RedisStack HNSW for all memory operations with vector indexing
|
| 154 |
+
- **High Performance**: Optimized for enterprise AI workloads
|
| 155 |
|
| 156 |
### Basic Redis (Legacy)
|
| 157 |
- **Compatibility Mode**: Available via `ORKA_FORCE_BASIC_REDIS=true`
|
|
|
|
| 165 |
OrKa V0.7.0 is fully driven by `orka.yaml`, which defines:
|
| 166 |
- Agent IDs and types with RedisStack memory loggers
|
| 167 |
- Memory configuration with decay rules and HNSW settings
|
| 168 |
+
- Backend selection (redisstack/redis)
|
| 169 |
- Performance monitoring and observability settings
|
| 170 |
|
| 171 |
This allows reproducible reasoning pipelines with enterprise-grade memory.
|
|
|
|
| 210 |
## ✅ V0.7.0 Completed Features
|
| 211 |
|
| 212 |
- ✅ **RedisStack HNSW Integration** - 100x faster vector search across all components
|
| 213 |
+
- ✅ **RedisStack Backend** - Enterprise-grade memory operations with HNSW indexing
|
| 214 |
- ✅ **Professional CLI Dashboard** - Real-time HNSW performance monitoring
|
| 215 |
- ✅ **Zero-Breaking Migration** - Complete backward compatibility maintained
|
| 216 |
- ✅ **Unified Architecture** - All components use RedisStack with intelligent fallback
|
docs/best-practices.md
CHANGED
|
@@ -26,7 +26,7 @@ graph TD
|
|
| 26 |
C1 --> D[RedisStack Cluster]
|
| 27 |
C2 --> D
|
| 28 |
C3 --> D
|
| 29 |
-
C1 --> E[
|
| 30 |
C2 --> E
|
| 31 |
C3 --> E
|
| 32 |
D --> F[Monitoring]
|
|
@@ -44,7 +44,7 @@ graph TD
|
|
| 44 |
2. **Scalability**
|
| 45 |
- Horizontal scaling for API servers
|
| 46 |
- RedisStack cluster for memory
|
| 47 |
-
-
|
| 48 |
- Separate compute and storage
|
| 49 |
|
| 50 |
3. **Reliability**
|
|
|
|
| 26 |
C1 --> D[RedisStack Cluster]
|
| 27 |
C2 --> D
|
| 28 |
C3 --> D
|
| 29 |
+
C1 --> E[RedisStack Cluster]
|
| 30 |
C2 --> E
|
| 31 |
C3 --> E
|
| 32 |
D --> F[Monitoring]
|
|
|
|
| 44 |
2. **Scalability**
|
| 45 |
- Horizontal scaling for API servers
|
| 46 |
- RedisStack cluster for memory
|
| 47 |
+
- RedisStack for memory and vector search
|
| 48 |
- Separate compute and storage
|
| 49 |
|
| 50 |
3. **Reliability**
|
docs/faq.md
CHANGED
|
@@ -39,7 +39,7 @@ It logs the error. You can define `failover:` agents to take over. No silent fai
|
|
| 39 |
Yes. Via LiteLLM proxy, run with Ollama, LM Studio, Claude, OpenRouter. V0.7.0 includes enhanced local LLM support with better error handling.
|
| 40 |
|
| 41 |
### What about security?
|
| 42 |
-
Redis/
|
| 43 |
|
| 44 |
### Should I use sync or async agents?
|
| 45 |
Use the modern async pattern for new development. The legacy sync pattern is provided for backward compatibility with existing code. The async pattern offers better concurrency control, timeout handling, and resource management.
|
|
|
|
| 39 |
Yes. Via LiteLLM proxy, run with Ollama, LM Studio, Claude, OpenRouter. V0.7.0 includes enhanced local LLM support with better error handling.
|
| 40 |
|
| 41 |
### What about security?
|
| 42 |
+
Redis/RedisStack can be encrypted. PII filters recommended. OrKa UI supports authentication, and all memory operations can be configured with encryption at rest.
|
| 43 |
|
| 44 |
### Should I use sync or async agents?
|
| 45 |
Use the modern async pattern for new development. The legacy sync pattern is provided for backward compatibility with existing code. The async pattern offers better concurrency control, timeout handling, and resource management.
|
docs/getting-started.md
CHANGED
|
@@ -31,10 +31,10 @@ Welcome to OrKa! This guide will help you get up and running with OrKa's powerfu
|
|
| 31 |
|
| 32 |
```bash
|
| 33 |
# Install OrKa with all dependencies (includes automatic RedisStack setup)
|
| 34 |
-
pip install orka-reasoning fastapi uvicorn
|
| 35 |
|
| 36 |
-
# Optional: Install
|
| 37 |
-
pip install orka-reasoning[
|
| 38 |
```
|
| 39 |
|
| 40 |
**That's it!** OrKa V0.7.0 automatically handles RedisStack setup through Docker.
|
|
@@ -55,8 +55,8 @@ export OPENAI_API_KEY=your-openai-api-key-here
|
|
| 55 |
# For LOCAL development (automatically includes RedisStack + 100x faster vector search):
|
| 56 |
orka-start
|
| 57 |
|
| 58 |
-
# For PRODUCTION with
|
| 59 |
-
orka-
|
| 60 |
|
| 61 |
# Optional: Run OrKa UI for visual monitoring
|
| 62 |
docker pull marcosomma/orka-ui:latest
|
|
@@ -381,8 +381,8 @@ Check out our comprehensive guides:
|
|
| 381 |
|
| 382 |
### 3. Production Deployment
|
| 383 |
```bash
|
| 384 |
-
# Use
|
| 385 |
-
orka-
|
| 386 |
|
| 387 |
# Monitor with professional UI
|
| 388 |
docker run -it -p 80:80 marcosomma/orka-ui:latest
|
|
|
|
| 31 |
|
| 32 |
```bash
|
| 33 |
# Install OrKa with all dependencies (includes automatic RedisStack setup)
|
| 34 |
+
pip install orka-reasoning fastapi uvicorn
|
| 35 |
|
| 36 |
+
# Optional: Install extra features
|
| 37 |
+
pip install orka-reasoning[extra]
|
| 38 |
```
|
| 39 |
|
| 40 |
**That's it!** OrKa V0.7.0 automatically handles RedisStack setup through Docker.
|
|
|
|
| 55 |
# For LOCAL development (automatically includes RedisStack + 100x faster vector search):
|
| 56 |
orka-start
|
| 57 |
|
| 58 |
+
# For PRODUCTION with RedisStack:
|
| 59 |
+
orka-start
|
| 60 |
|
| 61 |
# Optional: Run OrKa UI for visual monitoring
|
| 62 |
docker pull marcosomma/orka-ui:latest
|
|
|
|
| 381 |
|
| 382 |
### 3. Production Deployment
|
| 383 |
```bash
|
| 384 |
+
# Use RedisStack for enterprise memory and vector search
|
| 385 |
+
orka-start
|
| 386 |
|
| 387 |
# Monitor with professional UI
|
| 388 |
docker run -it -p 80:80 marcosomma/orka-ui:latest
|
docs/index.md
CHANGED
|
@@ -50,10 +50,10 @@ Every decision is traceable and auditable:
|
|
| 50 |
### 1. Install OrKa with Dependencies
|
| 51 |
```bash
|
| 52 |
# Install OrKa with all required dependencies
|
| 53 |
-
pip install orka-reasoning fastapi uvicorn
|
| 54 |
|
| 55 |
-
# Optional: Install
|
| 56 |
-
pip install orka-reasoning[
|
| 57 |
```
|
| 58 |
|
| 59 |
### 2. Start OrKa (Automatic RedisStack Setup)
|
|
@@ -67,8 +67,8 @@ export OPENAI_API_KEY=your-key-here
|
|
| 67 |
# For LOCAL development:
|
| 68 |
python -m orka.orka_start
|
| 69 |
|
| 70 |
-
# For PRODUCTION with
|
| 71 |
-
python -m orka.
|
| 72 |
```
|
| 73 |
|
| 74 |
### 3. Create Your First Memory-Enabled Agent
|
|
|
|
| 50 |
### 1. Install OrKa with Dependencies
|
| 51 |
```bash
|
| 52 |
# Install OrKa with all required dependencies
|
| 53 |
+
pip install orka-reasoning fastapi uvicorn
|
| 54 |
|
| 55 |
+
# Optional: Install extra features
|
| 56 |
+
pip install orka-reasoning[extra]
|
| 57 |
```
|
| 58 |
|
| 59 |
### 2. Start OrKa (Automatic RedisStack Setup)
|
|
|
|
| 67 |
# For LOCAL development:
|
| 68 |
python -m orka.orka_start
|
| 69 |
|
| 70 |
+
# For PRODUCTION with RedisStack:
|
| 71 |
+
python -m orka.orka_start
|
| 72 |
```
|
| 73 |
|
| 74 |
### 3. Create Your First Memory-Enabled Agent
|
docs/quickstart.md
CHANGED
|
@@ -65,8 +65,8 @@ Choose your deployment mode:
|
|
| 65 |
# Development (RedisStack only)
|
| 66 |
orka-start
|
| 67 |
|
| 68 |
-
# Production (RedisStack
|
| 69 |
-
orka-
|
| 70 |
|
| 71 |
# Optional: Start UI
|
| 72 |
docker run -d -p 80:80 marcosomma/orka-ui:latest
|
|
|
|
| 65 |
# Development (RedisStack only)
|
| 66 |
orka-start
|
| 67 |
|
| 68 |
+
# Production (RedisStack)
|
| 69 |
+
orka-start
|
| 70 |
|
| 71 |
# Optional: Start UI
|
| 72 |
docker run -d -p 80:80 marcosomma/orka-ui:latest
|
docs/security.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
|
| 4 |
# OrKa Security & Privacy Considerations
|
| 5 |
|
| 6 |
-
## Redis/
|
| 7 |
- Use TLS for Redis if deployed publicly
|
| 8 |
- Enable ACLs (requirepass + role enforcement)
|
| 9 |
|
|
|
|
| 3 |
|
| 4 |
# OrKa Security & Privacy Considerations
|
| 5 |
|
| 6 |
+
## Redis/RedisStack
|
| 7 |
- Use TLS for Redis if deployed publicly
|
| 8 |
- Enable ACLs (requirepass + role enforcement)
|
| 9 |
|
docs/sphinx/index.rst
DELETED
|
@@ -1,55 +0,0 @@
|
|
| 1 |
-
.. OrKa documentation master file
|
| 2 |
-
|
| 3 |
-
Welcome to OrKa's Documentation!
|
| 4 |
-
=================================
|
| 5 |
-
|
| 6 |
-
OrKa is a powerful AI orchestration framework that enables the creation of complex, multi-agent AI workflows with sophisticated memory management, dynamic routing, and real-time collaboration capabilities.
|
| 7 |
-
|
| 8 |
-
.. toctree::
|
| 9 |
-
:maxdepth: 2
|
| 10 |
-
:caption: Contents:
|
| 11 |
-
|
| 12 |
-
modules
|
| 13 |
-
|
| 14 |
-
Features
|
| 15 |
-
========
|
| 16 |
-
|
| 17 |
-
* **Multi-Agent Architecture**: Support for various LLM providers including OpenAI, Local LLMs, and custom agents
|
| 18 |
-
* **Advanced Memory System**: RedisStack-based vector search with HNSW indexing for 100x faster retrieval
|
| 19 |
-
* **Dynamic Workflow Control**: Fork/Join patterns, loops, conditional routing, and failover mechanisms
|
| 20 |
-
* **Real-time Collaboration**: Agent societies with memory sharing and dynamic interaction
|
| 21 |
-
* **Observability**: Comprehensive logging, metrics, and TUI interface for monitoring
|
| 22 |
-
* **Production Ready**: Docker support, scalable backends (Kafka + Redis), and robust error handling
|
| 23 |
-
|
| 24 |
-
Quick Start
|
| 25 |
-
===========
|
| 26 |
-
|
| 27 |
-
1. **Installation**::
|
| 28 |
-
|
| 29 |
-
pip install orka-reasoning
|
| 30 |
-
|
| 31 |
-
2. **Start the backend**::
|
| 32 |
-
|
| 33 |
-
python -m orka.orka_start
|
| 34 |
-
|
| 35 |
-
3. **Run a workflow**::
|
| 36 |
-
|
| 37 |
-
python -m orka.orka_cli run your_workflow.yml
|
| 38 |
-
|
| 39 |
-
Architecture Overview
|
| 40 |
-
====================
|
| 41 |
-
|
| 42 |
-
OrKa consists of several key components:
|
| 43 |
-
|
| 44 |
-
* **Agents**: Intelligent processing units (LLM agents, local agents, validation agents)
|
| 45 |
-
* **Nodes**: Workflow building blocks (memory, routing, control flow)
|
| 46 |
-
* **Orchestrator**: Execution engine with advanced scheduling and error handling
|
| 47 |
-
* **Memory System**: Persistent storage with vector search capabilities
|
| 48 |
-
* **CLI & TUI**: Command-line and terminal interfaces for management
|
| 49 |
-
|
| 50 |
-
Indices and tables
|
| 51 |
-
==================
|
| 52 |
-
|
| 53 |
-
* :ref:`genindex`
|
| 54 |
-
* :ref:`modindex`
|
| 55 |
-
* :ref:`search`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docs/troubleshooting.md
CHANGED
|
@@ -46,7 +46,7 @@ pip install --upgrade pip
|
|
| 46 |
|
| 47 |
4. Install with explicit dependencies:
|
| 48 |
```bash
|
| 49 |
-
pip install orka-reasoning fastapi uvicorn
|
| 50 |
```
|
| 51 |
|
| 52 |
### Import errors after installation
|
|
@@ -340,34 +340,36 @@ orchestrator:
|
|
| 340 |
|
| 341 |
## Production Deployment
|
| 342 |
|
| 343 |
-
###
|
| 344 |
|
| 345 |
**Symptoms:**
|
| 346 |
-
-
|
| 347 |
-
-
|
| 348 |
-
-
|
| 349 |
|
| 350 |
**Solutions:**
|
| 351 |
|
| 352 |
-
1. Check
|
| 353 |
```bash
|
| 354 |
-
|
|
|
|
| 355 |
```
|
| 356 |
|
| 357 |
-
2. Monitor
|
| 358 |
```bash
|
| 359 |
-
|
| 360 |
-
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe
|
| 361 |
```
|
| 362 |
|
| 363 |
3. Optimize settings:
|
| 364 |
```yaml
|
| 365 |
-
#
|
| 366 |
memory_config:
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
|
|
|
|
|
|
| 371 |
```
|
| 372 |
|
| 373 |
### Monitoring and Alerts
|
|
|
|
| 46 |
|
| 47 |
4. Install with explicit dependencies:
|
| 48 |
```bash
|
| 49 |
+
pip install orka-reasoning fastapi uvicorn
|
| 50 |
```
|
| 51 |
|
| 52 |
### Import errors after installation
|
|
|
|
| 340 |
|
| 341 |
## Production Deployment
|
| 342 |
|
| 343 |
+
### RedisStack Integration
|
| 344 |
|
| 345 |
**Symptoms:**
|
| 346 |
+
- Vector search not working
|
| 347 |
+
- Index creation failures
|
| 348 |
+
- Connection timeouts
|
| 349 |
|
| 350 |
**Solutions:**
|
| 351 |
|
| 352 |
+
1. Check RedisStack status:
|
| 353 |
```bash
|
| 354 |
+
redis-cli ping
|
| 355 |
+
redis-cli FT._LIST
|
| 356 |
```
|
| 357 |
|
| 358 |
+
2. Monitor performance:
|
| 359 |
```bash
|
| 360 |
+
orka memory watch
|
|
|
|
| 361 |
```
|
| 362 |
|
| 363 |
3. Optimize settings:
|
| 364 |
```yaml
|
| 365 |
+
# redis-config.yml
|
| 366 |
memory_config:
|
| 367 |
+
redis:
|
| 368 |
+
max_connections: 100
|
| 369 |
+
connection_timeout: 5
|
| 370 |
+
vector_index_params:
|
| 371 |
+
m: 16
|
| 372 |
+
ef_construction: 200
|
| 373 |
```
|
| 374 |
|
| 375 |
### Monitoring and Alerts
|
docs/tutorials/getting-started-with-orka.md
CHANGED
|
@@ -30,8 +30,8 @@ OrKa V0.7.0+ includes automatic RedisStack setup for 100x faster vector search:
|
|
| 30 |
# Start OrKa with RedisStack (for development)
|
| 31 |
orka-start
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
orka-
|
| 35 |
```
|
| 36 |
|
| 37 |
## Step 3: Create Your First Workflow
|
|
|
|
| 30 |
# Start OrKa with RedisStack (for development)
|
| 31 |
orka-start
|
| 32 |
|
| 33 |
+
# For production (same command):
|
| 34 |
+
orka-start
|
| 35 |
```
|
| 36 |
|
| 37 |
## Step 3: Create Your First Workflow
|
docs/yaml-configuration-guide.md
CHANGED
|
@@ -49,7 +49,7 @@ orchestrator:
|
|
| 49 |
memory_config:
|
| 50 |
# Memory backend configuration (RedisStack is now default)
|
| 51 |
# backend: redisstack # Default in V0.7.0 - automatic HNSW indexing
|
| 52 |
-
# backend:
|
| 53 |
# backend: redis # Legacy mode (not recommended)
|
| 54 |
|
| 55 |
# Decay configuration - inspired by human memory
|
|
@@ -1251,8 +1251,8 @@ This comprehensive guide covers all the major agent types, configuration pattern
|
|
| 1251 |
# Start OrKa with RedisStack (development)
|
| 1252 |
orka-start
|
| 1253 |
|
| 1254 |
-
# Start OrKa with
|
| 1255 |
-
orka-
|
| 1256 |
|
| 1257 |
# Run your workflow
|
| 1258 |
orka run ./my-workflow.yml "Your input here"
|
|
|
|
| 49 |
memory_config:
|
| 50 |
# Memory backend configuration (RedisStack is now default)
|
| 51 |
# backend: redisstack # Default in V0.7.0 - automatic HNSW indexing
|
| 52 |
+
# backend: redisstack # Recommended for production
|
| 53 |
# backend: redis # Legacy mode (not recommended)
|
| 54 |
|
| 55 |
# Decay configuration - inspired by human memory
|
|
|
|
| 1251 |
# Start OrKa with RedisStack (development)
|
| 1252 |
orka-start
|
| 1253 |
|
| 1254 |
+
# Start OrKa with RedisStack (production)
|
| 1255 |
+
orka-start
|
| 1256 |
|
| 1257 |
# Run your workflow
|
| 1258 |
orka run ./my-workflow.yml "Your input here"
|
examples/orka_framework_qa.yml
CHANGED
|
@@ -4,12 +4,8 @@ orchestrator:
|
|
| 4 |
queue: orka:qa
|
| 5 |
memory:
|
| 6 |
enabled: true
|
| 7 |
-
backend:
|
| 8 |
config:
|
| 9 |
-
bootstrap_servers: localhost:9092
|
| 10 |
-
schema_registry_url: http://localhost:8081
|
| 11 |
-
use_schema_registry: true
|
| 12 |
-
topic_prefix: orka-reasoning-memory
|
| 13 |
redis_url: redis://localhost:6380/0
|
| 14 |
agents:
|
| 15 |
- qa_agent
|
|
|
|
| 4 |
queue: orka:qa
|
| 5 |
memory:
|
| 6 |
enabled: true
|
| 7 |
+
backend: redisstack
|
| 8 |
config:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
redis_url: redis://localhost:6380/0
|
| 10 |
agents:
|
| 11 |
- qa_agent
|
examples/routed_binary_memory_writer.yml
CHANGED
|
@@ -4,13 +4,9 @@ orchestrator:
|
|
| 4 |
queue: orka:test-routing-memory
|
| 5 |
memory:
|
| 6 |
enabled: true
|
| 7 |
-
backend:
|
| 8 |
config:
|
| 9 |
-
|
| 10 |
-
schema_registry_url: http://localhost:8081
|
| 11 |
-
use_schema_registry: true
|
| 12 |
-
topic_prefix: orka-memory
|
| 13 |
-
redis_url: redis://localhost:6380/0 # Redis is still needed for memory operations
|
| 14 |
# Vector search configuration
|
| 15 |
vector_search:
|
| 16 |
enabled: true
|
|
|
|
| 4 |
queue: orka:test-routing-memory
|
| 5 |
memory:
|
| 6 |
enabled: true
|
| 7 |
+
backend: redisstack
|
| 8 |
config:
|
| 9 |
+
redis_url: redis://localhost:6380/0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Vector search configuration
|
| 11 |
vector_search:
|
| 12 |
enabled: true
|
mypy.ini
CHANGED
|
@@ -22,9 +22,6 @@ init_typed = True
|
|
| 22 |
warn_required_dynamic_aliases = True
|
| 23 |
warn_untyped_fields = True
|
| 24 |
|
| 25 |
-
[mypy-confluent_kafka.*]
|
| 26 |
-
ignore_missing_imports = True
|
| 27 |
-
|
| 28 |
[mypy-redis.*]
|
| 29 |
ignore_missing_imports = False
|
| 30 |
|
|
|
|
| 22 |
warn_required_dynamic_aliases = True
|
| 23 |
warn_untyped_fields = True
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
[mypy-redis.*]
|
| 26 |
ignore_missing_imports = False
|
| 27 |
|
orka/__init__.py
CHANGED
|
@@ -61,7 +61,6 @@ Core Components
|
|
| 61 |
|
| 62 |
* :class:`~orka.memory.redisstack_logger.RedisStackMemoryLogger` - HNSW vector indexing
|
| 63 |
* :class:`~orka.memory.redis_logger.RedisMemoryLogger` - Redis-based storage
|
| 64 |
-
* :class:`~orka.memory.kafka_logger.KafkaMemoryLogger` - Event streaming
|
| 65 |
* **Modular Components**: Serialization, compression, file operations
|
| 66 |
|
| 67 |
**Command Line Interface**
|
|
@@ -126,8 +125,8 @@ Usage Patterns
|
|
| 126 |
# Standard Redis backend
|
| 127 |
memory = create_memory_logger("redis")
|
| 128 |
|
| 129 |
-
#
|
| 130 |
-
memory = create_memory_logger("
|
| 131 |
|
| 132 |
**Custom Agent Development**
|
| 133 |
|
|
|
|
| 61 |
|
| 62 |
* :class:`~orka.memory.redisstack_logger.RedisStackMemoryLogger` - HNSW vector indexing
|
| 63 |
* :class:`~orka.memory.redis_logger.RedisMemoryLogger` - Redis-based storage
|
|
|
|
| 64 |
* **Modular Components**: Serialization, compression, file operations
|
| 65 |
|
| 66 |
**Command Line Interface**
|
|
|
|
| 125 |
# Standard Redis backend
|
| 126 |
memory = create_memory_logger("redis")
|
| 127 |
|
| 128 |
+
# RedisStack backend for high-performance vector search
|
| 129 |
+
memory = create_memory_logger("redisstack")
|
| 130 |
|
| 131 |
**Custom Agent Development**
|
| 132 |
|
orka/cli/memory/commands.py
CHANGED
|
@@ -246,20 +246,6 @@ def memory_configure(args: Any) -> int:
|
|
| 246 |
except Exception as e:
|
| 247 |
logger.error(f"❌ Decay Cleanup: Error - {e}")
|
| 248 |
|
| 249 |
-
elif backend == "kafka":
|
| 250 |
-
logger.info("\n📡 Kafka-Specific Tests:")
|
| 251 |
-
|
| 252 |
-
# Test hybrid backend
|
| 253 |
-
try:
|
| 254 |
-
if hasattr(memory, "redis_url"):
|
| 255 |
-
logger.info("✅ Hybrid Backend: Kafka + Redis")
|
| 256 |
-
logger.info(f" Kafka topic: {getattr(memory, 'main_topic', 'N/A')}")
|
| 257 |
-
logger.info(f" Redis URL: {memory.redis_url}")
|
| 258 |
-
else:
|
| 259 |
-
logger.info("⚠️ Hybrid Backend: Configuration unclear")
|
| 260 |
-
except Exception as e:
|
| 261 |
-
logger.error(f"❌ Hybrid Backend: Error - {e}")
|
| 262 |
-
|
| 263 |
# Test memory stats retrieval
|
| 264 |
try:
|
| 265 |
stats = memory.get_memory_stats()
|
|
|
|
| 246 |
except Exception as e:
|
| 247 |
logger.error(f"❌ Decay Cleanup: Error - {e}")
|
| 248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
# Test memory stats retrieval
|
| 250 |
try:
|
| 251 |
stats = memory.get_memory_stats()
|
orka/cli/parser.py
CHANGED
|
@@ -60,7 +60,7 @@ def setup_subcommands(parser):
|
|
| 60 |
stats_parser = memory_subparsers.add_parser("stats", help="Display memory statistics")
|
| 61 |
stats_parser.add_argument(
|
| 62 |
"--backend",
|
| 63 |
-
choices=["redis", "redisstack"
|
| 64 |
help="Memory backend to use",
|
| 65 |
)
|
| 66 |
stats_parser.set_defaults(func=memory_stats)
|
|
@@ -69,7 +69,7 @@ def setup_subcommands(parser):
|
|
| 69 |
cleanup_parser = memory_subparsers.add_parser("cleanup", help="Clean up expired memory entries")
|
| 70 |
cleanup_parser.add_argument(
|
| 71 |
"--backend",
|
| 72 |
-
choices=["redis", "redisstack"
|
| 73 |
help="Memory backend to use",
|
| 74 |
)
|
| 75 |
cleanup_parser.add_argument(
|
|
@@ -83,7 +83,7 @@ def setup_subcommands(parser):
|
|
| 83 |
config_parser = memory_subparsers.add_parser("configure", help="Display memory configuration")
|
| 84 |
config_parser.add_argument(
|
| 85 |
"--backend",
|
| 86 |
-
choices=["redis", "redisstack"
|
| 87 |
help="Memory backend to use",
|
| 88 |
)
|
| 89 |
config_parser.set_defaults(func=memory_configure)
|
|
@@ -95,7 +95,7 @@ def setup_subcommands(parser):
|
|
| 95 |
)
|
| 96 |
watch_parser.add_argument(
|
| 97 |
"--backend",
|
| 98 |
-
choices=["redis", "redisstack"
|
| 99 |
help="Memory backend to use",
|
| 100 |
)
|
| 101 |
watch_parser.add_argument(
|
|
|
|
| 60 |
stats_parser = memory_subparsers.add_parser("stats", help="Display memory statistics")
|
| 61 |
stats_parser.add_argument(
|
| 62 |
"--backend",
|
| 63 |
+
choices=["redis", "redisstack"],
|
| 64 |
help="Memory backend to use",
|
| 65 |
)
|
| 66 |
stats_parser.set_defaults(func=memory_stats)
|
|
|
|
| 69 |
cleanup_parser = memory_subparsers.add_parser("cleanup", help="Clean up expired memory entries")
|
| 70 |
cleanup_parser.add_argument(
|
| 71 |
"--backend",
|
| 72 |
+
choices=["redis", "redisstack"],
|
| 73 |
help="Memory backend to use",
|
| 74 |
)
|
| 75 |
cleanup_parser.add_argument(
|
|
|
|
| 83 |
config_parser = memory_subparsers.add_parser("configure", help="Display memory configuration")
|
| 84 |
config_parser.add_argument(
|
| 85 |
"--backend",
|
| 86 |
+
choices=["redis", "redisstack"],
|
| 87 |
help="Memory backend to use",
|
| 88 |
)
|
| 89 |
config_parser.set_defaults(func=memory_configure)
|
|
|
|
| 95 |
)
|
| 96 |
watch_parser.add_argument(
|
| 97 |
"--backend",
|
| 98 |
+
choices=["redis", "redisstack"],
|
| 99 |
help="Memory backend to use",
|
| 100 |
)
|
| 101 |
watch_parser.add_argument(
|
orka/docker/README.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
| 1 |
# OrKa V0.7.0 Docker Setup - 100x Faster Vector Search
|
| 2 |
|
| 3 |
-
This directory contains Docker configurations and scripts for running OrKa V0.7.0 with **RedisStack HNSW indexing**
|
| 4 |
|
| 5 |
## 🚀 V0.7.0 Performance Revolution
|
| 6 |
|
| 7 |
-
|
| 8 |
-
- **⚡ 50x Higher Throughput** - 50,000+ memory operations per second
|
| 9 |
-
- **🏗️ Unified Architecture** - All backends now use RedisStack for memory
|
| 10 |
-
- **🔧 Automatic Setup** - Zero manual configuration required
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
##
|
|
|
|
|
|
|
| 15 |
```bash
|
| 16 |
# Linux/macOS
|
| 17 |
./start-redis.sh
|
|
@@ -23,270 +25,184 @@ start-redis.bat
|
|
| 23 |
docker-compose --profile redis up --build -d
|
| 24 |
```
|
| 25 |
|
| 26 |
-
##
|
| 27 |
-
```bash
|
| 28 |
-
# Linux/macOS
|
| 29 |
-
./start-kafka.sh
|
| 30 |
-
|
| 31 |
-
# Windows
|
| 32 |
-
start-kafka.bat
|
| 33 |
-
|
| 34 |
-
# Or manually:
|
| 35 |
-
docker-compose --profile kafka up --build -d
|
| 36 |
-
```
|
| 37 |
-
|
| 38 |
-
### Dual Backend (Development & Testing)
|
| 39 |
-
```bash
|
| 40 |
-
# Linux/macOS
|
| 41 |
-
./start-dual.sh
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
##
|
| 48 |
|
| 49 |
-
###
|
| 50 |
-
- **orka-start-redis**:
|
| 51 |
-
- **redis**: RedisStack server with
|
| 52 |
|
| 53 |
**Endpoints:**
|
| 54 |
-
-
|
| 55 |
-
- RedisStack: `localhost:6380`
|
| 56 |
|
| 57 |
**Performance:**
|
| 58 |
-
-
|
| 59 |
-
- Memory
|
| 60 |
-
- Concurrent: 1,000+ simultaneous searches
|
| 61 |
-
|
| 62 |
-
### Kafka Profile (`--profile kafka`)
|
| 63 |
-
- **orka-start-kafka**: Orka API server with Kafka backend
|
| 64 |
-
- **kafka**: Kafka broker
|
| 65 |
-
- **zookeeper**: Zookeeper for Kafka coordination
|
| 66 |
-
|
| 67 |
-
**Endpoints:**
|
| 68 |
-
- Orka API: `http://localhost:8001`
|
| 69 |
-
- Kafka: `localhost:9092`
|
| 70 |
-
- Zookeeper: `localhost:2181`
|
| 71 |
-
|
| 72 |
-
### Dual Profile (`--profile dual`)
|
| 73 |
-
- **orka-dual-backend**: Orka API server with configurable backend
|
| 74 |
-
- **redis**: Redis server
|
| 75 |
-
- **kafka**: Kafka broker
|
| 76 |
-
- **zookeeper**: Zookeeper
|
| 77 |
-
|
| 78 |
-
**Endpoints:**
|
| 79 |
-
- Orka API: `http://localhost:8002`
|
| 80 |
-
- Redis: `localhost:6380`
|
| 81 |
-
- Kafka: `localhost:9092`
|
| 82 |
|
| 83 |
## 🛠️ Management Commands
|
| 84 |
|
| 85 |
### Starting Services
|
| 86 |
```bash
|
| 87 |
-
#
|
| 88 |
docker-compose --profile redis up -d
|
| 89 |
-
|
| 90 |
-
# Kafka only
|
| 91 |
-
docker-compose --profile kafka up -d
|
| 92 |
-
|
| 93 |
-
# Both (dual backend)
|
| 94 |
-
docker-compose --profile dual up -d
|
| 95 |
```
|
| 96 |
|
| 97 |
### Stopping Services
|
| 98 |
```bash
|
| 99 |
# Stop specific profile
|
| 100 |
docker-compose --profile redis down
|
| 101 |
-
docker-compose --profile kafka down
|
| 102 |
-
docker-compose --profile dual down
|
| 103 |
|
| 104 |
-
#
|
| 105 |
./cleanup.sh
|
| 106 |
-
|
| 107 |
-
# Stop all and remove volumes
|
| 108 |
-
./cleanup.sh --volumes
|
| 109 |
```
|
| 110 |
|
| 111 |
### Viewing Logs
|
| 112 |
```bash
|
| 113 |
# All services in a profile
|
| 114 |
docker-compose --profile redis logs -f
|
| 115 |
-
docker-compose --profile kafka logs -f
|
| 116 |
|
| 117 |
# Specific service
|
| 118 |
docker-compose logs -f orka-start-redis
|
| 119 |
-
docker-compose logs -f
|
| 120 |
```
|
| 121 |
|
| 122 |
-
###
|
| 123 |
```bash
|
| 124 |
-
# Check
|
| 125 |
docker-compose exec redis redis-cli ping
|
| 126 |
docker-compose exec redis redis-cli info
|
| 127 |
-
|
| 128 |
-
# Check Kafka
|
| 129 |
-
docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --list
|
| 130 |
-
docker-compose exec kafka kafka-console-consumer --bootstrap-server localhost:29092 --topic orka-memory-events --from-beginning
|
| 131 |
```
|
| 132 |
|
| 133 |
-
##
|
| 134 |
|
| 135 |
-
### RedisStack Backend (
|
| 136 |
```bash
|
| 137 |
-
ORKA_MEMORY_BACKEND=redisstack
|
| 138 |
REDIS_URL=redis://redis:6380/0
|
| 139 |
-
# Automatic HNSW indexing with optimized parameters:
|
| 140 |
-
# - M=16 (connectivity)
|
| 141 |
-
# - ef_construction=200 (build accuracy)
|
| 142 |
```
|
| 143 |
|
| 144 |
-
###
|
| 145 |
```bash
|
| 146 |
-
ORKA_MEMORY_BACKEND=
|
| 147 |
-
KAFKA_BOOTSTRAP_SERVERS=kafka:29092
|
| 148 |
-
KAFKA_TOPIC_PREFIX=orka-memory
|
| 149 |
-
KAFKA_SCHEMA_REGISTRY_URL=http://schema-registry:8081
|
| 150 |
-
REDIS_URL=redis://redis:6380/0 # RedisStack for memory operations
|
| 151 |
-
```
|
| 152 |
-
|
| 153 |
-
### Legacy Redis Backend (Basic - Not Recommended)
|
| 154 |
-
```bash
|
| 155 |
-
ORKA_FORCE_BASIC_REDIS=true # Force basic Redis mode
|
| 156 |
-
ORKA_MEMORY_BACKEND=redis # Legacy mode
|
| 157 |
REDIS_URL=redis://redis:6380/0
|
| 158 |
```
|
| 159 |
|
| 160 |
-
##
|
|
|
|
| 161 |
You can override the memory backend at runtime:
|
| 162 |
```bash
|
| 163 |
-
#
|
| 164 |
-
docker-compose exec orka-
|
| 165 |
```
|
| 166 |
|
| 167 |
## 📁 File Structure
|
| 168 |
|
| 169 |
```
|
| 170 |
orka/docker/
|
| 171 |
-
├── docker-compose.yml
|
| 172 |
-
├── Dockerfile # Orka application container
|
| 173 |
├── start-redis.sh # Redis backend startup script (Linux/macOS)
|
| 174 |
├── start-redis.bat # Redis backend startup script (Windows)
|
| 175 |
-
├── start-kafka.sh # Kafka backend startup script (Linux/macOS)
|
| 176 |
-
├── start-kafka.bat # Kafka backend startup script (Windows)
|
| 177 |
-
├── start-dual.sh # Dual backend startup script (Linux/macOS)
|
| 178 |
├── cleanup.sh # Service cleanup script (Linux/macOS)
|
| 179 |
-
|
|
|
|
| 180 |
```
|
| 181 |
|
| 182 |
-
##
|
| 183 |
-
|
| 184 |
-
This setup uses Docker Compose profiles to manage different backend configurations:
|
| 185 |
-
|
| 186 |
-
- **redis**: Minimal setup with Redis only
|
| 187 |
-
- **kafka**: Full event streaming with Kafka + Zookeeper
|
| 188 |
-
- **dual**: Both backends for testing and comparison
|
| 189 |
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
### From Redis to Kafka
|
| 193 |
-
1. Export Redis data: `docker-compose exec redis redis-cli --rdb > backup.rdb`
|
| 194 |
-
2. Stop Redis services: `docker-compose --profile redis down`
|
| 195 |
-
3. Start Kafka services: `./start-kafka.sh`
|
| 196 |
-
4. Configure application to use Kafka backend
|
| 197 |
-
|
| 198 |
-
### From Kafka to Redis
|
| 199 |
-
1. Stop Kafka services: `docker-compose --profile kafka down`
|
| 200 |
-
2. Start Redis services: `./start-redis.sh`
|
| 201 |
-
3. Configure application to use Redis backend
|
| 202 |
-
4. Kafka topics remain for historical reference
|
| 203 |
|
| 204 |
## 🚨 Troubleshooting
|
| 205 |
|
| 206 |
### Common Issues
|
| 207 |
|
| 208 |
-
**Kafka takes too long to start:**
|
| 209 |
-
- Increase wait times in startup scripts
|
| 210 |
-
- Check if Zookeeper is running: `docker-compose ps zookeeper`
|
| 211 |
-
- View Kafka logs: `docker-compose logs kafka`
|
| 212 |
-
|
| 213 |
**Redis connection refused:**
|
| 214 |
-
- Check Redis
|
| 215 |
-
- Verify
|
| 216 |
-
-
|
| 217 |
|
| 218 |
**Port conflicts:**
|
| 219 |
-
-
|
| 220 |
-
-
|
| 221 |
-
- Orka APIs: Ports 8000, 8001, 8002
|
| 222 |
|
| 223 |
**Memory issues:**
|
| 224 |
-
-
|
| 225 |
-
-
|
|
|
|
| 226 |
|
| 227 |
-
|
| 228 |
-
``
|
| 229 |
-
|
| 230 |
-
|
| 231 |
|
| 232 |
-
#
|
| 233 |
-
docker-compose down --rmi all --volumes --remove-orphans
|
| 234 |
|
| 235 |
-
#
|
| 236 |
-
docker system prune -a --volumes
|
| 237 |
-
```
|
| 238 |
-
|
| 239 |
-
## 📊 Monitoring
|
| 240 |
-
|
| 241 |
-
### Redis Monitoring
|
| 242 |
```bash
|
| 243 |
-
# Redis
|
| 244 |
-
docker-compose exec redis redis-cli
|
| 245 |
-
|
| 246 |
-
# Monitor commands
|
| 247 |
-
docker-compose exec redis redis-cli monitor
|
| 248 |
|
| 249 |
-
#
|
| 250 |
docker-compose exec redis redis-cli info memory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
```
|
| 252 |
|
| 253 |
-
###
|
| 254 |
```bash
|
| 255 |
-
#
|
| 256 |
-
docker-compose
|
| 257 |
|
| 258 |
-
#
|
| 259 |
-
docker
|
| 260 |
|
| 261 |
-
#
|
| 262 |
-
docker-compose
|
| 263 |
```
|
| 264 |
|
| 265 |
-
##
|
| 266 |
-
|
| 267 |
-
### For Redis
|
| 268 |
-
- Use Redis Cluster for high availability
|
| 269 |
-
- Configure Redis persistence (RDB + AOF)
|
| 270 |
-
- Set up Redis monitoring and alerting
|
| 271 |
-
- Consider Redis memory optimization
|
| 272 |
|
| 273 |
-
### For
|
| 274 |
-
-
|
| 275 |
-
-
|
| 276 |
-
-
|
| 277 |
-
-
|
| 278 |
-
- Consider using Kafka Connect for integration
|
| 279 |
|
| 280 |
### Security
|
| 281 |
-
- Enable authentication for
|
| 282 |
- Use TLS encryption for production
|
| 283 |
- Configure network security groups
|
| 284 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
|
| 286 |
-
##
|
| 287 |
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
4. Test both backends thoroughly
|
|
|
|
| 1 |
# OrKa V0.7.0 Docker Setup - 100x Faster Vector Search
|
| 2 |
|
| 3 |
+
This directory contains Docker configurations and scripts for running OrKa V0.7.0 with **RedisStack HNSW indexing** for ultra-fast vector search.
|
| 4 |
|
| 5 |
## 🚀 V0.7.0 Performance Revolution
|
| 6 |
|
| 7 |
+
OrKa V0.7.0 introduces **RedisStack with HNSW (Hierarchical Navigable Small World) vector indexing**, delivering:
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
- **100x faster vector search** compared to basic Redis
|
| 10 |
+
- **Sub-millisecond semantic search** for agent memory retrieval
|
| 11 |
+
- **Advanced memory decay** with intelligent cleanup
|
| 12 |
+
- **Enterprise-grade reliability** with persistent storage
|
| 13 |
|
| 14 |
+
## 🏃♂️ Quick Start
|
| 15 |
+
|
| 16 |
+
### RedisStack Backend (Recommended)
|
| 17 |
```bash
|
| 18 |
# Linux/macOS
|
| 19 |
./start-redis.sh
|
|
|
|
| 25 |
docker-compose --profile redis up --build -d
|
| 26 |
```
|
| 27 |
|
| 28 |
+
## 📊 Performance Benchmarks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
### RedisStack HNSW Performance
|
| 31 |
+
- **Search Speed**: <1ms for 100K+ vectors
|
| 32 |
+
- **Throughput**: 50,000+ operations/second
|
| 33 |
+
- **Memory Efficiency**: 90% less memory than traditional approaches
|
| 34 |
+
- **Concurrent**: 1,000+ simultaneous searches
|
| 35 |
|
| 36 |
+
## 🐳 Docker Profiles
|
| 37 |
|
| 38 |
+
### Redis Profile (`--profile redis`)
|
| 39 |
+
- **orka-start-redis**: Orka API server with RedisStack backend
|
| 40 |
+
- **redis**: RedisStack server with HNSW indexing
|
| 41 |
|
| 42 |
**Endpoints:**
|
| 43 |
+
- Orka API: `http://localhost:8000`
|
| 44 |
+
- RedisStack: `localhost:6380`
|
| 45 |
|
| 46 |
**Performance:**
|
| 47 |
+
- **Search Speed**: <1ms average
|
| 48 |
+
- **Memory Usage**: Optimized with decay management
|
| 49 |
+
- **Concurrent**: 1,000+ simultaneous searches
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
## 🛠️ Management Commands
|
| 52 |
|
| 53 |
### Starting Services
|
| 54 |
```bash
|
| 55 |
+
# RedisStack (recommended)
|
| 56 |
docker-compose --profile redis up -d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
```
|
| 58 |
|
| 59 |
### Stopping Services
|
| 60 |
```bash
|
| 61 |
# Stop specific profile
|
| 62 |
docker-compose --profile redis down
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
# Emergency cleanup
|
| 65 |
./cleanup.sh
|
|
|
|
|
|
|
|
|
|
| 66 |
```
|
| 67 |
|
| 68 |
### Viewing Logs
|
| 69 |
```bash
|
| 70 |
# All services in a profile
|
| 71 |
docker-compose --profile redis logs -f
|
|
|
|
| 72 |
|
| 73 |
# Specific service
|
| 74 |
docker-compose logs -f orka-start-redis
|
| 75 |
+
docker-compose logs -f redis
|
| 76 |
```
|
| 77 |
|
| 78 |
+
### Health Checks
|
| 79 |
```bash
|
| 80 |
+
# Check RedisStack
|
| 81 |
docker-compose exec redis redis-cli ping
|
| 82 |
docker-compose exec redis redis-cli info
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
```
|
| 84 |
|
| 85 |
+
## ⚙️ Configuration
|
| 86 |
|
| 87 |
+
### RedisStack Backend (Recommended)
|
| 88 |
```bash
|
| 89 |
+
ORKA_MEMORY_BACKEND=redisstack
|
| 90 |
REDIS_URL=redis://redis:6380/0
|
|
|
|
|
|
|
|
|
|
| 91 |
```
|
| 92 |
|
| 93 |
+
### Basic Redis Backend
|
| 94 |
```bash
|
| 95 |
+
ORKA_MEMORY_BACKEND=redis
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
REDIS_URL=redis://redis:6380/0
|
| 97 |
```
|
| 98 |
|
| 99 |
+
## 🔄 Runtime Backend Switching
|
| 100 |
+
|
| 101 |
You can override the memory backend at runtime:
|
| 102 |
```bash
|
| 103 |
+
# Force RedisStack backend
|
| 104 |
+
docker-compose exec orka-start-redis env ORKA_MEMORY_BACKEND=redisstack python -m orka.server
|
| 105 |
```
|
| 106 |
|
| 107 |
## 📁 File Structure
|
| 108 |
|
| 109 |
```
|
| 110 |
orka/docker/
|
| 111 |
+
├── docker-compose.yml # Main Docker Compose configuration
|
|
|
|
| 112 |
├── start-redis.sh # Redis backend startup script (Linux/macOS)
|
| 113 |
├── start-redis.bat # Redis backend startup script (Windows)
|
|
|
|
|
|
|
|
|
|
| 114 |
├── cleanup.sh # Service cleanup script (Linux/macOS)
|
| 115 |
+
├── cleanup-and-start.sh # Combined cleanup and start script
|
| 116 |
+
└── README.md # This file
|
| 117 |
```
|
| 118 |
|
| 119 |
+
## 🎯 Profiles
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
+
- **redis**: RedisStack setup with HNSW vector indexing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
## 🚨 Troubleshooting
|
| 124 |
|
| 125 |
### Common Issues
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
**Redis connection refused:**
|
| 128 |
+
- Check if Redis container is running: `docker-compose ps redis`
|
| 129 |
+
- Verify port 6380 is available: `netstat -an | grep 6380`
|
| 130 |
+
- View Redis logs: `docker-compose logs redis`
|
| 131 |
|
| 132 |
**Port conflicts:**
|
| 133 |
+
- RedisStack: Check if port 6380 is available
|
| 134 |
+
- Orka API: Port 8000
|
|
|
|
| 135 |
|
| 136 |
**Memory issues:**
|
| 137 |
+
- Check available memory: `docker stats`
|
| 138 |
+
- Adjust Redis memory limits in docker-compose.yml
|
| 139 |
+
- Monitor memory usage: `docker-compose exec redis redis-cli info memory`
|
| 140 |
|
| 141 |
+
**Vector search not working:**
|
| 142 |
+
- Verify RedisStack modules are loaded: `docker-compose exec redis redis-cli MODULE LIST`
|
| 143 |
+
- Check for RediSearch module: Should show `search` module
|
| 144 |
+
- Restart services if modules are missing
|
| 145 |
|
| 146 |
+
## 📈 Monitoring
|
|
|
|
| 147 |
|
| 148 |
+
### RedisStack Monitoring
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
```bash
|
| 150 |
+
# Check Redis info
|
| 151 |
+
docker-compose exec redis redis-cli info
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
+
# Monitor memory usage
|
| 154 |
docker-compose exec redis redis-cli info memory
|
| 155 |
+
|
| 156 |
+
# Check loaded modules
|
| 157 |
+
docker-compose exec redis redis-cli MODULE LIST
|
| 158 |
+
|
| 159 |
+
# Monitor performance
|
| 160 |
+
docker-compose exec redis redis-cli --latency-history -i 1
|
| 161 |
```
|
| 162 |
|
| 163 |
+
### Container Health
|
| 164 |
```bash
|
| 165 |
+
# Check all containers
|
| 166 |
+
docker-compose ps
|
| 167 |
|
| 168 |
+
# Resource usage
|
| 169 |
+
docker stats
|
| 170 |
|
| 171 |
+
# Container logs
|
| 172 |
+
docker-compose logs --tail=100 -f
|
| 173 |
```
|
| 174 |
|
| 175 |
+
## 🔧 Advanced Configuration
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
+
### For RedisStack
|
| 178 |
+
- Configure HNSW parameters for optimal performance
|
| 179 |
+
- Set appropriate memory limits
|
| 180 |
+
- Configure persistence settings
|
| 181 |
+
- Set up monitoring with Redis insights
|
|
|
|
| 182 |
|
| 183 |
### Security
|
| 184 |
+
- Enable authentication for Redis
|
| 185 |
- Use TLS encryption for production
|
| 186 |
- Configure network security groups
|
| 187 |
+
- Implement proper firewall rules
|
| 188 |
+
|
| 189 |
+
## 🎯 Production Deployment
|
| 190 |
+
|
| 191 |
+
### Performance Tuning
|
| 192 |
+
1. **Memory Configuration**: Set appropriate `maxmemory` and `maxmemory-policy`
|
| 193 |
+
2. **Persistence**: Configure RDB and AOF based on durability requirements
|
| 194 |
+
3. **HNSW Parameters**: Tune `M`, `ef_construction`, and `ef_runtime` for your data
|
| 195 |
+
4. **Connection Pooling**: Use connection pooling for high-concurrency applications
|
| 196 |
+
|
| 197 |
+
### Scaling
|
| 198 |
+
1. **Vertical Scaling**: Increase memory and CPU for the Redis container
|
| 199 |
+
2. **Read Replicas**: Set up Redis replicas for read scaling
|
| 200 |
+
3. **Sharding**: Implement Redis Cluster for horizontal scaling
|
| 201 |
+
4. **Monitoring**: Use Redis monitoring tools for performance insights
|
| 202 |
|
| 203 |
+
## 📚 Additional Resources
|
| 204 |
|
| 205 |
+
- [RedisStack Documentation](https://redis.io/docs/stack/)
|
| 206 |
+
- [HNSW Vector Indexing](https://redis.io/docs/stack/search/reference/vectors/)
|
| 207 |
+
- [OrKa Configuration Guide](../docs/YAML_CONFIGURATION.md)
|
| 208 |
+
- [Memory Backend Guide](../docs/MEMORY_BACKENDS.md)
|
|
|
orka/docker/V0.7.0_DOCKER_IMPROVEMENTS.md
DELETED
|
@@ -1,198 +0,0 @@
|
|
| 1 |
-
# OrKa V0.7.0 Docker Infrastructure Improvements
|
| 2 |
-
|
| 3 |
-
## 🚀 **Complete V0.7.0 Docker Upgrade Summary**
|
| 4 |
-
|
| 5 |
-
This document summarizes all Docker infrastructure improvements made for OrKa V0.7.0 to support **100x faster vector search** and enterprise deployment.
|
| 6 |
-
|
| 7 |
-
---
|
| 8 |
-
|
| 9 |
-
## ✅ **Files Updated/Created**
|
| 10 |
-
|
| 11 |
-
### **📦 Core Docker Files**
|
| 12 |
-
1. **`Dockerfile`** ✅ **UPDATED**
|
| 13 |
-
- Upgraded from Python 3.9 → **Python 3.11** (V0.7.0 requirement)
|
| 14 |
-
- Added comprehensive V0.7.0 dependencies
|
| 15 |
-
- Included system build dependencies (gcc, g++)
|
| 16 |
-
- Set `ORKA_MEMORY_BACKEND=redisstack` as default
|
| 17 |
-
- Added all required packages inline for better caching
|
| 18 |
-
|
| 19 |
-
2. **`Dockerfile.prod`** ✅ **NEW**
|
| 20 |
-
- Multi-stage production build for optimized images
|
| 21 |
-
- Non-root user for security
|
| 22 |
-
- Health checks for container monitoring
|
| 23 |
-
- Minimal runtime dependencies
|
| 24 |
-
- Better signal handling
|
| 25 |
-
|
| 26 |
-
3. **`.dockerignore`** ✅ **NEW**
|
| 27 |
-
- Optimized build context by excluding unnecessary files
|
| 28 |
-
- Reduces image size and build time
|
| 29 |
-
- Excludes docs, tests, cache files, and development artifacts
|
| 30 |
-
|
| 31 |
-
### **🔧 Requirements Files**
|
| 32 |
-
1. **`requirements-minimal.txt`** ✅ **UPDATED**
|
| 33 |
-
- Added missing V0.7.0 dependencies (OpenAI, LiteLLM, DuckDuckGo)
|
| 34 |
-
- Organized by category with clear documentation
|
| 35 |
-
- Includes all RedisStack and Kafka dependencies
|
| 36 |
-
- Proper version constraints
|
| 37 |
-
|
| 38 |
-
2. **`requirements.txt`** ✅ **UPDATED**
|
| 39 |
-
- Complete V0.7.0 dependency set
|
| 40 |
-
- Added ML packages for vector embeddings
|
| 41 |
-
- Includes all web framework dependencies
|
| 42 |
-
- Updated testing and development tools
|
| 43 |
-
|
| 44 |
-
### **🐳 Docker Compose Configuration**
|
| 45 |
-
1. **`docker-compose.yml`** ✅ **UPDATED**
|
| 46 |
-
- Enhanced RedisStack configuration with:
|
| 47 |
-
- Memory limits (2GB) for optimal performance
|
| 48 |
-
- HNSW-optimized settings
|
| 49 |
-
- Health checks and dependency ordering
|
| 50 |
-
- All OrKa services now default to `redisstack` backend
|
| 51 |
-
- Resource allocation for production workloads
|
| 52 |
-
|
| 53 |
-
### **📜 Startup Scripts**
|
| 54 |
-
1. **`start-redis.sh`** ✅ **UPDATED**
|
| 55 |
-
- Updated messaging for V0.7.0 RedisStack capabilities
|
| 56 |
-
- Added HNSW module verification
|
| 57 |
-
- Performance benchmarks in output
|
| 58 |
-
- Updated environment variable documentation
|
| 59 |
-
|
| 60 |
-
### **📚 Documentation**
|
| 61 |
-
1. **`README.md`** ✅ **UPDATED**
|
| 62 |
-
- Complete V0.7.0 feature documentation
|
| 63 |
-
- Performance benchmarks and comparisons
|
| 64 |
-
- Updated backend descriptions
|
| 65 |
-
- Enhanced troubleshooting section
|
| 66 |
-
|
| 67 |
-
2. **`V0.7.0_DOCKER_IMPROVEMENTS.md`** ✅ **NEW** (this file)
|
| 68 |
-
- Comprehensive improvement summary
|
| 69 |
-
- Migration guidance
|
| 70 |
-
- Performance documentation
|
| 71 |
-
|
| 72 |
-
---
|
| 73 |
-
|
| 74 |
-
## 🚀 **Key V0.7.0 Features Enabled**
|
| 75 |
-
|
| 76 |
-
### **RedisStack HNSW Performance**
|
| 77 |
-
- **Vector Search**: 0.5-5ms latency (100x faster than basic Redis)
|
| 78 |
-
- **Memory Operations**: 50,000+ operations/second (50x improvement)
|
| 79 |
-
- **Concurrent Searches**: 1,000+ simultaneous operations
|
| 80 |
-
- **Memory Efficiency**: 60% reduction in memory usage
|
| 81 |
-
|
| 82 |
-
### **Enterprise Architecture**
|
| 83 |
-
- **Unified Backend**: All components use RedisStack with intelligent fallback
|
| 84 |
-
- **Kafka Integration**: Enterprise streaming with RedisStack memory operations
|
| 85 |
-
- **Production Ready**: Multi-stage builds, health checks, resource limits
|
| 86 |
-
- **Security**: Non-root containers, minimal attack surface
|
| 87 |
-
|
| 88 |
-
### **Developer Experience**
|
| 89 |
-
- **Automatic Setup**: Zero manual configuration required
|
| 90 |
-
- **Performance Monitoring**: Built-in HNSW metrics and dashboard
|
| 91 |
-
- **Easy Migration**: Backward compatibility maintained
|
| 92 |
-
- **Comprehensive Logging**: Enhanced debugging and monitoring
|
| 93 |
-
|
| 94 |
-
---
|
| 95 |
-
|
| 96 |
-
## 📊 **Performance Improvements**
|
| 97 |
-
|
| 98 |
-
| Metric | Basic Redis | **V0.7.0 RedisStack** | Improvement |
|
| 99 |
-
|--------|-------------|------------------------|-------------|
|
| 100 |
-
| **Vector Search Latency** | 50-200ms | **0.5-5ms** | **100x faster** |
|
| 101 |
-
| **Memory Throughput** | 1,000/sec | **50,000/sec** | **50x higher** |
|
| 102 |
-
| **Concurrent Operations** | 10-50 | **1,000+** | **20x more** |
|
| 103 |
-
| **Memory Usage** | 100% baseline | **40%** | **60% reduction** |
|
| 104 |
-
| **Docker Build Time** | ~5 minutes | **~2 minutes** | **2.5x faster** |
|
| 105 |
-
| **Image Size** | ~800MB | **~600MB** | **25% smaller** |
|
| 106 |
-
|
| 107 |
-
---
|
| 108 |
-
|
| 109 |
-
## 🔧 **Deployment Options**
|
| 110 |
-
|
| 111 |
-
### **Development (RedisStack Only)**
|
| 112 |
-
```bash
|
| 113 |
-
./start-redis.sh
|
| 114 |
-
# Provides: 100x faster vector search for development
|
| 115 |
-
```
|
| 116 |
-
|
| 117 |
-
### **Enterprise (Kafka + RedisStack)**
|
| 118 |
-
```bash
|
| 119 |
-
./start-kafka.sh
|
| 120 |
-
# Provides: Event streaming + 100x faster memory operations
|
| 121 |
-
```
|
| 122 |
-
|
| 123 |
-
### **Production (Optimized Build)**
|
| 124 |
-
```bash
|
| 125 |
-
docker build -f Dockerfile.prod -t orka-prod .
|
| 126 |
-
# Provides: Multi-stage build, security hardening, health checks
|
| 127 |
-
```
|
| 128 |
-
|
| 129 |
-
---
|
| 130 |
-
|
| 131 |
-
## 🛠️ **Migration from Previous Versions**
|
| 132 |
-
|
| 133 |
-
### **From V0.6.x Docker Setup**
|
| 134 |
-
1. **Pull latest code** with V0.7.0 Docker improvements
|
| 135 |
-
2. **Rebuild containers**: `docker-compose --profile redis up --build`
|
| 136 |
-
3. **Automatic RedisStack**: No configuration changes needed
|
| 137 |
-
4. **Verify performance**: Use `python -m orka.orka_cli memory watch`
|
| 138 |
-
|
| 139 |
-
### **Environment Variables**
|
| 140 |
-
- **No changes required** - V0.7.0 defaults to RedisStack automatically
|
| 141 |
-
- **Optional override**: Set `ORKA_FORCE_BASIC_REDIS=true` for basic Redis mode
|
| 142 |
-
- **Performance monitoring**: Built-in HNSW metrics in CLI dashboard
|
| 143 |
-
|
| 144 |
-
---
|
| 145 |
-
|
| 146 |
-
## ✅ **Verification Checklist**
|
| 147 |
-
|
| 148 |
-
After deploying V0.7.0 Docker infrastructure:
|
| 149 |
-
|
| 150 |
-
- [ ] **RedisStack running**: `docker-compose exec redis redis-cli ping`
|
| 151 |
-
- [ ] **HNSW modules loaded**: `docker-compose exec redis redis-cli MODULE LIST | grep search`
|
| 152 |
-
- [ ] **OrKa API responsive**: `curl http://localhost:8000/health`
|
| 153 |
-
- [ ] **Vector search working**: `python -m orka.orka_cli memory watch`
|
| 154 |
-
- [ ] **Performance metrics**: Monitor sub-millisecond search latency
|
| 155 |
-
- [ ] **Memory operations**: Verify 50,000+ ops/sec throughput
|
| 156 |
-
|
| 157 |
-
---
|
| 158 |
-
|
| 159 |
-
## 🎯 **Production Deployment Recommendations**
|
| 160 |
-
|
| 161 |
-
### **Resource Allocation**
|
| 162 |
-
```yaml
|
| 163 |
-
# docker-compose.override.yml for production
|
| 164 |
-
services:
|
| 165 |
-
redis:
|
| 166 |
-
deploy:
|
| 167 |
-
resources:
|
| 168 |
-
limits:
|
| 169 |
-
memory: 8G # Scale based on memory dataset size
|
| 170 |
-
cpus: '4' # HNSW indexing benefits from multiple cores
|
| 171 |
-
```
|
| 172 |
-
|
| 173 |
-
### **Monitoring Setup**
|
| 174 |
-
```bash
|
| 175 |
-
# Enable comprehensive monitoring
|
| 176 |
-
docker-compose up -d
|
| 177 |
-
python -m orka.orka_cli memory watch # Real-time dashboard
|
| 178 |
-
```
|
| 179 |
-
|
| 180 |
-
### **Backup Strategy**
|
| 181 |
-
```bash
|
| 182 |
-
# RedisStack data persistence
|
| 183 |
-
docker-compose exec redis redis-cli BGSAVE
|
| 184 |
-
# Backup volume: redis_data
|
| 185 |
-
```
|
| 186 |
-
|
| 187 |
-
---
|
| 188 |
-
|
| 189 |
-
## 🌟 **OrKa V0.7.0 Docker - Production Ready!**
|
| 190 |
-
|
| 191 |
-
The Docker infrastructure has been completely modernized for V0.7.0:
|
| 192 |
-
|
| 193 |
-
- **🚀 Enterprise Performance**: 100x faster vector search out of the box
|
| 194 |
-
- **🔧 Zero Configuration**: Automatic RedisStack setup and optimization
|
| 195 |
-
- **🏗️ Production Hardened**: Security, monitoring, and resource management
|
| 196 |
-
- **⚡ Developer Friendly**: Enhanced debugging and real-time monitoring
|
| 197 |
-
|
| 198 |
-
**Ready to deploy OrKa V0.7.0 with revolutionary AI performance!**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orka/docker/cleanup-and-start.sh
CHANGED
|
@@ -43,16 +43,8 @@ case $PROFILE in
|
|
| 43 |
echo "Starting Redis profile..."
|
| 44 |
docker-compose --profile redis up -d --remove-orphans
|
| 45 |
;;
|
| 46 |
-
kafka)
|
| 47 |
-
echo "Starting Kafka profile..."
|
| 48 |
-
docker-compose --profile kafka up -d --remove-orphans
|
| 49 |
-
;;
|
| 50 |
-
dual)
|
| 51 |
-
echo "Starting dual backend profile..."
|
| 52 |
-
docker-compose --profile dual up -d --remove-orphans
|
| 53 |
-
;;
|
| 54 |
*)
|
| 55 |
-
echo "Usage: $0 [redis
|
| 56 |
echo "Defaulting to redis profile..."
|
| 57 |
docker-compose --profile redis up -d --remove-orphans
|
| 58 |
;;
|
|
|
|
| 43 |
echo "Starting Redis profile..."
|
| 44 |
docker-compose --profile redis up -d --remove-orphans
|
| 45 |
;;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
*)
|
| 47 |
+
echo "Usage: $0 [redis]"
|
| 48 |
echo "Defaulting to redis profile..."
|
| 49 |
docker-compose --profile redis up -d --remove-orphans
|
| 50 |
;;
|
orka/docker/cleanup.sh
CHANGED
|
@@ -30,8 +30,6 @@ fi
|
|
| 30 |
|
| 31 |
# Stop all profile-based services
|
| 32 |
stop_profile "redis" "Redis"
|
| 33 |
-
stop_profile "kafka" "Kafka"
|
| 34 |
-
stop_profile "dual" "Dual Backend"
|
| 35 |
|
| 36 |
# Stop any remaining containers
|
| 37 |
echo "🛑 Stopping any remaining Orka containers..."
|
|
@@ -66,7 +64,7 @@ if [[ "$CLEAN_VOLUMES" == false ]]; then
|
|
| 66 |
fi
|
| 67 |
|
| 68 |
echo "📋 Current Docker status:"
|
| 69 |
-
echo " • Running containers: $(docker ps --format 'table {{.Names}}\t{{.Status}}' | grep -E '(orka|redis
|
| 70 |
echo " • Orka volumes: $(docker volume ls --format 'table {{.Name}}' | grep -E '(orka|redis)' | wc -l || echo '0')"
|
| 71 |
-
echo " • Orka networks: $(docker network ls --format 'table {{.Name}}' | grep -E '(orka|redis
|
| 72 |
echo ""
|
|
|
|
| 30 |
|
| 31 |
# Stop all profile-based services
|
| 32 |
stop_profile "redis" "Redis"
|
|
|
|
|
|
|
| 33 |
|
| 34 |
# Stop any remaining containers
|
| 35 |
echo "🛑 Stopping any remaining Orka containers..."
|
|
|
|
| 64 |
fi
|
| 65 |
|
| 66 |
echo "📋 Current Docker status:"
|
| 67 |
+
echo " • Running containers: $(docker ps --format 'table {{.Names}}\t{{.Status}}' | grep -E '(orka|redis)' | wc -l || echo '0')"
|
| 68 |
echo " • Orka volumes: $(docker volume ls --format 'table {{.Name}}' | grep -E '(orka|redis)' | wc -l || echo '0')"
|
| 69 |
+
echo " • Orka networks: $(docker network ls --format 'table {{.Name}}' | grep -E '(orka|redis)' | wc -l || echo '0')"
|
| 70 |
echo ""
|
orka/docker/docker-compose.yml
CHANGED
|
@@ -35,8 +35,7 @@ services:
|
|
| 35 |
- orka-redis-network
|
| 36 |
profiles:
|
| 37 |
- redis
|
| 38 |
-
-
|
| 39 |
-
- dual
|
| 40 |
environment:
|
| 41 |
- REDIS_ARGS=--appendonly yes --dir /data --maxmemory 2gb --maxmemory-policy allkeys-lru
|
| 42 |
healthcheck:
|
|
@@ -51,86 +50,6 @@ services:
|
|
| 51 |
reservations:
|
| 52 |
memory: 1G
|
| 53 |
|
| 54 |
-
# ===================
|
| 55 |
-
# Kafka Infrastructure
|
| 56 |
-
# ===================
|
| 57 |
-
zookeeper:
|
| 58 |
-
image: confluentinc/cp-zookeeper:latest
|
| 59 |
-
environment:
|
| 60 |
-
ZOOKEEPER_CLIENT_PORT: 2181
|
| 61 |
-
ZOOKEEPER_TICK_TIME: 2000
|
| 62 |
-
networks:
|
| 63 |
-
- orka-kafka-network
|
| 64 |
-
restart: always
|
| 65 |
-
profiles:
|
| 66 |
-
- kafka
|
| 67 |
-
- dual
|
| 68 |
-
|
| 69 |
-
kafka:
|
| 70 |
-
image: confluentinc/cp-kafka:7.4.0
|
| 71 |
-
depends_on:
|
| 72 |
-
- zookeeper
|
| 73 |
-
ports:
|
| 74 |
-
- "9092:9092"
|
| 75 |
-
environment:
|
| 76 |
-
KAFKA_BROKER_ID: 1
|
| 77 |
-
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
| 78 |
-
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://kafka:29092
|
| 79 |
-
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
|
| 80 |
-
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT_INTERNAL
|
| 81 |
-
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
| 82 |
-
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
|
| 83 |
-
# Use stable Zookeeper mode (not KRaft)
|
| 84 |
-
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
|
| 85 |
-
networks:
|
| 86 |
-
- orka-kafka-network
|
| 87 |
-
restart: always
|
| 88 |
-
profiles:
|
| 89 |
-
- kafka
|
| 90 |
-
- dual
|
| 91 |
-
|
| 92 |
-
# ===================
|
| 93 |
-
# Schema Registry
|
| 94 |
-
# ===================
|
| 95 |
-
schema-registry:
|
| 96 |
-
image: confluentinc/cp-schema-registry:7.4.0
|
| 97 |
-
depends_on:
|
| 98 |
-
- kafka
|
| 99 |
-
- zookeeper
|
| 100 |
-
ports:
|
| 101 |
-
- "8081:8081"
|
| 102 |
-
environment:
|
| 103 |
-
SCHEMA_REGISTRY_HOST_NAME: schema-registry
|
| 104 |
-
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: PLAINTEXT://kafka:29092
|
| 105 |
-
SCHEMA_REGISTRY_LISTENERS: http://0.0.0.0:8081
|
| 106 |
-
SCHEMA_REGISTRY_KAFKASTORE_TOPIC: _schemas
|
| 107 |
-
SCHEMA_REGISTRY_DEBUG: 'true'
|
| 108 |
-
networks:
|
| 109 |
-
- orka-kafka-network
|
| 110 |
-
restart: always
|
| 111 |
-
profiles:
|
| 112 |
-
- kafka
|
| 113 |
-
- dual
|
| 114 |
-
|
| 115 |
-
# ===================
|
| 116 |
-
# Optional: Schema Registry UI
|
| 117 |
-
# ===================
|
| 118 |
-
schema-registry-ui:
|
| 119 |
-
image: landoop/schema-registry-ui:latest
|
| 120 |
-
depends_on:
|
| 121 |
-
- schema-registry
|
| 122 |
-
ports:
|
| 123 |
-
- "8082:8000"
|
| 124 |
-
environment:
|
| 125 |
-
SCHEMAREGISTRY_URL: http://schema-registry:8081
|
| 126 |
-
PROXY: 'true'
|
| 127 |
-
networks:
|
| 128 |
-
- orka-kafka-network
|
| 129 |
-
restart: always
|
| 130 |
-
profiles:
|
| 131 |
-
- kafka
|
| 132 |
-
- dual
|
| 133 |
-
|
| 134 |
# ===================
|
| 135 |
# Orka Services
|
| 136 |
# ===================
|
|
@@ -154,77 +73,11 @@ services:
|
|
| 154 |
- orka-redis-network
|
| 155 |
profiles:
|
| 156 |
- redis
|
| 157 |
-
|
| 158 |
-
orka-start-kafka:
|
| 159 |
-
build:
|
| 160 |
-
context: ../..
|
| 161 |
-
dockerfile: orka/docker/Dockerfile
|
| 162 |
-
ports:
|
| 163 |
-
- "8001:8000" # Different port to avoid conflicts
|
| 164 |
-
environment:
|
| 165 |
-
- ORKA_MEMORY_BACKEND=kafka
|
| 166 |
-
- KAFKA_BOOTSTRAP_SERVERS=kafka:29092
|
| 167 |
-
- KAFKA_TOPIC_PREFIX=orka-memory
|
| 168 |
-
- KAFKA_SCHEMA_REGISTRY_URL=http://schema-registry:8081
|
| 169 |
-
- REDIS_URL=redis://redis:6380/0 # Redis for memory operations
|
| 170 |
-
- ORKA_PORT=8000
|
| 171 |
-
depends_on:
|
| 172 |
-
kafka:
|
| 173 |
-
condition: service_started
|
| 174 |
-
zookeeper:
|
| 175 |
-
condition: service_started
|
| 176 |
-
schema-registry:
|
| 177 |
-
condition: service_started
|
| 178 |
-
redis:
|
| 179 |
-
condition: service_healthy
|
| 180 |
-
cleanup:
|
| 181 |
-
condition: service_completed_successfully
|
| 182 |
-
restart: always
|
| 183 |
-
networks:
|
| 184 |
-
- orka-kafka-network
|
| 185 |
-
- orka-redis-network # Connect to Redis network too
|
| 186 |
-
profiles:
|
| 187 |
-
- kafka
|
| 188 |
-
|
| 189 |
-
# ===================
|
| 190 |
-
# Optional: Combined service for testing both backends
|
| 191 |
-
# ===================
|
| 192 |
-
orka-dual-backend:
|
| 193 |
-
build:
|
| 194 |
-
context: ../..
|
| 195 |
-
dockerfile: orka/docker/Dockerfile
|
| 196 |
-
ports:
|
| 197 |
-
- "8002:8000"
|
| 198 |
-
environment:
|
| 199 |
-
- ORKA_MEMORY_BACKEND=redisstack # Default to RedisStack
|
| 200 |
-
- REDIS_URL=redis://redis:6380/0
|
| 201 |
-
- KAFKA_BOOTSTRAP_SERVERS=kafka:29092
|
| 202 |
-
- KAFKA_TOPIC_PREFIX=orka-memory
|
| 203 |
-
- KAFKA_SCHEMA_REGISTRY_URL=http://schema-registry:8081
|
| 204 |
-
- ORKA_PORT=8000
|
| 205 |
-
depends_on:
|
| 206 |
-
redis:
|
| 207 |
-
condition: service_healthy
|
| 208 |
-
kafka:
|
| 209 |
-
condition: service_started
|
| 210 |
-
zookeeper:
|
| 211 |
-
condition: service_started
|
| 212 |
-
schema-registry:
|
| 213 |
-
condition: service_started
|
| 214 |
-
cleanup:
|
| 215 |
-
condition: service_completed_successfully
|
| 216 |
-
restart: always
|
| 217 |
-
networks:
|
| 218 |
-
- orka-redis-network
|
| 219 |
-
- orka-kafka-network
|
| 220 |
-
profiles:
|
| 221 |
-
- dual
|
| 222 |
|
| 223 |
volumes:
|
| 224 |
redis_data:
|
| 225 |
|
| 226 |
networks:
|
| 227 |
orka-redis-network:
|
| 228 |
-
driver: bridge
|
| 229 |
-
orka-kafka-network:
|
| 230 |
driver: bridge
|
|
|
|
| 35 |
- orka-redis-network
|
| 36 |
profiles:
|
| 37 |
- redis
|
| 38 |
+
- default # Make redis the default profile
|
|
|
|
| 39 |
environment:
|
| 40 |
- REDIS_ARGS=--appendonly yes --dir /data --maxmemory 2gb --maxmemory-policy allkeys-lru
|
| 41 |
healthcheck:
|
|
|
|
| 50 |
reservations:
|
| 51 |
memory: 1G
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
# ===================
|
| 54 |
# Orka Services
|
| 55 |
# ===================
|
|
|
|
| 73 |
- orka-redis-network
|
| 74 |
profiles:
|
| 75 |
- redis
|
| 76 |
+
- default # Make this the default service
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
volumes:
|
| 79 |
redis_data:
|
| 80 |
|
| 81 |
networks:
|
| 82 |
orka-redis-network:
|
|
|
|
|
|
|
| 83 |
driver: bridge
|
orka/docker/start-dual.sh
DELETED
|
@@ -1,78 +0,0 @@
|
|
| 1 |
-
#!/bin/bash
|
| 2 |
-
|
| 3 |
-
# Orka Dual Backend Startup Script
|
| 4 |
-
# This script starts Orka with both Redis and Kafka backends for testing
|
| 5 |
-
|
| 6 |
-
set -e # Exit on any error
|
| 7 |
-
|
| 8 |
-
echo "🚀 Starting Orka with Dual Backend (Redis + Kafka)..."
|
| 9 |
-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
| 10 |
-
|
| 11 |
-
# Stop any existing services
|
| 12 |
-
echo "🛑 Stopping any existing services..."
|
| 13 |
-
docker-compose --profile dual down 2>/dev/null || true
|
| 14 |
-
|
| 15 |
-
# Build and start all services
|
| 16 |
-
echo "🔧 Building and starting all services..."
|
| 17 |
-
docker-compose --profile dual up --build -d
|
| 18 |
-
|
| 19 |
-
# Wait for services to be ready
|
| 20 |
-
echo "⏳ Waiting for services to initialize..."
|
| 21 |
-
sleep 15
|
| 22 |
-
|
| 23 |
-
# Check Redis
|
| 24 |
-
echo "🔍 Testing Redis connection..."
|
| 25 |
-
if docker-compose exec redis redis-cli ping > /dev/null 2>&1; then
|
| 26 |
-
echo "✅ Redis is ready!"
|
| 27 |
-
else
|
| 28 |
-
echo "❌ Redis connection failed"
|
| 29 |
-
exit 1
|
| 30 |
-
fi
|
| 31 |
-
|
| 32 |
-
# Check Kafka
|
| 33 |
-
echo "🔍 Testing Kafka connection..."
|
| 34 |
-
sleep 5
|
| 35 |
-
if docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --list > /dev/null 2>&1; then
|
| 36 |
-
echo "✅ Kafka is ready!"
|
| 37 |
-
else
|
| 38 |
-
echo "❌ Kafka connection failed, trying again..."
|
| 39 |
-
sleep 10
|
| 40 |
-
if docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --list > /dev/null 2>&1; then
|
| 41 |
-
echo "✅ Kafka is now ready!"
|
| 42 |
-
else
|
| 43 |
-
echo "❌ Kafka connection still failing"
|
| 44 |
-
exit 1
|
| 45 |
-
fi
|
| 46 |
-
fi
|
| 47 |
-
|
| 48 |
-
# Create initial Orka topics
|
| 49 |
-
echo "📝 Creating Orka topics..."
|
| 50 |
-
docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --create --topic orka-memory-events --partitions 3 --replication-factor 1 --if-not-exists 2>/dev/null || true
|
| 51 |
-
|
| 52 |
-
# Show running services
|
| 53 |
-
echo "📋 Services Status:"
|
| 54 |
-
docker-compose --profile dual ps
|
| 55 |
-
|
| 56 |
-
echo ""
|
| 57 |
-
echo "✅ Orka Dual Backend is now running!"
|
| 58 |
-
echo ""
|
| 59 |
-
echo "📍 Service Endpoints:"
|
| 60 |
-
echo " • Orka API (Dual): http://localhost:8002"
|
| 61 |
-
echo " • Redis: localhost:6380"
|
| 62 |
-
echo " • Kafka: localhost:9092"
|
| 63 |
-
echo " • Zookeeper: localhost:2181"
|
| 64 |
-
echo ""
|
| 65 |
-
echo "🛠️ Management Commands:"
|
| 66 |
-
echo " • View logs: docker-compose --profile dual logs -f"
|
| 67 |
-
echo " • Stop services: docker-compose --profile dual down"
|
| 68 |
-
echo " • Redis CLI: docker-compose exec redis redis-cli"
|
| 69 |
-
echo " • List topics: docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --list"
|
| 70 |
-
echo ""
|
| 71 |
-
echo "🔧 Environment Variables (Default):"
|
| 72 |
-
echo " • ORKA_MEMORY_BACKEND=redis (can be changed to kafka)"
|
| 73 |
-
echo " • REDIS_URL=redis://redis:6380/0"
|
| 74 |
-
echo " • KAFKA_BOOTSTRAP_SERVERS=kafka:29092"
|
| 75 |
-
echo " • KAFKA_TOPIC_PREFIX=orka-memory"
|
| 76 |
-
echo ""
|
| 77 |
-
echo "💡 Switch backend by setting ORKA_MEMORY_BACKEND environment variable"
|
| 78 |
-
echo ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orka/docker/start-kafka.bat
DELETED
|
@@ -1,84 +0,0 @@
|
|
| 1 |
-
@echo off
|
| 2 |
-
REM Orka Kafka + Redis Hybrid Backend Startup Script (Windows)
|
| 3 |
-
REM This script starts Orka with Kafka for event streaming and Redis for memory operations
|
| 4 |
-
|
| 5 |
-
echo 🚀 Starting Orka with Kafka + Redis Hybrid Backend...
|
| 6 |
-
echo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
| 7 |
-
|
| 8 |
-
REM Stop any existing services
|
| 9 |
-
echo 🛑 Stopping any existing services...
|
| 10 |
-
docker-compose --profile kafka down >nul 2>&1
|
| 11 |
-
|
| 12 |
-
REM Build and start hybrid services (Kafka + Redis)
|
| 13 |
-
echo 🔧 Building and starting Kafka + Redis services...
|
| 14 |
-
docker-compose --profile kafka up --build -d
|
| 15 |
-
|
| 16 |
-
REM Wait for services to be ready
|
| 17 |
-
echo ⏳ Waiting for Redis to be ready...
|
| 18 |
-
timeout /t 5 >nul
|
| 19 |
-
|
| 20 |
-
REM Check if Redis is responding
|
| 21 |
-
echo 🔍 Testing Redis connection...
|
| 22 |
-
docker-compose exec redis redis-cli ping >nul 2>&1
|
| 23 |
-
if %errorlevel% equ 0 (
|
| 24 |
-
echo ✅ Redis is ready!
|
| 25 |
-
) else (
|
| 26 |
-
echo ❌ Redis connection failed
|
| 27 |
-
exit /b 1
|
| 28 |
-
)
|
| 29 |
-
|
| 30 |
-
echo ⏳ Waiting for Zookeeper to be ready...
|
| 31 |
-
timeout /t 10 >nul
|
| 32 |
-
|
| 33 |
-
echo ⏳ Waiting for Kafka to be ready...
|
| 34 |
-
timeout /t 15 >nul
|
| 35 |
-
|
| 36 |
-
REM Check if Kafka is responding
|
| 37 |
-
echo 🔍 Testing Kafka connection...
|
| 38 |
-
docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --list >nul 2>&1
|
| 39 |
-
if %errorlevel% equ 0 (
|
| 40 |
-
echo ✅ Kafka is ready!
|
| 41 |
-
) else (
|
| 42 |
-
echo ❌ Kafka connection failed, trying again...
|
| 43 |
-
timeout /t 10 >nul
|
| 44 |
-
docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --list >nul 2>&1
|
| 45 |
-
if %errorlevel% equ 0 (
|
| 46 |
-
echo ✅ Kafka is now ready!
|
| 47 |
-
) else (
|
| 48 |
-
echo ❌ Kafka connection still failing
|
| 49 |
-
echo 📋 Checking service logs for diagnostics...
|
| 50 |
-
docker-compose --profile kafka logs kafka
|
| 51 |
-
exit /b 1
|
| 52 |
-
)
|
| 53 |
-
)
|
| 54 |
-
|
| 55 |
-
REM Create initial Orka topics
|
| 56 |
-
echo 📝 Creating Orka topics...
|
| 57 |
-
docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --create --topic orka-memory-events --partitions 3 --replication-factor 1 --if-not-exists >nul 2>&1
|
| 58 |
-
|
| 59 |
-
REM Show running services
|
| 60 |
-
echo 📋 Services Status:
|
| 61 |
-
docker-compose --profile kafka ps
|
| 62 |
-
|
| 63 |
-
echo.
|
| 64 |
-
echo ✅ Orka Kafka + Redis Hybrid Backend is now running!
|
| 65 |
-
echo.
|
| 66 |
-
echo 📍 Service Endpoints:
|
| 67 |
-
echo • Orka API: http://localhost:8001
|
| 68 |
-
echo • Kafka (Events): localhost:9092
|
| 69 |
-
echo • Redis (Memory): localhost:6380
|
| 70 |
-
echo • Zookeeper: localhost:2181
|
| 71 |
-
echo.
|
| 72 |
-
echo 🛠️ Management Commands:
|
| 73 |
-
echo • View logs: docker-compose --profile kafka logs -f
|
| 74 |
-
echo • Stop services: docker-compose --profile kafka down
|
| 75 |
-
echo • List topics: docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --list
|
| 76 |
-
echo • View messages: docker-compose exec kafka kafka-console-consumer --bootstrap-server localhost:29092 --topic orka-memory-events --from-beginning
|
| 77 |
-
echo • Redis CLI: docker-compose exec redis redis-cli
|
| 78 |
-
echo.
|
| 79 |
-
echo 🔧 Environment Variables:
|
| 80 |
-
echo • ORKA_MEMORY_BACKEND=kafka
|
| 81 |
-
echo • KAFKA_BOOTSTRAP_SERVERS=kafka:29092
|
| 82 |
-
echo • KAFKA_TOPIC_PREFIX=orka-memory
|
| 83 |
-
echo • REDIS_URL=redis://redis:6380/0
|
| 84 |
-
echo.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orka/docker/start-kafka.sh
DELETED
|
@@ -1,84 +0,0 @@
|
|
| 1 |
-
#!/bin/bash
|
| 2 |
-
|
| 3 |
-
# Orka Kafka + Redis Hybrid Backend Startup Script
|
| 4 |
-
# This script starts Orka with Kafka for event streaming and Redis for memory operations
|
| 5 |
-
|
| 6 |
-
set -e # Exit on any error
|
| 7 |
-
|
| 8 |
-
echo "🚀 Starting Orka with Kafka + Redis Hybrid Backend..."
|
| 9 |
-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
| 10 |
-
|
| 11 |
-
# Stop any existing services
|
| 12 |
-
echo "🛑 Stopping any existing services..."
|
| 13 |
-
docker-compose --profile kafka down 2>/dev/null || true
|
| 14 |
-
|
| 15 |
-
# Build and start hybrid services (Kafka + Redis)
|
| 16 |
-
echo "🔧 Building and starting Kafka + Redis services..."
|
| 17 |
-
docker-compose --profile kafka up --build -d
|
| 18 |
-
|
| 19 |
-
# Wait for services to be ready
|
| 20 |
-
echo "⏳ Waiting for Redis to be ready..."
|
| 21 |
-
sleep 5
|
| 22 |
-
|
| 23 |
-
# Check if Redis is responding
|
| 24 |
-
echo "🔍 Testing Redis connection..."
|
| 25 |
-
if docker-compose exec redis redis-cli ping > /dev/null 2>&1; then
|
| 26 |
-
echo "✅ Redis is ready!"
|
| 27 |
-
else
|
| 28 |
-
echo "❌ Redis connection failed"
|
| 29 |
-
exit 1
|
| 30 |
-
fi
|
| 31 |
-
|
| 32 |
-
echo "⏳ Waiting for Zookeeper to be ready..."
|
| 33 |
-
sleep 10
|
| 34 |
-
|
| 35 |
-
echo "⏳ Waiting for Kafka to be ready..."
|
| 36 |
-
sleep 15
|
| 37 |
-
|
| 38 |
-
# Check if Kafka is responding
|
| 39 |
-
echo "🔍 Testing Kafka connection..."
|
| 40 |
-
if docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --list > /dev/null 2>&1; then
|
| 41 |
-
echo "✅ Kafka is ready!"
|
| 42 |
-
else
|
| 43 |
-
echo "❌ Kafka connection failed, trying again..."
|
| 44 |
-
sleep 10
|
| 45 |
-
if docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --list > /dev/null 2>&1; then
|
| 46 |
-
echo "✅ Kafka is now ready!"
|
| 47 |
-
else
|
| 48 |
-
echo "❌ Kafka connection still failing"
|
| 49 |
-
echo "📋 Checking service logs for diagnostics..."
|
| 50 |
-
docker-compose --profile kafka logs kafka
|
| 51 |
-
exit 1
|
| 52 |
-
fi
|
| 53 |
-
fi
|
| 54 |
-
|
| 55 |
-
# Create initial Orka topics
|
| 56 |
-
echo "📝 Creating Orka topics..."
|
| 57 |
-
docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --create --topic orka-memory-events --partitions 3 --replication-factor 1 --if-not-exists 2>/dev/null || true
|
| 58 |
-
|
| 59 |
-
# Show running services
|
| 60 |
-
echo "📋 Services Status:"
|
| 61 |
-
docker-compose --profile kafka ps
|
| 62 |
-
|
| 63 |
-
echo ""
|
| 64 |
-
echo "✅ Orka Kafka + Redis Hybrid Backend is now running!"
|
| 65 |
-
echo ""
|
| 66 |
-
echo "📍 Service Endpoints:"
|
| 67 |
-
echo " • Orka API: http://localhost:8001"
|
| 68 |
-
echo " • Kafka (Events): localhost:9092"
|
| 69 |
-
echo " • Redis (Memory): localhost:6380"
|
| 70 |
-
echo " • Zookeeper: localhost:2181"
|
| 71 |
-
echo ""
|
| 72 |
-
echo "🛠️ Management Commands:"
|
| 73 |
-
echo " • View logs: docker-compose --profile kafka logs -f"
|
| 74 |
-
echo " • Stop services: docker-compose --profile kafka down"
|
| 75 |
-
echo " • List topics: docker-compose exec kafka kafka-topics --bootstrap-server localhost:29092 --list"
|
| 76 |
-
echo " • View messages: docker-compose exec kafka kafka-console-consumer --bootstrap-server localhost:29092 --topic orka-memory-events --from-beginning"
|
| 77 |
-
echo " • Redis CLI: docker-compose exec redis redis-cli"
|
| 78 |
-
echo ""
|
| 79 |
-
echo "🔧 Environment Variables:"
|
| 80 |
-
echo " • ORKA_MEMORY_BACKEND=kafka"
|
| 81 |
-
echo " • KAFKA_BOOTSTRAP_SERVERS=kafka:29092"
|
| 82 |
-
echo " • KAFKA_TOPIC_PREFIX=orka-memory"
|
| 83 |
-
echo " • REDIS_URL=redis://redis:6380/0"
|
| 84 |
-
echo ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orka/docker/start-redis.bat
CHANGED
|
@@ -1,29 +1,39 @@
|
|
| 1 |
@echo off
|
| 2 |
-
REM
|
| 3 |
-
REM This script starts
|
| 4 |
|
| 5 |
-
echo 🚀 Starting
|
| 6 |
echo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
| 7 |
|
| 8 |
REM Stop any existing services
|
| 9 |
-
echo 🛑 Stopping any existing
|
| 10 |
docker-compose --profile redis down >nul 2>&1
|
| 11 |
|
| 12 |
-
REM Build and start
|
| 13 |
-
echo 🔧 Building and starting
|
| 14 |
docker-compose --profile redis up --build -d
|
| 15 |
|
| 16 |
REM Wait for services to be ready
|
| 17 |
-
echo ⏳ Waiting for
|
| 18 |
-
timeout /t
|
| 19 |
|
| 20 |
-
REM Check if
|
| 21 |
-
echo 🔍 Testing
|
| 22 |
docker-compose exec redis redis-cli ping >nul 2>&1
|
| 23 |
if %errorlevel% equ 0 (
|
| 24 |
-
echo ✅
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
) else (
|
| 26 |
-
echo ❌
|
| 27 |
exit /b 1
|
| 28 |
)
|
| 29 |
|
|
@@ -32,18 +42,24 @@ echo 📋 Services Status:
|
|
| 32 |
docker-compose --profile redis ps
|
| 33 |
|
| 34 |
echo.
|
| 35 |
-
echo ✅
|
| 36 |
echo.
|
| 37 |
echo 📍 Service Endpoints:
|
| 38 |
-
echo •
|
| 39 |
-
echo •
|
| 40 |
echo.
|
| 41 |
echo 🛠️ Management Commands:
|
| 42 |
echo • View logs: docker-compose --profile redis logs -f
|
| 43 |
echo • Stop services: docker-compose --profile redis down
|
| 44 |
echo • Redis CLI: docker-compose exec redis redis-cli
|
|
|
|
| 45 |
echo.
|
| 46 |
echo 🔧 Environment Variables:
|
| 47 |
-
echo • ORKA_MEMORY_BACKEND=
|
| 48 |
echo • REDIS_URL=redis://redis:6380/0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
echo.
|
|
|
|
| 1 |
@echo off
|
| 2 |
+
REM OrKa V0.7.0 RedisStack Backend Startup Script (Windows)
|
| 3 |
+
REM This script starts OrKa with RedisStack for 100x faster vector search
|
| 4 |
|
| 5 |
+
echo 🚀 Starting OrKa V0.7.0 with RedisStack Backend (100x Faster Vector Search)...
|
| 6 |
echo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
| 7 |
|
| 8 |
REM Stop any existing services
|
| 9 |
+
echo 🛑 Stopping any existing RedisStack services...
|
| 10 |
docker-compose --profile redis down >nul 2>&1
|
| 11 |
|
| 12 |
+
REM Build and start RedisStack services
|
| 13 |
+
echo 🔧 Building and starting RedisStack services...
|
| 14 |
docker-compose --profile redis up --build -d
|
| 15 |
|
| 16 |
REM Wait for services to be ready
|
| 17 |
+
echo ⏳ Waiting for RedisStack to be ready...
|
| 18 |
+
timeout /t 10 >nul
|
| 19 |
|
| 20 |
+
REM Check if RedisStack is responding
|
| 21 |
+
echo 🔍 Testing RedisStack connection...
|
| 22 |
docker-compose exec redis redis-cli ping >nul 2>&1
|
| 23 |
if %errorlevel% equ 0 (
|
| 24 |
+
echo ✅ RedisStack is ready!
|
| 25 |
+
|
| 26 |
+
REM Check if vector search modules are loaded
|
| 27 |
+
echo 🔍 Verifying HNSW vector search capabilities...
|
| 28 |
+
docker-compose exec redis redis-cli MODULE LIST | findstr /i search >nul 2>&1
|
| 29 |
+
if %errorlevel% equ 0 (
|
| 30 |
+
echo ✅ RedisStack vector search modules loaded!
|
| 31 |
+
echo 🚀 HNSW indexing available for 100x faster searches!
|
| 32 |
+
) else (
|
| 33 |
+
echo ⚠️ Vector search modules not detected - falling back to basic Redis
|
| 34 |
+
)
|
| 35 |
) else (
|
| 36 |
+
echo ❌ RedisStack connection failed
|
| 37 |
exit /b 1
|
| 38 |
)
|
| 39 |
|
|
|
|
| 42 |
docker-compose --profile redis ps
|
| 43 |
|
| 44 |
echo.
|
| 45 |
+
echo ✅ OrKa V0.7.0 RedisStack Backend is now running!
|
| 46 |
echo.
|
| 47 |
echo 📍 Service Endpoints:
|
| 48 |
+
echo • OrKa API: http://localhost:8000
|
| 49 |
+
echo • RedisStack: localhost:6380 (external), redis:6380 (internal)
|
| 50 |
echo.
|
| 51 |
echo 🛠️ Management Commands:
|
| 52 |
echo • View logs: docker-compose --profile redis logs -f
|
| 53 |
echo • Stop services: docker-compose --profile redis down
|
| 54 |
echo • Redis CLI: docker-compose exec redis redis-cli
|
| 55 |
+
echo • Memory watch: python -m orka.orka_cli memory watch
|
| 56 |
echo.
|
| 57 |
echo 🔧 Environment Variables:
|
| 58 |
+
echo • ORKA_MEMORY_BACKEND=redisstack (V0.7.0 default)
|
| 59 |
echo • REDIS_URL=redis://redis:6380/0
|
| 60 |
+
echo.
|
| 61 |
+
echo ⚡ Performance:
|
| 62 |
+
echo • Vector Search: Sub-millisecond latency with HNSW indexing
|
| 63 |
+
echo • Memory Ops: 50,000+ operations/second
|
| 64 |
+
echo • Concurrent: 1,000+ simultaneous searches
|
| 65 |
echo.
|
orka/fork_group_manager.py
CHANGED
|
@@ -193,11 +193,11 @@ class ForkGroupManager:
|
|
| 193 |
|
| 194 |
class SimpleForkGroupManager:
|
| 195 |
"""
|
| 196 |
-
A simple in-memory fork group manager for use with non-Redis backends
|
| 197 |
Provides the same interface as ForkGroupManager but stores data in memory.
|
| 198 |
|
| 199 |
Note: This implementation is not distributed and will not work across multiple
|
| 200 |
-
orchestrator instances. Use only for single-instance deployments
|
| 201 |
"""
|
| 202 |
|
| 203 |
def __init__(self) -> None:
|
|
|
|
| 193 |
|
| 194 |
class SimpleForkGroupManager:
|
| 195 |
"""
|
| 196 |
+
A simple in-memory fork group manager for use with non-Redis backends.
|
| 197 |
Provides the same interface as ForkGroupManager but stores data in memory.
|
| 198 |
|
| 199 |
Note: This implementation is not distributed and will not work across multiple
|
| 200 |
+
orchestrator instances. Use only for single-instance deployments.
|
| 201 |
"""
|
| 202 |
|
| 203 |
def __init__(self) -> None:
|
orka/memory/__init__.py
CHANGED
|
@@ -35,8 +35,6 @@ This package contains specialized components for different aspects of memory man
|
|
| 35 |
:class:`~orka.memory.redisstack_logger.RedisStackMemoryLogger`
|
| 36 |
High-performance RedisStack backend with HNSW vector indexing for semantic search
|
| 37 |
|
| 38 |
-
:class:`~orka.memory.kafka_logger.KafkaMemoryLogger`
|
| 39 |
-
Kafka-based event streaming implementation (optional dependency)
|
| 40 |
|
| 41 |
**Utility Mixins**
|
| 42 |
|
|
@@ -61,8 +59,8 @@ Architecture Benefits
|
|
| 61 |
**Backend Flexibility**
|
| 62 |
Easy to add new storage backends including RedisStack
|
| 63 |
|
| 64 |
-
**
|
| 65 |
-
|
| 66 |
|
| 67 |
**Performance Optimization**
|
| 68 |
Specialized components allow for targeted optimizations including HNSW indexing
|
|
@@ -74,7 +72,7 @@ Usage Patterns
|
|
| 74 |
|
| 75 |
.. code-block:: python
|
| 76 |
|
| 77 |
-
from orka.memory import RedisMemoryLogger, RedisStackMemoryLogger
|
| 78 |
|
| 79 |
# Standard Redis backend
|
| 80 |
redis_logger = RedisMemoryLogger(redis_url="redis://localhost:6380")
|
|
@@ -86,9 +84,6 @@ Usage Patterns
|
|
| 86 |
vector_params={"M": 16, "ef_construction": 200}
|
| 87 |
)
|
| 88 |
|
| 89 |
-
# Kafka backend (if available)
|
| 90 |
-
if KafkaMemoryLogger:
|
| 91 |
-
kafka_logger = KafkaMemoryLogger(bootstrap_servers="localhost:9092")
|
| 92 |
|
| 93 |
**Through Factory Function (Recommended)**
|
| 94 |
|
|
@@ -118,11 +113,9 @@ Modular Components
|
|
| 118 |
* ``base_logger`` - Abstract base class and common functionality
|
| 119 |
* ``redis_logger`` - Redis backend implementation
|
| 120 |
* ``redisstack_logger`` - RedisStack backend with HNSW vector indexing
|
| 121 |
-
* ``kafka_logger`` - Kafka backend implementation (optional)
|
| 122 |
* ``serialization`` - JSON sanitization and processing utilities
|
| 123 |
* ``file_operations`` - File I/O and export functionality
|
| 124 |
* ``compressor`` - Data compression utilities
|
| 125 |
-
* ``schema_manager`` - Schema validation and management
|
| 126 |
|
| 127 |
Performance Characteristics
|
| 128 |
--------------------------
|
|
@@ -213,73 +206,9 @@ except ImportError:
|
|
| 213 |
RedisStackMemoryLogger = _DummyRedisStackMemoryLogger # type: ignore
|
| 214 |
|
| 215 |
|
| 216 |
-
# Import KafkaMemoryLogger if available (optional dependency)
|
| 217 |
-
try:
|
| 218 |
-
from .kafka_logger import KafkaMemoryLogger
|
| 219 |
-
except ImportError:
|
| 220 |
-
# Define a dummy class if Kafka dependencies are not available
|
| 221 |
-
class _DummyKafkaMemoryLogger(BaseMemoryLogger):
|
| 222 |
-
def __init__(self, *args: Any, **kwargs: Any):
|
| 223 |
-
super().__init__(*args, **kwargs)
|
| 224 |
-
raise ImportError("Kafka dependencies not available")
|
| 225 |
-
|
| 226 |
-
def cleanup_expired_memories(self, dry_run: bool = False) -> dict[str, Any]:
|
| 227 |
-
raise NotImplementedError
|
| 228 |
-
|
| 229 |
-
def get_memory_stats(self) -> dict[str, Any]:
|
| 230 |
-
raise NotImplementedError
|
| 231 |
-
|
| 232 |
-
def log(self, *args: Any, **kwargs: Any) -> None:
|
| 233 |
-
raise NotImplementedError
|
| 234 |
-
|
| 235 |
-
def tail(self, count: int = 10) -> list[dict[str, Any]]:
|
| 236 |
-
raise NotImplementedError
|
| 237 |
-
|
| 238 |
-
def hset(self, name: str, key: str, value: str | bytes | int | float) -> int:
|
| 239 |
-
raise NotImplementedError
|
| 240 |
-
|
| 241 |
-
def hget(self, name: str, key: str) -> str | None:
|
| 242 |
-
raise NotImplementedError
|
| 243 |
-
|
| 244 |
-
def hkeys(self, name: str) -> list[str]:
|
| 245 |
-
raise NotImplementedError
|
| 246 |
-
|
| 247 |
-
def hdel(self, name: str, *keys: str) -> int:
|
| 248 |
-
raise NotImplementedError
|
| 249 |
-
|
| 250 |
-
def smembers(self, name: str) -> list[str]:
|
| 251 |
-
raise NotImplementedError
|
| 252 |
-
|
| 253 |
-
def sadd(self, name: str, *values: str) -> int:
|
| 254 |
-
raise NotImplementedError
|
| 255 |
-
|
| 256 |
-
def srem(self, name: str, *values: str) -> int:
|
| 257 |
-
raise NotImplementedError
|
| 258 |
-
|
| 259 |
-
def get(self, key: str) -> str | None:
|
| 260 |
-
raise NotImplementedError
|
| 261 |
-
|
| 262 |
-
def set(self, key: str, value: str | bytes | int | float) -> bool:
|
| 263 |
-
raise NotImplementedError
|
| 264 |
-
|
| 265 |
-
def delete(self, *keys: str) -> int:
|
| 266 |
-
raise NotImplementedError
|
| 267 |
-
|
| 268 |
-
def ensure_index(self) -> bool:
|
| 269 |
-
raise NotImplementedError
|
| 270 |
-
|
| 271 |
-
def log_memory(self, *args: Any, **kwargs: Any) -> str:
|
| 272 |
-
raise NotImplementedError
|
| 273 |
-
|
| 274 |
-
def search_memories(self, *args: Any, **kwargs: Any) -> list[dict[str, Any]]:
|
| 275 |
-
raise NotImplementedError
|
| 276 |
-
|
| 277 |
-
KafkaMemoryLogger = _DummyKafkaMemoryLogger # type: ignore
|
| 278 |
-
|
| 279 |
__all__ = [
|
| 280 |
"BaseMemoryLogger",
|
| 281 |
"FileOperationsMixin",
|
| 282 |
-
"KafkaMemoryLogger",
|
| 283 |
"RedisMemoryLogger",
|
| 284 |
"RedisStackMemoryLogger",
|
| 285 |
"SerializationMixin",
|
|
|
|
| 35 |
:class:`~orka.memory.redisstack_logger.RedisStackMemoryLogger`
|
| 36 |
High-performance RedisStack backend with HNSW vector indexing for semantic search
|
| 37 |
|
|
|
|
|
|
|
| 38 |
|
| 39 |
**Utility Mixins**
|
| 40 |
|
|
|
|
| 59 |
**Backend Flexibility**
|
| 60 |
Easy to add new storage backends including RedisStack
|
| 61 |
|
| 62 |
+
**Modular Design**
|
| 63 |
+
Components can be mixed and matched as needed for different use cases
|
| 64 |
|
| 65 |
**Performance Optimization**
|
| 66 |
Specialized components allow for targeted optimizations including HNSW indexing
|
|
|
|
| 72 |
|
| 73 |
.. code-block:: python
|
| 74 |
|
| 75 |
+
from orka.memory import RedisMemoryLogger, RedisStackMemoryLogger
|
| 76 |
|
| 77 |
# Standard Redis backend
|
| 78 |
redis_logger = RedisMemoryLogger(redis_url="redis://localhost:6380")
|
|
|
|
| 84 |
vector_params={"M": 16, "ef_construction": 200}
|
| 85 |
)
|
| 86 |
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
**Through Factory Function (Recommended)**
|
| 89 |
|
|
|
|
| 113 |
* ``base_logger`` - Abstract base class and common functionality
|
| 114 |
* ``redis_logger`` - Redis backend implementation
|
| 115 |
* ``redisstack_logger`` - RedisStack backend with HNSW vector indexing
|
|
|
|
| 116 |
* ``serialization`` - JSON sanitization and processing utilities
|
| 117 |
* ``file_operations`` - File I/O and export functionality
|
| 118 |
* ``compressor`` - Data compression utilities
|
|
|
|
| 119 |
|
| 120 |
Performance Characteristics
|
| 121 |
--------------------------
|
|
|
|
| 206 |
RedisStackMemoryLogger = _DummyRedisStackMemoryLogger # type: ignore
|
| 207 |
|
| 208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
__all__ = [
|
| 210 |
"BaseMemoryLogger",
|
| 211 |
"FileOperationsMixin",
|
|
|
|
| 212 |
"RedisMemoryLogger",
|
| 213 |
"RedisStackMemoryLogger",
|
| 214 |
"SerializationMixin",
|
orka/memory/base_logger.py
CHANGED
|
@@ -107,7 +107,7 @@ class BaseMemoryLogger(ABC, SerializationMixin, FileOperationsMixin):
|
|
| 107 |
- Vector search capabilities for semantic similarity
|
| 108 |
- Advanced filtering and querying options
|
| 109 |
- Performance optimizations for specific use cases
|
| 110 |
-
- Integration with external systems (Redis,
|
| 111 |
|
| 112 |
Configuration Options
|
| 113 |
--------------------
|
|
|
|
| 107 |
- Vector search capabilities for semantic similarity
|
| 108 |
- Advanced filtering and querying options
|
| 109 |
- Performance optimizations for specific use cases
|
| 110 |
+
- Integration with external systems (Redis, etc.)
|
| 111 |
|
| 112 |
Configuration Options
|
| 113 |
--------------------
|
orka/memory/file_operations.py
CHANGED
|
@@ -59,18 +59,14 @@ class FileOperationsMixin:
|
|
| 59 |
file_path: Path to the output JSON file.
|
| 60 |
"""
|
| 61 |
try:
|
| 62 |
-
#
|
| 63 |
-
if hasattr(self, "
|
| 64 |
try:
|
| 65 |
-
#
|
| 66 |
-
self.
|
| 67 |
-
logger.debug(
|
| 68 |
-
|
| 69 |
-
)
|
| 70 |
-
except Exception as flush_e:
|
| 71 |
-
logger.warning(
|
| 72 |
-
f"Warning: Failed to flush Kafka messages before save: {flush_e!s}",
|
| 73 |
-
)
|
| 74 |
|
| 75 |
# Process memory entries to optimize storage (remove repeated previous_outputs)
|
| 76 |
processed_memory = self._process_memory_for_saving(self.memory)
|
|
|
|
| 59 |
file_path: Path to the output JSON file.
|
| 60 |
"""
|
| 61 |
try:
|
| 62 |
+
# Ensure all pending operations are completed before saving
|
| 63 |
+
if hasattr(self, "redis_client"):
|
| 64 |
try:
|
| 65 |
+
# For Redis backends, ensure connection is stable
|
| 66 |
+
self.redis_client.ping()
|
| 67 |
+
logger.debug("Redis connection verified before save")
|
| 68 |
+
except Exception as ping_e:
|
| 69 |
+
logger.warning(f"Warning: Redis connection issue before save: {ping_e!s}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
# Process memory entries to optimize storage (remove repeated previous_outputs)
|
| 72 |
processed_memory = self._process_memory_for_saving(self.memory)
|
orka/memory/kafka_logger.py
DELETED
|
@@ -1,586 +0,0 @@
|
|
| 1 |
-
"""Kafka memory logger implementation."""
|
| 2 |
-
|
| 3 |
-
import json
|
| 4 |
-
import logging
|
| 5 |
-
import os
|
| 6 |
-
from datetime import UTC, datetime
|
| 7 |
-
from typing import Any, cast
|
| 8 |
-
|
| 9 |
-
import redis
|
| 10 |
-
from redis import Redis
|
| 11 |
-
|
| 12 |
-
from .base_logger import BaseMemoryLogger
|
| 13 |
-
|
| 14 |
-
logger = logging.getLogger(__name__)
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
class KafkaMemoryLogger(BaseMemoryLogger):
|
| 18 |
-
"""Memory logger implementation using Kafka."""
|
| 19 |
-
|
| 20 |
-
def __init__(
|
| 21 |
-
self,
|
| 22 |
-
bootstrap_servers: str = "localhost:9092",
|
| 23 |
-
redis_url: str | None = None,
|
| 24 |
-
stream_key: str = "orka:memory",
|
| 25 |
-
debug_keep_previous_outputs: bool = False,
|
| 26 |
-
decay_config: dict[str, Any] | None = None,
|
| 27 |
-
enable_hnsw: bool = True,
|
| 28 |
-
vector_params: dict[str, Any] | None = None,
|
| 29 |
-
topic_prefix: str = "orka-memory",
|
| 30 |
-
schema_registry_url: str | None = None,
|
| 31 |
-
use_schema_registry: bool = True,
|
| 32 |
-
) -> None:
|
| 33 |
-
"""Initialize the Kafka memory logger."""
|
| 34 |
-
super().__init__(stream_key, debug_keep_previous_outputs, decay_config)
|
| 35 |
-
|
| 36 |
-
self.bootstrap_servers = bootstrap_servers
|
| 37 |
-
self.redis_url = (
|
| 38 |
-
redis_url
|
| 39 |
-
if redis_url is not None
|
| 40 |
-
else os.environ.get("REDIS_URL", "redis://localhost:6380/0")
|
| 41 |
-
)
|
| 42 |
-
self.stream_key = stream_key
|
| 43 |
-
self.debug_keep_previous_outputs = debug_keep_previous_outputs
|
| 44 |
-
self.main_topic = f"{topic_prefix}-events"
|
| 45 |
-
self.memory = []
|
| 46 |
-
self.decay_config = decay_config or {}
|
| 47 |
-
self.schema_registry_url = schema_registry_url or os.getenv(
|
| 48 |
-
"KAFKA_SCHEMA_REGISTRY_URL",
|
| 49 |
-
"http://localhost:8081",
|
| 50 |
-
)
|
| 51 |
-
self.use_schema_registry = use_schema_registry
|
| 52 |
-
|
| 53 |
-
# Initialize Kafka producer
|
| 54 |
-
self._init_kafka_producer()
|
| 55 |
-
|
| 56 |
-
self._redis_memory_logger = None
|
| 57 |
-
|
| 58 |
-
# Create RedisStack logger for enhanced memory operations
|
| 59 |
-
try:
|
| 60 |
-
from .redisstack_logger import RedisStackMemoryLogger
|
| 61 |
-
|
| 62 |
-
self._redis_memory_logger = RedisStackMemoryLogger(
|
| 63 |
-
redis_url=self.redis_url,
|
| 64 |
-
stream_key=stream_key,
|
| 65 |
-
debug_keep_previous_outputs=debug_keep_previous_outputs,
|
| 66 |
-
decay_config=decay_config,
|
| 67 |
-
enable_hnsw=enable_hnsw,
|
| 68 |
-
vector_params=vector_params,
|
| 69 |
-
)
|
| 70 |
-
|
| 71 |
-
# Ensure enhanced index is ready
|
| 72 |
-
self._redis_memory_logger.ensure_index()
|
| 73 |
-
logger.info("✅ Kafka backend using RedisStack for memory operations")
|
| 74 |
-
|
| 75 |
-
except ImportError:
|
| 76 |
-
# Fallback to basic Redis
|
| 77 |
-
self.redis_client = redis.from_url(self.redis_url)
|
| 78 |
-
self._redis_memory_logger = None
|
| 79 |
-
logger.warning("⚠️ RedisStack not available, using basic Redis for memory operations")
|
| 80 |
-
except Exception as e:
|
| 81 |
-
# If RedisStack creation fails for any other reason, fall back to basic Redis
|
| 82 |
-
logger.warning(
|
| 83 |
-
f"⚠️ RedisStack initialization failed ({e}), using basic Redis for memory operations",
|
| 84 |
-
)
|
| 85 |
-
self._redis_memory_logger = None
|
| 86 |
-
|
| 87 |
-
# Initialize basic Redis client as fallback
|
| 88 |
-
self.redis_client = redis.from_url(self.redis_url)
|
| 89 |
-
|
| 90 |
-
def _init_kafka_producer(self):
|
| 91 |
-
"""Initialize the Kafka producer with proper configuration."""
|
| 92 |
-
try:
|
| 93 |
-
from confluent_kafka import Producer
|
| 94 |
-
from confluent_kafka.serialization import StringSerializer
|
| 95 |
-
|
| 96 |
-
# Configure producer with reliability settings
|
| 97 |
-
producer_config = {
|
| 98 |
-
"bootstrap.servers": self.bootstrap_servers,
|
| 99 |
-
"acks": "all", # Wait for all replicas
|
| 100 |
-
"enable.idempotence": True, # Prevent duplicates
|
| 101 |
-
"max.in.flight.requests.per.connection": 5,
|
| 102 |
-
"retries": 5,
|
| 103 |
-
"retry.backoff.ms": 500,
|
| 104 |
-
"compression.type": "lz4",
|
| 105 |
-
"queue.buffering.max.messages": 100000,
|
| 106 |
-
"queue.buffering.max.ms": 100,
|
| 107 |
-
"batch.size": 16384,
|
| 108 |
-
"linger.ms": 5,
|
| 109 |
-
}
|
| 110 |
-
|
| 111 |
-
self.producer = Producer(producer_config)
|
| 112 |
-
self.string_serializer = StringSerializer("utf_8")
|
| 113 |
-
logger.info("✅ Kafka producer initialized with reliability settings")
|
| 114 |
-
|
| 115 |
-
except ImportError:
|
| 116 |
-
logger.error(
|
| 117 |
-
"❌ confluent-kafka not installed. Please install it to use Kafka backend.",
|
| 118 |
-
)
|
| 119 |
-
raise
|
| 120 |
-
|
| 121 |
-
@property
|
| 122 |
-
def redis(self) -> redis.Redis:
|
| 123 |
-
"""Return Redis client - prefer RedisStack client if available."""
|
| 124 |
-
if self._redis_memory_logger:
|
| 125 |
-
_redis: redis.Redis = self._redis_memory_logger.redis
|
| 126 |
-
return _redis
|
| 127 |
-
# Fallback to basic Redis client
|
| 128 |
-
_redis = cast(redis.Redis, self.redis_client)
|
| 129 |
-
return _redis
|
| 130 |
-
|
| 131 |
-
def _store_in_redis(self, event: dict[str, Any], **kwargs: Any) -> None:
|
| 132 |
-
"""Store event using RedisStack logger if available."""
|
| 133 |
-
if self._redis_memory_logger:
|
| 134 |
-
# ✅ Use RedisStack logger for enhanced storage
|
| 135 |
-
self._redis_memory_logger.log(
|
| 136 |
-
agent_id=event["agent_id"],
|
| 137 |
-
event_type=event["event_type"],
|
| 138 |
-
payload=event["payload"],
|
| 139 |
-
step=kwargs.get("step"),
|
| 140 |
-
run_id=kwargs.get("run_id"),
|
| 141 |
-
fork_group=kwargs.get("fork_group"),
|
| 142 |
-
parent=kwargs.get("parent"),
|
| 143 |
-
previous_outputs=kwargs.get("previous_outputs"),
|
| 144 |
-
agent_decay_config=kwargs.get("agent_decay_config"),
|
| 145 |
-
log_type=kwargs.get("log_type", "log"),
|
| 146 |
-
)
|
| 147 |
-
else:
|
| 148 |
-
# Fallback to basic Redis streams
|
| 149 |
-
try:
|
| 150 |
-
# Prepare the Redis entry
|
| 151 |
-
redis_entry = {
|
| 152 |
-
"agent_id": event["agent_id"],
|
| 153 |
-
"event_type": event["event_type"],
|
| 154 |
-
"timestamp": event.get("timestamp"),
|
| 155 |
-
"run_id": kwargs.get("run_id", "default"),
|
| 156 |
-
"step": str(kwargs.get("step", -1)),
|
| 157 |
-
"payload": json.dumps(event["payload"]),
|
| 158 |
-
}
|
| 159 |
-
|
| 160 |
-
# Add decay metadata if available
|
| 161 |
-
if hasattr(self, "decay_config") and self.decay_config:
|
| 162 |
-
decay_metadata = self._generate_decay_metadata(event)
|
| 163 |
-
redis_entry.update(decay_metadata)
|
| 164 |
-
|
| 165 |
-
# Write to Redis stream
|
| 166 |
-
self.redis_client.xadd(self.stream_key, redis_entry)
|
| 167 |
-
logger.debug(f"- Stored event in basic Redis stream: {self.stream_key}")
|
| 168 |
-
|
| 169 |
-
except Exception as e:
|
| 170 |
-
logger.error(f"Failed to store event in basic Redis: {e}")
|
| 171 |
-
|
| 172 |
-
def _generate_decay_metadata(self, event: dict[str, Any]) -> dict[str, Any]:
|
| 173 |
-
"""Generate decay metadata for an event."""
|
| 174 |
-
if not self.decay_config or not self.decay_config.get("enabled"):
|
| 175 |
-
return {}
|
| 176 |
-
|
| 177 |
-
current_time = int(datetime.now(UTC).timestamp() * 1000)
|
| 178 |
-
decay_hours = self.decay_config.get("default_long_term_hours", 24.0)
|
| 179 |
-
|
| 180 |
-
return {
|
| 181 |
-
"orka_memory_type": "long_term",
|
| 182 |
-
"orka_memory_category": "stored",
|
| 183 |
-
"orka_expire_time": current_time + int(decay_hours * 3600 * 1000),
|
| 184 |
-
"orka_importance_score": 1.0,
|
| 185 |
-
}
|
| 186 |
-
|
| 187 |
-
def log(
|
| 188 |
-
self,
|
| 189 |
-
agent_id: str,
|
| 190 |
-
event_type: str,
|
| 191 |
-
payload: dict[str, Any],
|
| 192 |
-
step: int | None = None,
|
| 193 |
-
run_id: str | None = None,
|
| 194 |
-
fork_group: str | None = None,
|
| 195 |
-
parent: str | None = None,
|
| 196 |
-
previous_outputs: dict[str, Any] | None = None,
|
| 197 |
-
agent_decay_config: dict[str, Any] | None = None,
|
| 198 |
-
log_type: str = "log",
|
| 199 |
-
) -> None:
|
| 200 |
-
"""Log an event to both Kafka and Redis."""
|
| 201 |
-
if not agent_id:
|
| 202 |
-
raise ValueError("Event must contain 'agent_id'")
|
| 203 |
-
|
| 204 |
-
# Create a copy of the payload to avoid modifying the original
|
| 205 |
-
safe_payload = self._sanitize_for_json(payload)
|
| 206 |
-
|
| 207 |
-
# Determine which decay config to use
|
| 208 |
-
effective_decay_config = self.decay_config.copy() if self.decay_config else {}
|
| 209 |
-
if agent_decay_config:
|
| 210 |
-
# Merge agent-specific decay config with global config
|
| 211 |
-
effective_decay_config.update(agent_decay_config)
|
| 212 |
-
|
| 213 |
-
# Calculate decay metadata if decay is enabled
|
| 214 |
-
decay_metadata = {}
|
| 215 |
-
decay_enabled = effective_decay_config.get("enabled", False)
|
| 216 |
-
|
| 217 |
-
if decay_enabled:
|
| 218 |
-
decay_metadata = self._generate_decay_metadata(
|
| 219 |
-
{
|
| 220 |
-
"agent_id": agent_id,
|
| 221 |
-
"event_type": event_type,
|
| 222 |
-
"payload": safe_payload,
|
| 223 |
-
"timestamp": int(datetime.now(UTC).timestamp() * 1000),
|
| 224 |
-
},
|
| 225 |
-
)
|
| 226 |
-
|
| 227 |
-
# Store in memory buffer
|
| 228 |
-
event_data = {
|
| 229 |
-
"agent_id": agent_id,
|
| 230 |
-
"event_type": event_type,
|
| 231 |
-
"payload": safe_payload,
|
| 232 |
-
"timestamp": int(datetime.now(UTC).timestamp() * 1000),
|
| 233 |
-
"run_id": run_id or "default",
|
| 234 |
-
"step": step or -1,
|
| 235 |
-
}
|
| 236 |
-
event_data.update(decay_metadata)
|
| 237 |
-
self.memory.append(event_data)
|
| 238 |
-
|
| 239 |
-
# Store in Redis first
|
| 240 |
-
self._store_in_redis(
|
| 241 |
-
event_data,
|
| 242 |
-
step=step,
|
| 243 |
-
run_id=run_id,
|
| 244 |
-
fork_group=fork_group,
|
| 245 |
-
parent=parent,
|
| 246 |
-
previous_outputs=previous_outputs,
|
| 247 |
-
agent_decay_config=agent_decay_config,
|
| 248 |
-
log_type=log_type,
|
| 249 |
-
)
|
| 250 |
-
|
| 251 |
-
# Then send to Kafka
|
| 252 |
-
self._send_to_kafka(event_data)
|
| 253 |
-
|
| 254 |
-
def _send_to_kafka(self, event_data: dict[str, Any]) -> None:
|
| 255 |
-
"""Send event data to Kafka."""
|
| 256 |
-
try:
|
| 257 |
-
# Prepare Kafka message
|
| 258 |
-
kafka_message = event_data.copy()
|
| 259 |
-
|
| 260 |
-
# Serialize and send
|
| 261 |
-
message_str = json.dumps(kafka_message)
|
| 262 |
-
self.producer.produce(
|
| 263 |
-
self.main_topic,
|
| 264 |
-
value=self.string_serializer(message_str),
|
| 265 |
-
on_delivery=self._delivery_callback,
|
| 266 |
-
)
|
| 267 |
-
self.producer.poll(0) # Trigger delivery reports
|
| 268 |
-
|
| 269 |
-
except Exception as e:
|
| 270 |
-
logger.error(f"Failed to send event to Kafka: {e}")
|
| 271 |
-
# Continue execution - Redis storage is our source of truth
|
| 272 |
-
|
| 273 |
-
def _delivery_callback(self, err: Any, msg: Any) -> None:
|
| 274 |
-
"""Handle Kafka message delivery confirmation."""
|
| 275 |
-
if err:
|
| 276 |
-
logger.error(f"Message delivery failed: {err}")
|
| 277 |
-
else:
|
| 278 |
-
logger.debug(f"- Message delivered to {msg.topic()} [{msg.partition()}]")
|
| 279 |
-
|
| 280 |
-
def tail(self, count: int = 10) -> list[dict[str, Any]]:
|
| 281 |
-
"""Get the last n events from Redis."""
|
| 282 |
-
if self._redis_memory_logger:
|
| 283 |
-
return self._redis_memory_logger.tail(count)
|
| 284 |
-
|
| 285 |
-
try:
|
| 286 |
-
# Get stream entries
|
| 287 |
-
entries = self.redis_client.xrevrange(self.stream_key, count=count)
|
| 288 |
-
result = []
|
| 289 |
-
|
| 290 |
-
for _, data in entries:
|
| 291 |
-
entry = {
|
| 292 |
-
"agent_id": data.get(b"agent_id", b"").decode(),
|
| 293 |
-
"event_type": data.get(b"event_type", b"").decode(),
|
| 294 |
-
"timestamp": int(data.get(b"timestamp", b"0").decode()),
|
| 295 |
-
"run_id": data.get(b"run_id", b"default").decode(),
|
| 296 |
-
"step": int(data.get(b"step", b"-1").decode()),
|
| 297 |
-
}
|
| 298 |
-
|
| 299 |
-
try:
|
| 300 |
-
entry["payload"] = json.loads(data.get(b"payload", b"{}").decode())
|
| 301 |
-
except json.JSONDecodeError:
|
| 302 |
-
entry["payload"] = {}
|
| 303 |
-
|
| 304 |
-
result.append(entry)
|
| 305 |
-
|
| 306 |
-
return result
|
| 307 |
-
|
| 308 |
-
except Exception as e:
|
| 309 |
-
logger.error(f"Failed to tail Redis stream: {e}")
|
| 310 |
-
return []
|
| 311 |
-
|
| 312 |
-
def get(self, key: str) -> str | None:
|
| 313 |
-
"""Get a value from Redis."""
|
| 314 |
-
if self._redis_memory_logger:
|
| 315 |
-
result = self._redis_memory_logger.get(key)
|
| 316 |
-
if isinstance(result, bytes):
|
| 317 |
-
return result.decode() # type: ignore
|
| 318 |
-
return result if isinstance(result, str) else None
|
| 319 |
-
try:
|
| 320 |
-
value = self.redis_client.get(key)
|
| 321 |
-
if isinstance(value, bytes):
|
| 322 |
-
return value.decode()
|
| 323 |
-
return value if isinstance(value, str) else None
|
| 324 |
-
except Exception as e:
|
| 325 |
-
logger.error(f"Failed to get key {key}: {e}")
|
| 326 |
-
return None
|
| 327 |
-
|
| 328 |
-
def set(self, key: str, value: str | bytes | int | float) -> bool:
|
| 329 |
-
"""Set a value in Redis."""
|
| 330 |
-
if self._redis_memory_logger:
|
| 331 |
-
return self._redis_memory_logger.set(key, value)
|
| 332 |
-
try:
|
| 333 |
-
return bool(self.redis_client.set(key, value))
|
| 334 |
-
except Exception as e:
|
| 335 |
-
logger.error(f"Failed to set key {key}: {e}")
|
| 336 |
-
return False
|
| 337 |
-
|
| 338 |
-
def delete(self, *keys: str) -> int:
|
| 339 |
-
"""Delete keys from Redis."""
|
| 340 |
-
if self._redis_memory_logger:
|
| 341 |
-
return self._redis_memory_logger.delete(*keys)
|
| 342 |
-
try:
|
| 343 |
-
return self.redis_client.delete(*keys)
|
| 344 |
-
except Exception as e:
|
| 345 |
-
logger.error(f"Failed to delete keys {keys}: {e}")
|
| 346 |
-
return 0
|
| 347 |
-
|
| 348 |
-
def hset(self, name: str, key: str, value: str | bytes | int | float) -> int:
|
| 349 |
-
"""Set a hash field in Redis."""
|
| 350 |
-
if self._redis_memory_logger:
|
| 351 |
-
return self._redis_memory_logger.hset(name, key, value)
|
| 352 |
-
try:
|
| 353 |
-
return self.redis_client.hset(name, key, value)
|
| 354 |
-
except Exception as e:
|
| 355 |
-
logger.error(f"Failed to hset {name}.{key}: {e}")
|
| 356 |
-
return 0
|
| 357 |
-
|
| 358 |
-
def hget(self, name: str, key: str) -> str | None:
|
| 359 |
-
"""Get a hash field from Redis."""
|
| 360 |
-
if self._redis_memory_logger:
|
| 361 |
-
result = self._redis_memory_logger.hget(name, key)
|
| 362 |
-
if isinstance(result, bytes):
|
| 363 |
-
return result.decode() # type: ignore
|
| 364 |
-
return result if isinstance(result, str) else None
|
| 365 |
-
try:
|
| 366 |
-
value = self.redis_client.hget(name, key)
|
| 367 |
-
if isinstance(value, bytes):
|
| 368 |
-
return value.decode()
|
| 369 |
-
return value if isinstance(value, str) else None
|
| 370 |
-
except Exception as e:
|
| 371 |
-
logger.error(f"Failed to hget {name}.{key}: {e}")
|
| 372 |
-
return None
|
| 373 |
-
|
| 374 |
-
def hdel(self, name: str, *keys: str) -> int:
|
| 375 |
-
"""Delete fields from a hash structure."""
|
| 376 |
-
if self._redis_memory_logger:
|
| 377 |
-
return self._redis_memory_logger.hdel(name, *keys)
|
| 378 |
-
try:
|
| 379 |
-
return self.redis_client.hdel(name, *keys)
|
| 380 |
-
except Exception as e:
|
| 381 |
-
logger.error(f"Failed to hdel {name}.{keys}: {e}")
|
| 382 |
-
return 0
|
| 383 |
-
|
| 384 |
-
def hkeys(self, name: str) -> list[str]:
|
| 385 |
-
"""Get all hash fields from Redis."""
|
| 386 |
-
if self._redis_memory_logger:
|
| 387 |
-
return self._redis_memory_logger.hkeys(name)
|
| 388 |
-
try:
|
| 389 |
-
keys = self.redis_client.hkeys(name)
|
| 390 |
-
return [k.decode() for k in keys]
|
| 391 |
-
except Exception as e:
|
| 392 |
-
logger.error(f"Failed to get hkeys for {name}: {e}")
|
| 393 |
-
return []
|
| 394 |
-
|
| 395 |
-
def sadd(self, name: str, *values: str) -> int:
|
| 396 |
-
"""Add members to a set."""
|
| 397 |
-
if self._redis_memory_logger:
|
| 398 |
-
return self._redis_memory_logger.sadd(name, *values)
|
| 399 |
-
try:
|
| 400 |
-
return self.redis_client.sadd(name, *values)
|
| 401 |
-
except Exception as e:
|
| 402 |
-
logger.error(f"Failed to sadd to {name}: {e}")
|
| 403 |
-
return 0
|
| 404 |
-
|
| 405 |
-
def srem(self, name: str, *values: str) -> int:
|
| 406 |
-
"""Remove members from a set."""
|
| 407 |
-
if self._redis_memory_logger:
|
| 408 |
-
return self._redis_memory_logger.srem(name, *values)
|
| 409 |
-
try:
|
| 410 |
-
return self.redis_client.srem(name, *values)
|
| 411 |
-
except Exception as e:
|
| 412 |
-
logger.error(f"Failed to srem from {name}: {e}")
|
| 413 |
-
return 0
|
| 414 |
-
|
| 415 |
-
def smembers(self, name: str) -> list[str]:
|
| 416 |
-
"""Get all members of a Redis set."""
|
| 417 |
-
if self._redis_memory_logger:
|
| 418 |
-
return self._redis_memory_logger.smembers(name)
|
| 419 |
-
try:
|
| 420 |
-
members = self.redis_client.smembers(name)
|
| 421 |
-
return [m.decode() for m in members]
|
| 422 |
-
except Exception as e:
|
| 423 |
-
logger.error(f"Failed to get smembers for {name}: {e}")
|
| 424 |
-
return []
|
| 425 |
-
|
| 426 |
-
def cleanup_expired_memories(self, dry_run: bool = False) -> dict[str, Any]:
|
| 427 |
-
"""Clean up expired memories."""
|
| 428 |
-
if self._redis_memory_logger:
|
| 429 |
-
return self._redis_memory_logger.cleanup_expired_memories(dry_run=dry_run)
|
| 430 |
-
try:
|
| 431 |
-
# Get all memory keys
|
| 432 |
-
memory_pattern = "orka_memory:*"
|
| 433 |
-
keys = self.redis_client.keys(memory_pattern)
|
| 434 |
-
cleaned = 0
|
| 435 |
-
|
| 436 |
-
for key in keys:
|
| 437 |
-
try:
|
| 438 |
-
# Get expiry time if set
|
| 439 |
-
expire_time_bytes = self.redis_client.hget(key, "orka_expire_time")
|
| 440 |
-
if expire_time_bytes:
|
| 441 |
-
expire_time = int(expire_time_bytes.decode())
|
| 442 |
-
current_time = int(datetime.now(UTC).timestamp() * 1000)
|
| 443 |
-
|
| 444 |
-
if current_time > expire_time:
|
| 445 |
-
if not dry_run:
|
| 446 |
-
self.redis_client.delete(key)
|
| 447 |
-
cleaned += 1
|
| 448 |
-
|
| 449 |
-
except Exception as e:
|
| 450 |
-
logger.warning(f"Error checking: {e}")
|
| 451 |
-
continue
|
| 452 |
-
|
| 453 |
-
return {
|
| 454 |
-
"cleaned": cleaned,
|
| 455 |
-
"total_checked": len(keys),
|
| 456 |
-
"expired_found": cleaned,
|
| 457 |
-
"dry_run": dry_run,
|
| 458 |
-
"cleanup_type": "kafka_redis_fallback",
|
| 459 |
-
"errors": [],
|
| 460 |
-
}
|
| 461 |
-
|
| 462 |
-
except Exception as e:
|
| 463 |
-
logger.error(f"Failed to cleanup expired memories: {e}")
|
| 464 |
-
return {
|
| 465 |
-
"cleaned": 0,
|
| 466 |
-
"total_checked": 0,
|
| 467 |
-
"expired_found": 0,
|
| 468 |
-
"dry_run": dry_run,
|
| 469 |
-
"cleanup_type": "kafka_redis_fallback",
|
| 470 |
-
"errors": [str(e)],
|
| 471 |
-
}
|
| 472 |
-
|
| 473 |
-
def get_memory_stats(self) -> dict[str, Any]:
|
| 474 |
-
"""Get memory statistics."""
|
| 475 |
-
if self._redis_memory_logger:
|
| 476 |
-
return self._redis_memory_logger.get_memory_stats()
|
| 477 |
-
try:
|
| 478 |
-
memory_pattern = "orka_memory:*"
|
| 479 |
-
keys = self.redis_client.keys(memory_pattern)
|
| 480 |
-
total_memories = len(keys)
|
| 481 |
-
|
| 482 |
-
# Count memories by type
|
| 483 |
-
memory_types: dict[str, int] = {}
|
| 484 |
-
expired_count = 0
|
| 485 |
-
current_time = int(datetime.now(UTC).timestamp() * 1000)
|
| 486 |
-
|
| 487 |
-
for key in keys:
|
| 488 |
-
try:
|
| 489 |
-
memory_data = self.redis_client.hgetall(key)
|
| 490 |
-
|
| 491 |
-
# Count by memory type
|
| 492 |
-
memory_type = memory_data.get(b"memory_type", b"unknown").decode()
|
| 493 |
-
memory_types[memory_type] = memory_types.get(memory_type, 0) + 1
|
| 494 |
-
|
| 495 |
-
# Check expiry
|
| 496 |
-
expire_time_bytes = memory_data.get(b"orka_expire_time")
|
| 497 |
-
if expire_time_bytes:
|
| 498 |
-
expire_time = int(expire_time_bytes.decode())
|
| 499 |
-
if current_time > expire_time:
|
| 500 |
-
expired_count += 1
|
| 501 |
-
|
| 502 |
-
except Exception as e:
|
| 503 |
-
logger.warning(f"Error processing memory: {e}")
|
| 504 |
-
continue
|
| 505 |
-
|
| 506 |
-
return {
|
| 507 |
-
"total_memories": total_memories,
|
| 508 |
-
"memory_types": memory_types,
|
| 509 |
-
"expired_count": expired_count,
|
| 510 |
-
"backend": "kafka+redis",
|
| 511 |
-
"timestamp": current_time,
|
| 512 |
-
}
|
| 513 |
-
|
| 514 |
-
except Exception as e:
|
| 515 |
-
logger.error(f"Failed to get memory stats: {e}")
|
| 516 |
-
return {
|
| 517 |
-
"error": str(e),
|
| 518 |
-
"backend": "kafka+redis",
|
| 519 |
-
"timestamp": int(datetime.now(UTC).timestamp() * 1000),
|
| 520 |
-
}
|
| 521 |
-
|
| 522 |
-
def close(self):
|
| 523 |
-
"""Close all connections."""
|
| 524 |
-
try:
|
| 525 |
-
if hasattr(self, "producer"):
|
| 526 |
-
self.producer.flush() # Ensure all messages are delivered
|
| 527 |
-
if self._redis_memory_logger:
|
| 528 |
-
self._redis_memory_logger.close()
|
| 529 |
-
else:
|
| 530 |
-
self.redis_client.close()
|
| 531 |
-
except Exception as e:
|
| 532 |
-
logger.error(f"Error closing connections: {e}")
|
| 533 |
-
|
| 534 |
-
def search_memories(
|
| 535 |
-
self,
|
| 536 |
-
query: str,
|
| 537 |
-
num_results: int = 10,
|
| 538 |
-
trace_id: str | None = None,
|
| 539 |
-
node_id: str | None = None,
|
| 540 |
-
memory_type: str | None = None,
|
| 541 |
-
min_importance: float | None = None,
|
| 542 |
-
log_type: str = "memory",
|
| 543 |
-
namespace: str | None = None,
|
| 544 |
-
) -> list[dict[str, Any]]:
|
| 545 |
-
"""Search memories using RedisStack if available."""
|
| 546 |
-
if self._redis_memory_logger:
|
| 547 |
-
return self._redis_memory_logger.search_memories(
|
| 548 |
-
query=query,
|
| 549 |
-
num_results=num_results,
|
| 550 |
-
trace_id=trace_id,
|
| 551 |
-
node_id=node_id,
|
| 552 |
-
memory_type=memory_type,
|
| 553 |
-
min_importance=min_importance,
|
| 554 |
-
log_type=log_type,
|
| 555 |
-
namespace=namespace,
|
| 556 |
-
)
|
| 557 |
-
return [] # Return empty list when RedisStack is not available
|
| 558 |
-
|
| 559 |
-
def log_memory(
|
| 560 |
-
self,
|
| 561 |
-
content: str,
|
| 562 |
-
node_id: str,
|
| 563 |
-
trace_id: str,
|
| 564 |
-
metadata: dict[str, Any] | None = None,
|
| 565 |
-
importance_score: float = 1.0,
|
| 566 |
-
memory_type: str = "short_term",
|
| 567 |
-
expiry_hours: float | None = None,
|
| 568 |
-
) -> str:
|
| 569 |
-
"""Store memory with vector embedding."""
|
| 570 |
-
if self._redis_memory_logger:
|
| 571 |
-
return self._redis_memory_logger.log_memory(
|
| 572 |
-
content=content,
|
| 573 |
-
node_id=node_id,
|
| 574 |
-
trace_id=trace_id,
|
| 575 |
-
metadata=metadata,
|
| 576 |
-
importance_score=importance_score,
|
| 577 |
-
memory_type=memory_type,
|
| 578 |
-
expiry_hours=expiry_hours,
|
| 579 |
-
)
|
| 580 |
-
return ""
|
| 581 |
-
|
| 582 |
-
def ensure_index(self) -> bool:
|
| 583 |
-
"""Ensure the enhanced memory index exists."""
|
| 584 |
-
if self._redis_memory_logger:
|
| 585 |
-
return self._redis_memory_logger.ensure_index()
|
| 586 |
-
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orka/memory/schema_manager.py
DELETED
|
@@ -1,321 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Schema management for OrKa memory entries.
|
| 3 |
-
Provides Avro and Protobuf serialization with Schema Registry integration.
|
| 4 |
-
"""
|
| 5 |
-
|
| 6 |
-
import json
|
| 7 |
-
import logging
|
| 8 |
-
import os
|
| 9 |
-
from dataclasses import dataclass
|
| 10 |
-
from enum import Enum
|
| 11 |
-
from typing import TYPE_CHECKING, Any
|
| 12 |
-
|
| 13 |
-
# Always import SerializationContext for type hints
|
| 14 |
-
if TYPE_CHECKING:
|
| 15 |
-
from confluent_kafka.serialization import MessageField, SerializationContext
|
| 16 |
-
|
| 17 |
-
try:
|
| 18 |
-
from confluent_kafka.schema_registry import SchemaRegistryClient
|
| 19 |
-
from confluent_kafka.schema_registry.avro import AvroDeserializer, AvroSerializer
|
| 20 |
-
from confluent_kafka.serialization import MessageField, SerializationContext
|
| 21 |
-
|
| 22 |
-
AVRO_AVAILABLE = True
|
| 23 |
-
except ImportError:
|
| 24 |
-
AVRO_AVAILABLE = False
|
| 25 |
-
logging.warning(
|
| 26 |
-
"Avro dependencies not available. Install with: pip install confluent-kafka[avro]",
|
| 27 |
-
)
|
| 28 |
-
|
| 29 |
-
try:
|
| 30 |
-
import google.protobuf # type: ignore [import-untyped, unused-ignore]
|
| 31 |
-
from confluent_kafka.schema_registry.protobuf import (
|
| 32 |
-
ProtobufDeserializer,
|
| 33 |
-
ProtobufSerializer,
|
| 34 |
-
)
|
| 35 |
-
|
| 36 |
-
PROTOBUF_AVAILABLE = True
|
| 37 |
-
except ImportError:
|
| 38 |
-
PROTOBUF_AVAILABLE = False
|
| 39 |
-
logging.warning(
|
| 40 |
-
"Protobuf dependencies not available. Install with: pip install confluent-kafka[protobuf]",
|
| 41 |
-
)
|
| 42 |
-
|
| 43 |
-
logger = logging.getLogger(__name__)
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
class SchemaFormat(Enum):
|
| 47 |
-
AVRO = "avro"
|
| 48 |
-
PROTOBUF = "protobuf"
|
| 49 |
-
JSON = "json" # Fallback for development
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
@dataclass
|
| 53 |
-
class SchemaConfig:
|
| 54 |
-
registry_url: str | None
|
| 55 |
-
format: SchemaFormat = SchemaFormat.AVRO
|
| 56 |
-
schemas_dir: str = "orka/schemas"
|
| 57 |
-
subject_name_strategy: str = (
|
| 58 |
-
"TopicNameStrategy" # TopicNameStrategy, RecordNameStrategy, TopicRecordNameStrategy
|
| 59 |
-
)
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
class SchemaManager:
|
| 63 |
-
"""Manages schema serialization/deserialization for OrKa memory entries."""
|
| 64 |
-
|
| 65 |
-
def __init__(self, config: SchemaConfig):
|
| 66 |
-
self.config = config
|
| 67 |
-
self.registry_client = None
|
| 68 |
-
self.serializers: dict[str, Any] = {}
|
| 69 |
-
self.deserializers: dict[str, Any] = {}
|
| 70 |
-
self.schema_cache: dict[str, str] = {} # Cache for loaded schemas
|
| 71 |
-
|
| 72 |
-
if config.format != SchemaFormat.JSON:
|
| 73 |
-
self._init_schema_registry()
|
| 74 |
-
|
| 75 |
-
def _init_schema_registry(self):
|
| 76 |
-
"""Initialize connection to Schema Registry."""
|
| 77 |
-
if not AVRO_AVAILABLE and not PROTOBUF_AVAILABLE:
|
| 78 |
-
raise RuntimeError(
|
| 79 |
-
"Neither Avro nor Protobuf dependencies are available. Please install: pip install orka-reasoning[schema]",
|
| 80 |
-
)
|
| 81 |
-
|
| 82 |
-
try:
|
| 83 |
-
# Import here to avoid issues when dependencies aren't available
|
| 84 |
-
from confluent_kafka.schema_registry import SchemaRegistryClient
|
| 85 |
-
|
| 86 |
-
self.registry_client = SchemaRegistryClient(
|
| 87 |
-
{"url": self.config.registry_url},
|
| 88 |
-
)
|
| 89 |
-
logger.info(f"Connected to Schema Registry at {self.config.registry_url}")
|
| 90 |
-
except Exception as e:
|
| 91 |
-
logger.error(f"Failed to connect to Schema Registry: {e}")
|
| 92 |
-
raise
|
| 93 |
-
|
| 94 |
-
def _load_avro_schema(self, schema_name: str) -> str:
|
| 95 |
-
"""Load Avro schema from file."""
|
| 96 |
-
if schema_name in self.schema_cache:
|
| 97 |
-
return self.schema_cache[schema_name]
|
| 98 |
-
|
| 99 |
-
schema_path = os.path.join(
|
| 100 |
-
self.config.schemas_dir,
|
| 101 |
-
"avro",
|
| 102 |
-
f"{schema_name}.avsc",
|
| 103 |
-
)
|
| 104 |
-
try:
|
| 105 |
-
with open(schema_path) as f:
|
| 106 |
-
schema_str = f.read()
|
| 107 |
-
self.schema_cache[schema_name] = schema_str
|
| 108 |
-
return schema_str
|
| 109 |
-
except FileNotFoundError:
|
| 110 |
-
raise FileNotFoundError(f"Avro schema not found: {schema_path}")
|
| 111 |
-
|
| 112 |
-
def _load_protobuf_schema(self, schema_name: str) -> str:
|
| 113 |
-
"""Load Protobuf schema from file."""
|
| 114 |
-
if schema_name in self.schema_cache:
|
| 115 |
-
return self.schema_cache[schema_name]
|
| 116 |
-
|
| 117 |
-
schema_path = os.path.join(
|
| 118 |
-
self.config.schemas_dir,
|
| 119 |
-
"protobuf",
|
| 120 |
-
f"{schema_name}.proto",
|
| 121 |
-
)
|
| 122 |
-
try:
|
| 123 |
-
with open(schema_path) as f:
|
| 124 |
-
schema_str = f.read()
|
| 125 |
-
self.schema_cache[schema_name] = schema_str
|
| 126 |
-
return schema_str
|
| 127 |
-
except FileNotFoundError:
|
| 128 |
-
raise FileNotFoundError(f"Protobuf schema not found: {schema_path}")
|
| 129 |
-
|
| 130 |
-
def get_serializer(self, topic: str, schema_name: str = "memory_entry") -> Any:
|
| 131 |
-
"""Get serializer for a topic."""
|
| 132 |
-
cache_key = f"{topic}_{schema_name}_serializer"
|
| 133 |
-
|
| 134 |
-
if cache_key in self.serializers:
|
| 135 |
-
return self.serializers[cache_key]
|
| 136 |
-
|
| 137 |
-
if self.config.format == SchemaFormat.AVRO:
|
| 138 |
-
if not AVRO_AVAILABLE:
|
| 139 |
-
raise RuntimeError("Avro dependencies not available")
|
| 140 |
-
|
| 141 |
-
schema_str = self._load_avro_schema(schema_name)
|
| 142 |
-
from confluent_kafka.schema_registry.avro import AvroSerializer
|
| 143 |
-
|
| 144 |
-
serializer = AvroSerializer(
|
| 145 |
-
self.registry_client,
|
| 146 |
-
schema_str,
|
| 147 |
-
self._memory_to_dict,
|
| 148 |
-
)
|
| 149 |
-
|
| 150 |
-
elif self.config.format == SchemaFormat.PROTOBUF:
|
| 151 |
-
if not PROTOBUF_AVAILABLE:
|
| 152 |
-
raise RuntimeError("Protobuf dependencies not available")
|
| 153 |
-
|
| 154 |
-
# For Protobuf, we'd need the compiled proto class
|
| 155 |
-
# This is a placeholder - you'd import your generated proto classes
|
| 156 |
-
raise NotImplementedError("Protobuf serializer not fully implemented yet")
|
| 157 |
-
|
| 158 |
-
else: # JSON fallback
|
| 159 |
-
serializer = self._json_serializer
|
| 160 |
-
|
| 161 |
-
self.serializers[cache_key] = serializer
|
| 162 |
-
return serializer
|
| 163 |
-
|
| 164 |
-
def get_deserializer(self, topic: str, schema_name: str = "memory_entry") -> Any:
|
| 165 |
-
"""Get deserializer for a topic."""
|
| 166 |
-
cache_key = f"{topic}_{schema_name}_deserializer"
|
| 167 |
-
|
| 168 |
-
if cache_key in self.deserializers:
|
| 169 |
-
return self.deserializers[cache_key]
|
| 170 |
-
|
| 171 |
-
if self.config.format == SchemaFormat.AVRO:
|
| 172 |
-
if not AVRO_AVAILABLE:
|
| 173 |
-
raise RuntimeError("Avro dependencies not available")
|
| 174 |
-
|
| 175 |
-
schema_str = self._load_avro_schema(schema_name)
|
| 176 |
-
from confluent_kafka.schema_registry.avro import AvroDeserializer
|
| 177 |
-
|
| 178 |
-
deserializer = AvroDeserializer(
|
| 179 |
-
self.registry_client,
|
| 180 |
-
schema_str,
|
| 181 |
-
self._dict_to_memory,
|
| 182 |
-
)
|
| 183 |
-
|
| 184 |
-
elif self.config.format == SchemaFormat.PROTOBUF:
|
| 185 |
-
if not PROTOBUF_AVAILABLE:
|
| 186 |
-
raise RuntimeError("Protobuf dependencies not available")
|
| 187 |
-
|
| 188 |
-
raise NotImplementedError("Protobuf deserializer not fully implemented yet")
|
| 189 |
-
|
| 190 |
-
else: # JSON fallback
|
| 191 |
-
deserializer = self._json_deserializer
|
| 192 |
-
|
| 193 |
-
self.deserializers[cache_key] = deserializer
|
| 194 |
-
return deserializer
|
| 195 |
-
|
| 196 |
-
def _memory_to_dict(self, obj: dict[str, Any], ctx: "SerializationContext") -> dict[str, Any]:
|
| 197 |
-
"""Convert memory object to dict for serialization."""
|
| 198 |
-
# Ensure metadata field exists with default values
|
| 199 |
-
if "metadata" not in obj:
|
| 200 |
-
obj["metadata"] = {
|
| 201 |
-
"source": "",
|
| 202 |
-
"timestamp": "",
|
| 203 |
-
"category": "",
|
| 204 |
-
"tags": [],
|
| 205 |
-
"confidence": 0.0, # Default confidence score
|
| 206 |
-
"reason": "",
|
| 207 |
-
"fact": "",
|
| 208 |
-
"agent_id": "",
|
| 209 |
-
"query": "",
|
| 210 |
-
"vector_embedding": [],
|
| 211 |
-
}
|
| 212 |
-
return obj
|
| 213 |
-
|
| 214 |
-
def _dict_to_memory(self, obj: dict[str, Any], ctx: "SerializationContext") -> dict[str, Any]:
|
| 215 |
-
"""Convert dict to memory object after deserialization."""
|
| 216 |
-
return obj
|
| 217 |
-
|
| 218 |
-
def _json_serializer(
|
| 219 |
-
self,
|
| 220 |
-
obj: dict[str, Any],
|
| 221 |
-
ctx: "SerializationContext",
|
| 222 |
-
) -> bytes:
|
| 223 |
-
"""Fallback JSON serializer."""
|
| 224 |
-
return json.dumps(obj).encode("utf-8")
|
| 225 |
-
|
| 226 |
-
def _json_deserializer(
|
| 227 |
-
self,
|
| 228 |
-
data: bytes,
|
| 229 |
-
ctx: "SerializationContext",
|
| 230 |
-
) -> dict[str, Any]:
|
| 231 |
-
"""Fallback JSON deserializer."""
|
| 232 |
-
result: dict[str, Any] = json.loads(data.decode("utf-8"))
|
| 233 |
-
return result
|
| 234 |
-
|
| 235 |
-
def _check_registry(self) -> None:
|
| 236 |
-
"""Check if registry client is initialized."""
|
| 237 |
-
if self.registry_client is None:
|
| 238 |
-
logger.error("Schema Registry not initialized")
|
| 239 |
-
raise RuntimeError("Schema Registry not initialized")
|
| 240 |
-
|
| 241 |
-
def register_schema(self, subject: str, schema_name: str) -> int:
|
| 242 |
-
"""Register a schema with the Schema Registry."""
|
| 243 |
-
self._check_registry()
|
| 244 |
-
registry = self.registry_client
|
| 245 |
-
assert registry is not None # Help mypy understand registry can't be None
|
| 246 |
-
|
| 247 |
-
try: # type: ignore[unreachable]
|
| 248 |
-
if self.config.format == SchemaFormat.AVRO:
|
| 249 |
-
schema_str = self._load_avro_schema(schema_name)
|
| 250 |
-
from confluent_kafka.schema_registry import Schema
|
| 251 |
-
|
| 252 |
-
schema = Schema(schema_str, schema_type="AVRO")
|
| 253 |
-
elif self.config.format == SchemaFormat.PROTOBUF:
|
| 254 |
-
schema_str = self._load_protobuf_schema(schema_name)
|
| 255 |
-
from confluent_kafka.schema_registry import Schema
|
| 256 |
-
|
| 257 |
-
schema = Schema(schema_str, schema_type="PROTOBUF")
|
| 258 |
-
else:
|
| 259 |
-
raise ValueError("Cannot register JSON schemas")
|
| 260 |
-
|
| 261 |
-
schema_id = registry.register_schema(subject, schema)
|
| 262 |
-
logger.info(
|
| 263 |
-
f"Registered schema {schema_name} for subject {subject} with ID {schema_id}"
|
| 264 |
-
)
|
| 265 |
-
return schema_id
|
| 266 |
-
except Exception as e:
|
| 267 |
-
logger.error(f"Failed to register schema: {e}")
|
| 268 |
-
raise
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
def create_schema_manager(
|
| 272 |
-
registry_url: str | None = None,
|
| 273 |
-
format: SchemaFormat = SchemaFormat.AVRO,
|
| 274 |
-
) -> SchemaManager:
|
| 275 |
-
"""Create a schema manager with configuration from environment or parameters."""
|
| 276 |
-
registry_url = registry_url or os.getenv(
|
| 277 |
-
"KAFKA_SCHEMA_REGISTRY_URL",
|
| 278 |
-
"http://localhost:8081",
|
| 279 |
-
)
|
| 280 |
-
|
| 281 |
-
config = SchemaConfig(registry_url=registry_url, format=format)
|
| 282 |
-
return SchemaManager(config)
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
# Example usage and migration helper
|
| 286 |
-
def migrate_from_json():
|
| 287 |
-
"""
|
| 288 |
-
Example of how to migrate existing JSON-based Kafka messages to schema-based.
|
| 289 |
-
"""
|
| 290 |
-
logger.info(
|
| 291 |
-
"""
|
| 292 |
-
Migration Steps:
|
| 293 |
-
|
| 294 |
-
1. Install dependencies:
|
| 295 |
-
pip install orka-reasoning[schema] # Includes Avro and Protobuf support
|
| 296 |
-
|
| 297 |
-
2. Update your Kafka producer:
|
| 298 |
-
schema_manager = create_schema_manager()
|
| 299 |
-
serializer = schema_manager.get_serializer('orka-memory-topic')
|
| 300 |
-
|
| 301 |
-
# In your producer code:
|
| 302 |
-
producer.produce(
|
| 303 |
-
topic='orka-memory-topic',
|
| 304 |
-
value=serializer(memory_object, SerializationContext('orka-memory-topic', MessageField.VALUE))
|
| 305 |
-
)
|
| 306 |
-
|
| 307 |
-
3. Update your Kafka consumer:
|
| 308 |
-
deserializer = schema_manager.get_deserializer('orka-memory-topic')
|
| 309 |
-
|
| 310 |
-
# In your consumer code:
|
| 311 |
-
memory_object = deserializer(message.value(), SerializationContext('orka-memory-topic', MessageField.VALUE))
|
| 312 |
-
|
| 313 |
-
4. Register schemas:
|
| 314 |
-
schema_manager.register_schema('orka-memory-topic-value', 'memory_entry')
|
| 315 |
-
"""
|
| 316 |
-
)
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
if __name__ == "__main__":
|
| 320 |
-
# Demo the schema management
|
| 321 |
-
migrate_from_json()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orka/memory_logger.py
CHANGED
|
@@ -31,7 +31,7 @@ Key Features
|
|
| 31 |
Records all agent activities and system events with detailed metadata
|
| 32 |
|
| 33 |
**Data Persistence**
|
| 34 |
-
Stores data in Redis streams
|
| 35 |
|
| 36 |
**Serialization**
|
| 37 |
Handles conversion of complex Python objects to JSON-serializable formats
|
|
@@ -46,8 +46,8 @@ Key Features
|
|
| 46 |
**File Export**
|
| 47 |
Supports exporting memory logs to files for analysis and backup
|
| 48 |
|
| 49 |
-
**
|
| 50 |
-
|
| 51 |
|
| 52 |
Core Use Cases
|
| 53 |
--------------
|
|
@@ -71,8 +71,8 @@ The memory system is composed of specialized modules:
|
|
| 71 |
:class:`~orka.memory.redis_logger.RedisMemoryLogger`
|
| 72 |
Complete Redis backend implementation with streams and data structures
|
| 73 |
|
| 74 |
-
:class:`~orka.memory.
|
| 75 |
-
|
| 76 |
|
| 77 |
:class:`~orka.memory.serialization`
|
| 78 |
JSON sanitization and memory processing utilities
|
|
@@ -92,24 +92,24 @@ Usage Examples
|
|
| 92 |
|
| 93 |
from orka.memory_logger import create_memory_logger
|
| 94 |
|
| 95 |
-
#
|
| 96 |
-
|
| 97 |
|
| 98 |
-
#
|
| 99 |
-
|
| 100 |
|
| 101 |
**Direct Instantiation**
|
| 102 |
|
| 103 |
.. code-block:: python
|
| 104 |
|
| 105 |
from orka.memory.redis_logger import RedisMemoryLogger
|
| 106 |
-
from orka.memory.
|
| 107 |
|
| 108 |
# Redis logger
|
| 109 |
redis_logger = RedisMemoryLogger(redis_url="redis://localhost:6380")
|
| 110 |
|
| 111 |
-
#
|
| 112 |
-
|
| 113 |
|
| 114 |
**Environment-Based Configuration**
|
| 115 |
|
|
@@ -119,23 +119,23 @@ Usage Examples
|
|
| 119 |
from orka.memory_logger import create_memory_logger
|
| 120 |
|
| 121 |
# Set backend via environment variable
|
| 122 |
-
os.environ["ORKA_MEMORY_BACKEND"] = "
|
| 123 |
|
| 124 |
-
# Logger will use
|
| 125 |
memory = create_memory_logger()
|
| 126 |
|
| 127 |
Backend Comparison
|
| 128 |
------------------
|
| 129 |
|
| 130 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
* **Best for**: Development, single-node deployments, quick prototyping
|
| 132 |
* **Features**: Fast in-memory operations, simple setup, full feature support
|
| 133 |
-
* **Limitations**:
|
| 134 |
-
|
| 135 |
-
**Kafka Backend**
|
| 136 |
-
* **Best for**: Production, distributed systems, high-throughput scenarios
|
| 137 |
-
* **Features**: Persistent event log, horizontal scaling, fault tolerance
|
| 138 |
-
* **Limitations**: More complex setup, higher resource usage
|
| 139 |
|
| 140 |
Implementation Notes
|
| 141 |
--------------------
|
|
@@ -147,6 +147,7 @@ Implementation Notes
|
|
| 147 |
* Blob deduplication reduces storage overhead
|
| 148 |
* In-memory buffers provide fast access to recent events
|
| 149 |
* Batch operations improve throughput
|
|
|
|
| 150 |
|
| 151 |
**Error Handling**
|
| 152 |
* Robust sanitization handles non-serializable objects
|
|
@@ -171,8 +172,6 @@ logger = logging.getLogger(__name__)
|
|
| 171 |
def create_memory_logger(
|
| 172 |
backend: str = "redisstack",
|
| 173 |
redis_url: str | None = None,
|
| 174 |
-
bootstrap_servers: str | None = None,
|
| 175 |
-
topic_prefix: str = "orka-memory",
|
| 176 |
stream_key: str = "orka:memory",
|
| 177 |
debug_keep_previous_outputs: bool = False,
|
| 178 |
decay_config: dict[str, Any] | None = None,
|
|
@@ -191,10 +190,8 @@ def create_memory_logger(
|
|
| 191 |
Defaults to RedisStack for optimal performance with automatic fallback.
|
| 192 |
|
| 193 |
Args:
|
| 194 |
-
backend: Memory backend type ("redisstack", "redis"
|
| 195 |
redis_url: Redis connection URL
|
| 196 |
-
bootstrap_servers: Kafka bootstrap servers (for Kafka backend)
|
| 197 |
-
topic_prefix: Kafka topic prefix (for Kafka backend)
|
| 198 |
stream_key: Redis stream key for logging
|
| 199 |
debug_keep_previous_outputs: Whether to keep previous outputs in logs
|
| 200 |
decay_config: Memory decay configuration
|
|
@@ -229,7 +226,7 @@ def create_memory_logger(
|
|
| 229 |
"check_interval_minutes": 30,
|
| 230 |
}
|
| 231 |
|
| 232 |
-
#
|
| 233 |
force_basic_redis = os.getenv("ORKA_FORCE_BASIC_REDIS", "false").lower() == "true"
|
| 234 |
|
| 235 |
if force_basic_redis and backend in ["redis", "redisstack"]:
|
|
@@ -252,7 +249,7 @@ def create_memory_logger(
|
|
| 252 |
try:
|
| 253 |
from .memory.redisstack_logger import RedisStackMemoryLogger
|
| 254 |
|
| 255 |
-
#
|
| 256 |
embedder = None
|
| 257 |
try:
|
| 258 |
from .utils.embedder import get_embedder
|
|
@@ -270,111 +267,40 @@ def create_memory_logger(
|
|
| 270 |
if force_recreate_index:
|
| 271 |
effective_vector_params["force_recreate"] = True
|
| 272 |
|
| 273 |
-
|
| 274 |
-
if "dim" not in effective_vector_params and vector_dim:
|
| 275 |
-
effective_vector_params["dim"] = vector_dim
|
| 276 |
|
| 277 |
-
|
| 278 |
redis_url=redis_url or "redis://localhost:6380/0",
|
| 279 |
-
index_name=index_name,
|
| 280 |
-
embedder=embedder,
|
|
|
|
| 281 |
stream_key=stream_key,
|
| 282 |
debug_keep_previous_outputs=debug_keep_previous_outputs,
|
| 283 |
decay_config=decay_config,
|
| 284 |
enable_hnsw=enable_hnsw,
|
| 285 |
vector_params=effective_vector_params,
|
| 286 |
-
format_params=format_params,
|
|
|
|
|
|
|
|
|
|
| 287 |
)
|
| 288 |
|
| 289 |
-
# Test RedisStack capabilities
|
| 290 |
-
try:
|
| 291 |
-
index_ready = logger_instance.ensure_index()
|
| 292 |
-
if index_ready:
|
| 293 |
-
if embedder:
|
| 294 |
-
logging.getLogger(__name__).info(
|
| 295 |
-
"✅ RedisStack with HNSW and vector search enabled",
|
| 296 |
-
)
|
| 297 |
-
else:
|
| 298 |
-
logging.getLogger(__name__).info(
|
| 299 |
-
"✅ RedisStack with HNSW enabled (no vector search)",
|
| 300 |
-
)
|
| 301 |
-
return logger_instance
|
| 302 |
-
else:
|
| 303 |
-
logging.getLogger(__name__).warning(
|
| 304 |
-
"⚠️ RedisStack index failed, falling back to basic Redis",
|
| 305 |
-
)
|
| 306 |
-
except Exception as e:
|
| 307 |
-
logging.getLogger(__name__).warning(f"RedisStack index test failed: {e}")
|
| 308 |
-
|
| 309 |
except ImportError as e:
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
decay_config=decay_config,
|
| 323 |
-
)
|
| 324 |
-
except ImportError as e:
|
| 325 |
-
if backend == "redisstack":
|
| 326 |
raise ImportError(f"No Redis backends available: {e}") from e
|
| 327 |
|
| 328 |
-
|
| 329 |
-
if backend == "kafka":
|
| 330 |
-
try:
|
| 331 |
-
from .memory.kafka_logger import KafkaMemoryLogger
|
| 332 |
-
|
| 333 |
-
# ✅ CRITICAL: Use provided parameters or defaults
|
| 334 |
-
kafka_bootstrap_servers = bootstrap_servers or os.getenv(
|
| 335 |
-
"KAFKA_BOOTSTRAP_SERVERS",
|
| 336 |
-
"localhost:9092",
|
| 337 |
-
)
|
| 338 |
-
|
| 339 |
-
# Get Schema Registry configuration
|
| 340 |
-
schema_registry_url = kwargs.get("schema_registry_url") or os.getenv(
|
| 341 |
-
"KAFKA_SCHEMA_REGISTRY_URL",
|
| 342 |
-
"http://localhost:8081",
|
| 343 |
-
)
|
| 344 |
-
use_schema_registry = kwargs.get("use_schema_registry", True)
|
| 345 |
-
|
| 346 |
-
logger.info(
|
| 347 |
-
f"🔄 Creating Kafka memory logger with Schema Registry: {schema_registry_url}"
|
| 348 |
-
)
|
| 349 |
-
|
| 350 |
-
return KafkaMemoryLogger(
|
| 351 |
-
bootstrap_servers=str(kafka_bootstrap_servers),
|
| 352 |
-
schema_registry_url=schema_registry_url,
|
| 353 |
-
use_schema_registry=use_schema_registry,
|
| 354 |
-
topic_prefix=topic_prefix,
|
| 355 |
-
redis_url=redis_url or "redis://localhost:6380/0",
|
| 356 |
-
stream_key=stream_key,
|
| 357 |
-
debug_keep_previous_outputs=debug_keep_previous_outputs,
|
| 358 |
-
decay_config=decay_config,
|
| 359 |
-
enable_hnsw=enable_hnsw,
|
| 360 |
-
vector_params=vector_params,
|
| 361 |
-
)
|
| 362 |
-
except ImportError as e:
|
| 363 |
-
logging.getLogger(__name__).warning(
|
| 364 |
-
f"Kafka not available, falling back to RedisStack: {e}",
|
| 365 |
-
)
|
| 366 |
-
# Recursive call with RedisStack
|
| 367 |
-
return create_memory_logger(
|
| 368 |
-
"redisstack",
|
| 369 |
-
redis_url=redis_url,
|
| 370 |
-
stream_key=stream_key,
|
| 371 |
-
debug_keep_previous_outputs=debug_keep_previous_outputs,
|
| 372 |
-
decay_config=decay_config,
|
| 373 |
-
enable_hnsw=enable_hnsw,
|
| 374 |
-
vector_params=vector_params,
|
| 375 |
-
)
|
| 376 |
-
|
| 377 |
-
raise ValueError(f"Unsupported backend: {backend}. Supported: redisstack, redis, kafka")
|
| 378 |
|
| 379 |
|
| 380 |
# Add MemoryLogger alias for backward compatibility with tests
|
|
|
|
| 31 |
Records all agent activities and system events with detailed metadata
|
| 32 |
|
| 33 |
**Data Persistence**
|
| 34 |
+
Stores data in Redis streams with reliability and durability
|
| 35 |
|
| 36 |
**Serialization**
|
| 37 |
Handles conversion of complex Python objects to JSON-serializable formats
|
|
|
|
| 46 |
**File Export**
|
| 47 |
Supports exporting memory logs to files for analysis and backup
|
| 48 |
|
| 49 |
+
**RedisStack Backend**
|
| 50 |
+
High-performance RedisStack backend with HNSW vector indexing for semantic search
|
| 51 |
|
| 52 |
Core Use Cases
|
| 53 |
--------------
|
|
|
|
| 71 |
:class:`~orka.memory.redis_logger.RedisMemoryLogger`
|
| 72 |
Complete Redis backend implementation with streams and data structures
|
| 73 |
|
| 74 |
+
:class:`~orka.memory.redisstack_logger.RedisStackMemoryLogger`
|
| 75 |
+
High-performance RedisStack backend with HNSW vector indexing
|
| 76 |
|
| 77 |
:class:`~orka.memory.serialization`
|
| 78 |
JSON sanitization and memory processing utilities
|
|
|
|
| 92 |
|
| 93 |
from orka.memory_logger import create_memory_logger
|
| 94 |
|
| 95 |
+
# RedisStack backend (default - recommended)
|
| 96 |
+
redisstack_memory = create_memory_logger("redisstack", redis_url="redis://localhost:6380")
|
| 97 |
|
| 98 |
+
# Basic Redis backend
|
| 99 |
+
redis_memory = create_memory_logger("redis", redis_url="redis://localhost:6380")
|
| 100 |
|
| 101 |
**Direct Instantiation**
|
| 102 |
|
| 103 |
.. code-block:: python
|
| 104 |
|
| 105 |
from orka.memory.redis_logger import RedisMemoryLogger
|
| 106 |
+
from orka.memory.redisstack_logger import RedisStackMemoryLogger
|
| 107 |
|
| 108 |
# Redis logger
|
| 109 |
redis_logger = RedisMemoryLogger(redis_url="redis://localhost:6380")
|
| 110 |
|
| 111 |
+
# RedisStack logger with HNSW
|
| 112 |
+
redisstack_logger = RedisStackMemoryLogger(redis_url="redis://localhost:6380")
|
| 113 |
|
| 114 |
**Environment-Based Configuration**
|
| 115 |
|
|
|
|
| 119 |
from orka.memory_logger import create_memory_logger
|
| 120 |
|
| 121 |
# Set backend via environment variable
|
| 122 |
+
os.environ["ORKA_MEMORY_BACKEND"] = "redisstack"
|
| 123 |
|
| 124 |
+
# Logger will use RedisStack automatically
|
| 125 |
memory = create_memory_logger()
|
| 126 |
|
| 127 |
Backend Comparison
|
| 128 |
------------------
|
| 129 |
|
| 130 |
+
**RedisStack Backend (Recommended)**
|
| 131 |
+
* **Best for**: Production AI workloads, high-performance applications
|
| 132 |
+
* **Features**: HNSW vector indexing, 100x faster search, advanced memory management
|
| 133 |
+
* **Performance**: Sub-millisecond search, 50,000+ operations/second
|
| 134 |
+
|
| 135 |
+
**Redis Backend (Legacy)**
|
| 136 |
* **Best for**: Development, single-node deployments, quick prototyping
|
| 137 |
* **Features**: Fast in-memory operations, simple setup, full feature support
|
| 138 |
+
* **Limitations**: Basic search capabilities, no vector indexing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
Implementation Notes
|
| 141 |
--------------------
|
|
|
|
| 147 |
* Blob deduplication reduces storage overhead
|
| 148 |
* In-memory buffers provide fast access to recent events
|
| 149 |
* Batch operations improve throughput
|
| 150 |
+
* HNSW indexing for ultra-fast vector search
|
| 151 |
|
| 152 |
**Error Handling**
|
| 153 |
* Robust sanitization handles non-serializable objects
|
|
|
|
| 172 |
def create_memory_logger(
|
| 173 |
backend: str = "redisstack",
|
| 174 |
redis_url: str | None = None,
|
|
|
|
|
|
|
| 175 |
stream_key: str = "orka:memory",
|
| 176 |
debug_keep_previous_outputs: bool = False,
|
| 177 |
decay_config: dict[str, Any] | None = None,
|
|
|
|
| 190 |
Defaults to RedisStack for optimal performance with automatic fallback.
|
| 191 |
|
| 192 |
Args:
|
| 193 |
+
backend: Memory backend type ("redisstack", "redis")
|
| 194 |
redis_url: Redis connection URL
|
|
|
|
|
|
|
| 195 |
stream_key: Redis stream key for logging
|
| 196 |
debug_keep_previous_outputs: Whether to keep previous outputs in logs
|
| 197 |
decay_config: Memory decay configuration
|
|
|
|
| 226 |
"check_interval_minutes": 30,
|
| 227 |
}
|
| 228 |
|
| 229 |
+
# Handle force basic Redis flag
|
| 230 |
force_basic_redis = os.getenv("ORKA_FORCE_BASIC_REDIS", "false").lower() == "true"
|
| 231 |
|
| 232 |
if force_basic_redis and backend in ["redis", "redisstack"]:
|
|
|
|
| 249 |
try:
|
| 250 |
from .memory.redisstack_logger import RedisStackMemoryLogger
|
| 251 |
|
| 252 |
+
# Initialize embedder for vector search
|
| 253 |
embedder = None
|
| 254 |
try:
|
| 255 |
from .utils.embedder import get_embedder
|
|
|
|
| 267 |
if force_recreate_index:
|
| 268 |
effective_vector_params["force_recreate"] = True
|
| 269 |
|
| 270 |
+
logger.info("✅ RedisStack with HNSW and vector search enabled")
|
|
|
|
|
|
|
| 271 |
|
| 272 |
+
return RedisStackMemoryLogger(
|
| 273 |
redis_url=redis_url or "redis://localhost:6380/0",
|
| 274 |
+
index_name=index_name,
|
| 275 |
+
embedder=embedder,
|
| 276 |
+
memory_decay_config=decay_config,
|
| 277 |
stream_key=stream_key,
|
| 278 |
debug_keep_previous_outputs=debug_keep_previous_outputs,
|
| 279 |
decay_config=decay_config,
|
| 280 |
enable_hnsw=enable_hnsw,
|
| 281 |
vector_params=effective_vector_params,
|
| 282 |
+
format_params=format_params,
|
| 283 |
+
vector_dim=vector_dim,
|
| 284 |
+
force_recreate_index=force_recreate_index,
|
| 285 |
+
**kwargs,
|
| 286 |
)
|
| 287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
except ImportError as e:
|
| 289 |
+
# Fall back to basic Redis if RedisStack is not available
|
| 290 |
+
logger.warning(f"RedisStack not available, falling back to basic Redis: {e}")
|
| 291 |
+
try:
|
| 292 |
+
from .memory.redis_logger import RedisMemoryLogger
|
| 293 |
+
|
| 294 |
+
return RedisMemoryLogger(
|
| 295 |
+
redis_url=redis_url,
|
| 296 |
+
stream_key=stream_key,
|
| 297 |
+
debug_keep_previous_outputs=debug_keep_previous_outputs,
|
| 298 |
+
decay_config=decay_config,
|
| 299 |
+
)
|
| 300 |
+
except ImportError as e:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
raise ImportError(f"No Redis backends available: {e}") from e
|
| 302 |
|
| 303 |
+
raise ValueError(f"Unsupported backend: {backend}. Supported: redisstack, redis")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
|
| 305 |
|
| 306 |
# Add MemoryLogger alias for backward compatibility with tests
|
orka/orchestrator/base.py
CHANGED
|
@@ -31,7 +31,7 @@ Core Responsibilities
|
|
| 31 |
* Handles environment variable overrides
|
| 32 |
|
| 33 |
**Infrastructure Setup**
|
| 34 |
-
* Initializes memory backend (Redis or
|
| 35 |
* Configures fork group management for parallel execution
|
| 36 |
* Sets up error tracking and telemetry systems
|
| 37 |
|
|
@@ -71,7 +71,7 @@ class OrchestratorBase:
|
|
| 71 |
loader (:class:`~orka.loader.YAMLLoader`): Configuration file loader and validator
|
| 72 |
orchestrator_cfg (dict): Orchestrator-specific configuration settings
|
| 73 |
agent_cfgs (list): List of agent configuration objects
|
| 74 |
-
memory: Memory backend instance (Redis or
|
| 75 |
fork_manager: Fork group manager for parallel execution
|
| 76 |
queue (list): Current agent execution queue
|
| 77 |
run_id (str): Unique identifier for this orchestration run
|
|
@@ -90,10 +90,8 @@ class OrchestratorBase:
|
|
| 90 |
config_path (str): Path to the YAML configuration file
|
| 91 |
|
| 92 |
Environment Variables:
|
| 93 |
-
ORKA_MEMORY_BACKEND: Memory backend type ('redis' or '
|
| 94 |
ORKA_DEBUG_KEEP_PREVIOUS_OUTPUTS: Keep previous outputs for debugging ('true'/'false')
|
| 95 |
-
KAFKA_BOOTSTRAP_SERVERS: Kafka broker addresses (for Kafka backend)
|
| 96 |
-
KAFKA_TOPIC_PREFIX: Topic prefix for Kafka topics (default: 'orka-memory')
|
| 97 |
REDIS_URL: Redis connection URL (default: 'redis://localhost:6380/0')
|
| 98 |
"""
|
| 99 |
self.loader = YAMLLoader(config_path)
|
|
@@ -121,53 +119,25 @@ class OrchestratorBase:
|
|
| 121 |
# Get memory configuration from YAML
|
| 122 |
memory_config = self.orchestrator_cfg.get("memory", {}).get("config", {})
|
| 123 |
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
"ef_construction": 200,
|
| 144 |
-
"ef_runtime": 10,
|
| 145 |
-
},
|
| 146 |
-
)
|
| 147 |
-
# For Kafka backend, now use Redis-based fork manager since we have Redis for memory
|
| 148 |
-
self.memory = cast(
|
| 149 |
-
RedisStackMemoryLogger, self.memory
|
| 150 |
-
) # Cast to RedisStackMemoryLogger for type checking
|
| 151 |
-
self.fork_manager = ForkGroupManager(self.memory.redis)
|
| 152 |
-
else:
|
| 153 |
-
self.memory = create_memory_logger(
|
| 154 |
-
backend="redisstack",
|
| 155 |
-
redis_url=memory_config.get("redis_url")
|
| 156 |
-
or os.getenv("REDIS_URL", "redis://localhost:6380/0"),
|
| 157 |
-
debug_keep_previous_outputs=debug_keep_previous_outputs,
|
| 158 |
-
decay_config=decay_config,
|
| 159 |
-
enable_hnsw=True,
|
| 160 |
-
vector_params={
|
| 161 |
-
"M": 16,
|
| 162 |
-
"ef_construction": 200,
|
| 163 |
-
"ef_runtime": 10,
|
| 164 |
-
},
|
| 165 |
-
)
|
| 166 |
-
# For Redis, use the existing Redis-based fork manager
|
| 167 |
-
self.memory = cast(
|
| 168 |
-
RedisStackMemoryLogger, self.memory
|
| 169 |
-
) # Cast to RedisStackMemoryLogger for type checking
|
| 170 |
-
self.fork_manager = ForkGroupManager(self.memory.redis)
|
| 171 |
|
| 172 |
self.queue = self.orchestrator_cfg["agents"][:] # Initial agent execution queue
|
| 173 |
self.run_id = str(uuid4()) # Unique run/session ID
|
|
|
|
| 31 |
* Handles environment variable overrides
|
| 32 |
|
| 33 |
**Infrastructure Setup**
|
| 34 |
+
* Initializes memory backend (Redis or RedisStack)
|
| 35 |
* Configures fork group management for parallel execution
|
| 36 |
* Sets up error tracking and telemetry systems
|
| 37 |
|
|
|
|
| 71 |
loader (:class:`~orka.loader.YAMLLoader`): Configuration file loader and validator
|
| 72 |
orchestrator_cfg (dict): Orchestrator-specific configuration settings
|
| 73 |
agent_cfgs (list): List of agent configuration objects
|
| 74 |
+
memory: Memory backend instance (Redis or RedisStack)
|
| 75 |
fork_manager: Fork group manager for parallel execution
|
| 76 |
queue (list): Current agent execution queue
|
| 77 |
run_id (str): Unique identifier for this orchestration run
|
|
|
|
| 90 |
config_path (str): Path to the YAML configuration file
|
| 91 |
|
| 92 |
Environment Variables:
|
| 93 |
+
ORKA_MEMORY_BACKEND: Memory backend type ('redis' or 'redisstack', default: 'redisstack')
|
| 94 |
ORKA_DEBUG_KEEP_PREVIOUS_OUTPUTS: Keep previous outputs for debugging ('true'/'false')
|
|
|
|
|
|
|
| 95 |
REDIS_URL: Redis connection URL (default: 'redis://localhost:6380/0')
|
| 96 |
"""
|
| 97 |
self.loader = YAMLLoader(config_path)
|
|
|
|
| 119 |
# Get memory configuration from YAML
|
| 120 |
memory_config = self.orchestrator_cfg.get("memory", {}).get("config", {})
|
| 121 |
|
| 122 |
+
# Always use RedisStack backend
|
| 123 |
+
self.memory = create_memory_logger(
|
| 124 |
+
backend="redisstack",
|
| 125 |
+
redis_url=memory_config.get("redis_url")
|
| 126 |
+
or os.getenv("REDIS_URL", "redis://localhost:6380/0"),
|
| 127 |
+
debug_keep_previous_outputs=debug_keep_previous_outputs,
|
| 128 |
+
decay_config=decay_config,
|
| 129 |
+
enable_hnsw=True,
|
| 130 |
+
vector_params={
|
| 131 |
+
"M": 16,
|
| 132 |
+
"ef_construction": 200,
|
| 133 |
+
"ef_runtime": 10,
|
| 134 |
+
},
|
| 135 |
+
)
|
| 136 |
+
# For Redis, use the existing Redis-based fork manager
|
| 137 |
+
self.memory = cast(
|
| 138 |
+
RedisStackMemoryLogger, self.memory
|
| 139 |
+
) # Cast to RedisStackMemoryLogger for type checking
|
| 140 |
+
self.fork_manager = ForkGroupManager(self.memory.redis)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
self.queue = self.orchestrator_cfg["agents"][:] # Initial agent execution queue
|
| 143 |
self.run_id = str(uuid4()) # Unique run/session ID
|
orka/orka_start.py
CHANGED
|
@@ -4,18 +4,17 @@ OrKa Service Runner
|
|
| 4 |
====================
|
| 5 |
|
| 6 |
Main entry point for starting the OrKa service stack.
|
| 7 |
-
By default, uses
|
| 8 |
|
| 9 |
-
This provides
|
| 10 |
-
-
|
| 11 |
-
-
|
|
|
|
| 12 |
|
| 13 |
Environment Variables:
|
| 14 |
--------------------
|
| 15 |
-
ORKA_MEMORY_BACKEND: Backend type ('
|
| 16 |
REDIS_URL: Redis connection URL (default: redis://localhost:6380/0)
|
| 17 |
-
KAFKA_BOOTSTRAP_SERVERS: Kafka broker list (default: localhost:9092)
|
| 18 |
-
KAFKA_TOPIC_PREFIX: Prefix for Kafka topics (default: orka-memory)
|
| 19 |
"""
|
| 20 |
import os
|
| 21 |
import sys
|
|
@@ -25,24 +24,16 @@ from orka.utils.logging_utils import setup_logging
|
|
| 25 |
|
| 26 |
setup_logging()
|
| 27 |
|
| 28 |
-
# Set default backend to
|
| 29 |
if "ORKA_MEMORY_BACKEND" not in os.environ:
|
| 30 |
-
os.environ["ORKA_MEMORY_BACKEND"] = "
|
| 31 |
|
| 32 |
# Ensure Redis is configured for memory operations
|
| 33 |
if "REDIS_URL" not in os.environ:
|
| 34 |
os.environ["REDIS_URL"] = "redis://localhost:6380/0"
|
| 35 |
|
| 36 |
-
# Set default Kafka configuration if not already set
|
| 37 |
-
if "KAFKA_BOOTSTRAP_SERVERS" not in os.environ:
|
| 38 |
-
os.environ["KAFKA_BOOTSTRAP_SERVERS"] = "localhost:9092"
|
| 39 |
-
|
| 40 |
-
if "KAFKA_TOPIC_PREFIX" not in os.environ:
|
| 41 |
-
os.environ["KAFKA_TOPIC_PREFIX"] = "orka-memory"
|
| 42 |
-
|
| 43 |
# Import all functions from the modular startup package to maintain backward compatibility
|
| 44 |
from orka.startup import ( # Main orchestration functions
|
| 45 |
-
initialize_schema_registry,
|
| 46 |
main,
|
| 47 |
run_startup,
|
| 48 |
wait_for_redis,
|
|
@@ -52,25 +43,19 @@ from orka.startup import ( # Main orchestration functions
|
|
| 52 |
# Provide backward compatibility alias
|
| 53 |
_wait_for_redis = wait_for_redis
|
| 54 |
|
| 55 |
-
# The _initialize_schema_registry function is now initialize_schema_registry (removed underscore)
|
| 56 |
-
# Provide backward compatibility alias
|
| 57 |
-
_initialize_schema_registry = initialize_schema_registry
|
| 58 |
|
| 59 |
# Public API for backward compatibility
|
| 60 |
__all__ = [
|
| 61 |
-
"_initialize_schema_registry",
|
| 62 |
"_wait_for_redis",
|
| 63 |
-
"initialize_schema_registry",
|
| 64 |
"main",
|
| 65 |
"run_startup",
|
| 66 |
"wait_for_redis",
|
| 67 |
]
|
| 68 |
|
| 69 |
-
|
|
|
|
| 70 |
print("📋 Configuration:")
|
| 71 |
-
print(f" • Memory Backend: {
|
| 72 |
-
print(f" • Kafka Servers: {os.environ['KAFKA_BOOTSTRAP_SERVERS']}")
|
| 73 |
-
print(f" • Kafka Topic Prefix: {os.environ['KAFKA_TOPIC_PREFIX']}")
|
| 74 |
print(f" • Redis URL: {os.environ['REDIS_URL']}")
|
| 75 |
print(f" • LOG_LEVEL: {os.getenv('ORKA_LOG_LEVEL', 'INFO')}")
|
| 76 |
|
|
|
|
| 4 |
====================
|
| 5 |
|
| 6 |
Main entry point for starting the OrKa service stack.
|
| 7 |
+
By default, uses RedisStack backend for high-performance memory operations with HNSW vector indexing.
|
| 8 |
|
| 9 |
+
This provides optimal performance with simplified infrastructure:
|
| 10 |
+
- RedisStack for ultra-fast memory operations and vector search
|
| 11 |
+
- HNSW indexing for 100x faster semantic search
|
| 12 |
+
- Simplified architecture with single backend
|
| 13 |
|
| 14 |
Environment Variables:
|
| 15 |
--------------------
|
| 16 |
+
ORKA_MEMORY_BACKEND: Backend type ('redisstack' or 'redis')
|
| 17 |
REDIS_URL: Redis connection URL (default: redis://localhost:6380/0)
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
import os
|
| 20 |
import sys
|
|
|
|
| 24 |
|
| 25 |
setup_logging()
|
| 26 |
|
| 27 |
+
# Set default backend to RedisStack for optimal performance
|
| 28 |
if "ORKA_MEMORY_BACKEND" not in os.environ:
|
| 29 |
+
os.environ["ORKA_MEMORY_BACKEND"] = "redisstack"
|
| 30 |
|
| 31 |
# Ensure Redis is configured for memory operations
|
| 32 |
if "REDIS_URL" not in os.environ:
|
| 33 |
os.environ["REDIS_URL"] = "redis://localhost:6380/0"
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
# Import all functions from the modular startup package to maintain backward compatibility
|
| 36 |
from orka.startup import ( # Main orchestration functions
|
|
|
|
| 37 |
main,
|
| 38 |
run_startup,
|
| 39 |
wait_for_redis,
|
|
|
|
| 43 |
# Provide backward compatibility alias
|
| 44 |
_wait_for_redis = wait_for_redis
|
| 45 |
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
# Public API for backward compatibility
|
| 48 |
__all__ = [
|
|
|
|
| 49 |
"_wait_for_redis",
|
|
|
|
| 50 |
"main",
|
| 51 |
"run_startup",
|
| 52 |
"wait_for_redis",
|
| 53 |
]
|
| 54 |
|
| 55 |
+
backend = os.environ["ORKA_MEMORY_BACKEND"]
|
| 56 |
+
print(f"🚀 Starting OrKa with {backend.upper()} Backend...")
|
| 57 |
print("📋 Configuration:")
|
| 58 |
+
print(f" • Memory Backend: {backend}")
|
|
|
|
|
|
|
| 59 |
print(f" • Redis URL: {os.environ['REDIS_URL']}")
|
| 60 |
print(f" • LOG_LEVEL: {os.getenv('ORKA_LOG_LEVEL', 'INFO')}")
|
| 61 |
|
orka/schemas/avro/memory_entry.avsc
DELETED
|
@@ -1,116 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"type": "record",
|
| 3 |
-
"name": "MemoryEntry",
|
| 4 |
-
"namespace": "orka.memory",
|
| 5 |
-
"doc": "OrKa memory entry with structured content and metadata",
|
| 6 |
-
"fields": [
|
| 7 |
-
{
|
| 8 |
-
"name": "id",
|
| 9 |
-
"type": "string",
|
| 10 |
-
"doc": "Unique identifier for the memory entry"
|
| 11 |
-
},
|
| 12 |
-
{
|
| 13 |
-
"name": "content",
|
| 14 |
-
"type": "string",
|
| 15 |
-
"doc": "The actual content/text of the memory"
|
| 16 |
-
},
|
| 17 |
-
{
|
| 18 |
-
"name": "metadata",
|
| 19 |
-
"type": {
|
| 20 |
-
"type": "record",
|
| 21 |
-
"name": "MemoryMetadata",
|
| 22 |
-
"fields": [
|
| 23 |
-
{
|
| 24 |
-
"name": "source",
|
| 25 |
-
"type": "string",
|
| 26 |
-
"doc": "Source of the memory (e.g., validation-guard, user-input)"
|
| 27 |
-
},
|
| 28 |
-
{
|
| 29 |
-
"name": "confidence",
|
| 30 |
-
"type": "double",
|
| 31 |
-
"doc": "Confidence score (0.0 to 1.0)"
|
| 32 |
-
},
|
| 33 |
-
{
|
| 34 |
-
"name": "reason",
|
| 35 |
-
"type": ["null", "string"],
|
| 36 |
-
"default": null,
|
| 37 |
-
"doc": "Optional reason or explanation"
|
| 38 |
-
},
|
| 39 |
-
{
|
| 40 |
-
"name": "fact",
|
| 41 |
-
"type": ["null", "string"],
|
| 42 |
-
"default": null,
|
| 43 |
-
"doc": "Extracted fact or insight"
|
| 44 |
-
},
|
| 45 |
-
{
|
| 46 |
-
"name": "timestamp",
|
| 47 |
-
"type": "double",
|
| 48 |
-
"doc": "Unix timestamp when created"
|
| 49 |
-
},
|
| 50 |
-
{
|
| 51 |
-
"name": "agent_id",
|
| 52 |
-
"type": "string",
|
| 53 |
-
"doc": "ID of the agent that created this memory"
|
| 54 |
-
},
|
| 55 |
-
{
|
| 56 |
-
"name": "query",
|
| 57 |
-
"type": ["null", "string"],
|
| 58 |
-
"default": null,
|
| 59 |
-
"doc": "Original query that led to this memory"
|
| 60 |
-
},
|
| 61 |
-
{
|
| 62 |
-
"name": "tags",
|
| 63 |
-
"type": {
|
| 64 |
-
"type": "array",
|
| 65 |
-
"items": "string"
|
| 66 |
-
},
|
| 67 |
-
"default": [],
|
| 68 |
-
"doc": "Tags for categorization"
|
| 69 |
-
},
|
| 70 |
-
{
|
| 71 |
-
"name": "vector_embedding",
|
| 72 |
-
"type": ["null", {
|
| 73 |
-
"type": "array",
|
| 74 |
-
"items": "double"
|
| 75 |
-
}],
|
| 76 |
-
"default": null,
|
| 77 |
-
"doc": "Optional vector embedding for semantic search"
|
| 78 |
-
},
|
| 79 |
-
{
|
| 80 |
-
"name": "category",
|
| 81 |
-
"type": ["null", "string"],
|
| 82 |
-
"default": null,
|
| 83 |
-
"doc": "Category for memory separation (log, stored, etc.)"
|
| 84 |
-
}
|
| 85 |
-
]
|
| 86 |
-
},
|
| 87 |
-
"doc": "Metadata associated with the memory entry"
|
| 88 |
-
},
|
| 89 |
-
{
|
| 90 |
-
"name": "similarity",
|
| 91 |
-
"type": ["null", "double"],
|
| 92 |
-
"default": null,
|
| 93 |
-
"doc": "Similarity score when retrieved from search"
|
| 94 |
-
},
|
| 95 |
-
{
|
| 96 |
-
"name": "ts",
|
| 97 |
-
"type": "long",
|
| 98 |
-
"doc": "Timestamp in nanoseconds"
|
| 99 |
-
},
|
| 100 |
-
{
|
| 101 |
-
"name": "match_type",
|
| 102 |
-
"type": {
|
| 103 |
-
"type": "enum",
|
| 104 |
-
"name": "MatchType",
|
| 105 |
-
"symbols": ["exact", "semantic", "fuzzy", "stream", "hybrid"]
|
| 106 |
-
},
|
| 107 |
-
"default": "semantic",
|
| 108 |
-
"doc": "Type of match when retrieved"
|
| 109 |
-
},
|
| 110 |
-
{
|
| 111 |
-
"name": "stream_key",
|
| 112 |
-
"type": "string",
|
| 113 |
-
"doc": "Stream/topic key for partitioning"
|
| 114 |
-
}
|
| 115 |
-
]
|
| 116 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orka/schemas/protobuf/memory_entry.proto
DELETED
|
@@ -1,52 +0,0 @@
|
|
| 1 |
-
syntax = "proto3";
|
| 2 |
-
|
| 3 |
-
package orka.memory;
|
| 4 |
-
|
| 5 |
-
// Match types for memory retrieval
|
| 6 |
-
enum MatchType {
|
| 7 |
-
SEMANTIC = 0;
|
| 8 |
-
EXACT = 1;
|
| 9 |
-
FUZZY = 2;
|
| 10 |
-
STREAM = 3;
|
| 11 |
-
HYBRID = 4;
|
| 12 |
-
}
|
| 13 |
-
|
| 14 |
-
// Metadata associated with a memory entry
|
| 15 |
-
message MemoryMetadata {
|
| 16 |
-
string source = 1; // Source of the memory (e.g., validation-guard)
|
| 17 |
-
double confidence = 2; // Confidence score (0.0 to 1.0)
|
| 18 |
-
optional string reason = 3; // Optional reason or explanation
|
| 19 |
-
optional string fact = 4; // Extracted fact or insight
|
| 20 |
-
double timestamp = 5; // Unix timestamp when created
|
| 21 |
-
string agent_id = 6; // ID of the agent that created this memory
|
| 22 |
-
optional string query = 7; // Original query that led to this memory
|
| 23 |
-
repeated string tags = 8; // Tags for categorization
|
| 24 |
-
repeated double vector_embedding = 9; // Optional vector embedding for semantic search
|
| 25 |
-
optional string category = 10; // Category for memory separation (log, stored, etc.)
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
// Main memory entry record
|
| 29 |
-
message MemoryEntry {
|
| 30 |
-
string id = 1; // Unique identifier for the memory entry
|
| 31 |
-
string content = 2; // The actual content/text of the memory
|
| 32 |
-
MemoryMetadata metadata = 3; // Metadata associated with the memory entry
|
| 33 |
-
optional double similarity = 4; // Similarity score when retrieved from search
|
| 34 |
-
int64 ts = 5; // Timestamp in nanoseconds
|
| 35 |
-
MatchType match_type = 6; // Type of match when retrieved
|
| 36 |
-
string stream_key = 7; // Stream/topic key for partitioning
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
// Memory operations for Kafka messages
|
| 40 |
-
message MemoryOperation {
|
| 41 |
-
enum OperationType {
|
| 42 |
-
CREATE = 0;
|
| 43 |
-
UPDATE = 1;
|
| 44 |
-
DELETE = 2;
|
| 45 |
-
SEARCH = 3;
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
OperationType operation = 1;
|
| 49 |
-
MemoryEntry entry = 2;
|
| 50 |
-
optional string search_query = 3; // For search operations
|
| 51 |
-
optional int32 limit = 4; // For search result limits
|
| 52 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|