Spaces:
Running
Running
File size: 12,183 Bytes
89e1169 592e28e 68afe96 592e28e 68afe96 7ad5fc1 68afe96 7ad5fc1 68afe96 740164e 68afe96 c366330 68afe96 6b92d39 68afe96 c366330 f2689da 68afe96 c366330 68afe96 592e28e 68afe96 89e1169 68afe96 f2689da 68afe96 f2689da 68afe96 592e28e 89e1169 68afe96 c366330 68afe96 89e1169 c366330 89e1169 c4d7ea7 435f08f c4d7ea7 740164e 89e1169 c4d7ea7 740164e 435f08f c4d7ea7 435f08f 740164e c4d7ea7 740164e 435f08f 89e1169 740164e c4d7ea7 740164e c4d7ea7 740164e c4d7ea7 740164e c4d7ea7 740164e 592e28e 740164e 435f08f c4d7ea7 89e1169 592e28e c366330 c4d7ea7 c366330 c4d7ea7 c366330 c4d7ea7 c366330 c4d7ea7 c366330 c4d7ea7 c366330 c4d7ea7 c366330 c4d7ea7 89e1169 c4d7ea7 c366330 c4d7ea7 f2689da c366330 c4d7ea7 f2689da c4d7ea7 c366330 c4d7ea7 c366330 f2689da c4d7ea7 c4ebf95 f2689da c4d7ea7 f2689da c4d7ea7 f2689da c4d7ea7 c4ebf95 f2689da c4d7ea7 c4ebf95 c366330 f2689da 89e1169 c4d7ea7 f2689da c4d7ea7 89e1169 7ad5fc1 c4d7ea7 7ad5fc1 c4d7ea7 7ad5fc1 c4d7ea7 7ad5fc1 c4d7ea7 7ad5fc1 c4d7ea7 7ad5fc1 c4d7ea7 7ad5fc1 c4d7ea7 7ad5fc1 c4d7ea7 7ad5fc1 c4ebf95 7ad5fc1 c4d7ea7 7ad5fc1 c4d7ea7 7ad5fc1 f2689da 89e1169 f2689da 89e1169 c4d7ea7 7ad5fc1 c4d7ea7 c4ebf95 7ad5fc1 c4d7ea7 c4ebf95 5fd8cb4 592e28e f2689da c4d7ea7 7ad5fc1 f2689da 7ad5fc1 89e1169 f2689da 89e1169 8146dee 89e1169 f2689da 89e1169 f2689da 592e28e f2689da 89e1169 f2689da 89e1169 f2689da 89e1169 f2689da 89e1169 f2689da 89e1169 32f70b2 f2689da 32f70b2 f2689da c366330 f2689da c366330 f2689da c366330 f2689da c366330 f2689da c366330 f2689da | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | [π Getting Start](./getting-started.md) | [π€ Agent Types](./agents.md) | [π Architecture](./architecture.md) | [π§ Idea](./index.md) | [π§ͺ Extending Agents](./extending-agents.md) | [π Observability](./observability.md) | [π YAML Schema](./orka.yaml-schema.md) | [π YAML Configuration Guide](./yaml-configuration-guide.md) | [β Runtime Modes](./runtime-modes.md) | [π Security](./security.md) | [β FAQ](./faq.md)
# Getting Started with OrKa
This guide shows you how to set up OrKa and create your first AI workflows using YAML configuration files.
## What You'll Learn
- How to install OrKa and its dependencies
- How to create basic AI workflows in YAML
- How to use OrKa's memory system
- How to work with local LLMs for privacy
## Prerequisites
- Python 3.8 or higher
- Docker (for Redis memory backend)
- Optional: Local LLM like Ollama, or OpenAI API key
## Installation
```bash
# Install OrKa
pip install orka-reasoning
# Start Redis for memory (runs in Docker)
orka-start
```
## Environment Setup
```bash
# For local LLMs (no API key needed)
# Just install Ollama: https://ollama.ai
# For OpenAI models (optional)
export OPENAI_API_KEY=your-api-key-here
# For Windows PowerShell:
$env:OPENAI_API_KEY="your-api-key-here"
```
## Your First Workflow
Let's create a simple Q&A system that remembers previous conversations:
### Create your first workflow file: `smart-assistant.yml`
Use one of the preset-based examples to get started:
```bash
# Copy a memory preset example (simplified configuration)
cp ../examples/simple_memory_preset_demo.yml smart-assistant.yml
# Or try the preset showcase with multiple memory types
cp ../examples/memory_presets_showcase.yml smart-assistant.yml
```
This gives you a working workflow with simplified configuration:
- **π§ Memory Presets** - Single parameter provides preconfigured retention rules
- **π― Operation-Based Defaults** - Different settings for read vs write operations
- **π€ Local LLM Support** - Privacy-focused with Ollama integration
- **β‘ Minimal Configuration** - Preset templates reduce configuration complexity
> **See all available examples**: [`../examples/README.md`](../examples/README.md)
**Key Features with Memory Presets:**
- **Simplified Configuration**: `memory_preset: "episodic"` instead of manual decay rules
- **Preset Templates**: Memory types with predefined retention periods (sensory, working, episodic, semantic, procedural, meta)
- **Operation-Based Defaults**: Automatic parameter selection for read vs write operations
- **Local LLM Integration** - Full privacy with local model support
**Example workflow structure with presets:**
```yaml
agents:
- id: memory_reader
type: memory
memory_preset: "episodic" # Personal experiences (7 days default)
config:
operation: read
# Preset provides default configuration
- id: answer_builder
type: local_llm # Local model for privacy
model: gpt-oss:20b
provider: ollama
- id: memory_writer
type: memory
memory_preset: "semantic" # Facts and knowledge (30 days default)
config:
operation: write
```
> **View the complete workflow**: [`../examples/simple_memory_preset_demo.yml`](../examples/simple_memory_preset_demo.yml)
### Test Your Workflow
```bash
# Run your first conversation
orka run smart-assistant.yml "Hello! I'm new to OrKa. Can you help me understand how the memory system works?"
# Ask a follow-up question
orka run smart-assistant.yml "What are the performance characteristics?"
# Test memory retrieval
orka run smart-assistant.yml "Can you remind me what we were just discussing?"
```
**What happens:**
- **First interaction**: No previous memory, creates new entry
- **Second interaction**: Retrieves relevant context from previous conversation
- **Third interaction**: Demonstrates memory retrieval with vector search
## π§ Understanding OrKa's Memory System
### What the Workflow Does
1. **Memory Retrieval**: OrKa searches for relevant past conversations using vector similarity with HNSW indexing
2. **Context Processing**: Retrieved memories are included in LLM prompt as context
3. **Response Generation**: LLM generates response based on current input and retrieved context
4. **Memory Storage**: Interaction is stored in Redis with vector embeddings and expiration rules
### RedisStack HNSW Indexing
**Basic Redis (pre-V0.7.0):**
- Vector search: 50-200ms (linear scan)
- Limited concurrent searches
- Manual index management
**RedisStack HNSW (V0.7.0+):**
- Vector search: 0.5-5ms (HNSW index)
- 1000+ concurrent searches supported
- Automatic index optimization
- Measured 100x faster on benchmarks
## π₯οΈ Monitor Memory State
```bash
# View memory dashboard with metrics
orka memory watch
# Example output:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β OrKa Memory Dashboard - 14:23:45 | Backend: redisstack β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π§ Backend: redisstack (HNSW) β‘ Decay: β
Enabled β
β π Memories: 1,247 π Active: 1,224 β
β π HNSW Searches: 1,203 Avg: 2.1ms | Hybrid: 856 β
β π§ Memory Types: Short: 423 πΎ Long: 801 | Recent: 43 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# View detailed statistics
orka memory stats
# Preview cleanup without deleting
orka memory cleanup --dry-run
```
## π Performance Comparison
Performance measurements on test dataset:
| Operation | Basic Redis | RedisStack HNSW | Measured Difference |
|-----------|-------------|-----------------|--------------|
| **Vector Search** | 50-200ms | 0.5-5ms | **~100x faster** |
| **Index Management** | Manual | Automatic | **Automatic** |
| **Concurrent Searches** | 10-50 | 1000+ | **20x+ more** |
| **Memory Efficiency** | 100% baseline | 40% | **60% reduction** |
*Note: Performance varies based on dataset size and hardware.*
## π Advanced: Iterative Workflows with LoopNode
OrKa V0.7.5 introduces **LoopNode** for workflows that repeat until a condition is met:
### Create an Iterative Workflow: `iterative-assistant.yml`
```yaml
meta:
version: "1.0"
description: "Iterative refinement workflow with score-based exit"
orchestrator:
id: iterative-assistant
strategy: sequential
agents: [improvement_loop, final_summary]
agents:
- id: improvement_loop
type: loop
max_loops: 5
score_threshold: 0.85
score_extraction_pattern: "QUALITY_SCORE:\\s*([0-9.]+)"
# Extract metrics from each iteration
cognitive_extraction:
enabled: true
extract_patterns:
insights:
- "(?:provides?|shows?|demonstrates?)\\s+(.+?)(?:\\n|$)"
improvements:
- "(?:lacks?|needs?|should?)\\s+(.+?)(?:\\n|$)"
mistakes:
- "(?:overlooked|missed?)\\s+(.+?)(?:\\n|$)"
# Store iteration metadata
past_loops_metadata:
iteration: "{{ loop_number }}"
quality_score: "{{ score }}"
key_insights: "{{ insights }}"
improvements_needed: "{{ improvements }}"
# Internal workflow that gets repeated
internal_workflow:
orchestrator:
id: improvement-cycle
agents: [analyzer, quality_scorer]
agents:
- id: analyzer
type: openai-answer
prompt: |
Analyze this request: {{ input }}
{% if previous_outputs.past_loops %}
Previous iterations:
{% for loop in previous_outputs.past_loops %}
- Iteration {{ loop.iteration }} (Score: {{ loop.quality_score }}):
Insights: {{ loop.key_insights }}
Improvements: {{ loop.improvements_needed }}
{% endfor %}
{% endif %}
Provide analysis based on previous iterations.
- id: quality_scorer
type: openai-answer
prompt: |
Rate this analysis quality (0.0-1.0):
{{ previous_outputs.analyzer.result }}
Format: QUALITY_SCORE: X.XX
Explain improvements needed if score < 0.85
- id: final_summary
type: openai-answer
prompt: |
Summarize the iteration process:
Iterations: {{ previous_outputs.improvement_loop.loops_completed }}
Final Score: {{ previous_outputs.improvement_loop.final_score }}
Learning Journey:
{% for loop in previous_outputs.improvement_loop.past_loops %}
**Iteration {{ loop.iteration }}**: {{ loop.key_insights }}
{% endfor %}
Final Result: {{ previous_outputs.improvement_loop.result }}
```
### Test the Iterative Workflow
```bash
# Run an iterative workflow
orka run iterative-assistant.yml "Explain how artificial intelligence will impact education in the next decade"
# Workflow repeats until quality threshold is met
```
**What happens:**
- **Iteration 1**: Initial analysis, generates quality score
- **Iteration 2**: Refines based on identified gaps from iteration 1
- **Continues**: Until quality score reaches 0.85 or max loops (5) reached
- **Final**: Aggregated output with summary of iterations
## π― Next Steps
### 1. Explore More Examples
```bash
# Try the built-in examples
orka run examples/enhanced_memory_validation_example.yml "Test memory search"
# Try the multi-agent deliberation example
orka run examples/cognitive_society_loop.yml "Should we implement universal basic income?"
# Try the loop example
orka run examples/simple_loop_example.yml "Analyze the pros and cons of remote work"
```
### 2. Build Advanced Workflows
Check out our guides:
- **[π YAML Configuration Guide](./yaml-configuration-guide.md)** - Complete configuration reference including LoopNode
- **[π§ Memory System Guide](./MEMORY_SYSTEM_GUIDE.md)** - Deep dive into RedisStack memory
- **[π€ Agent Types](./agents.md)** - All available agent types including LoopNode
### 3. Production Deployment
```bash
# Use RedisStack for enterprise memory and vector search
orka-start
# Monitor with professional UI
docker run -it -p 80:80 marcosomma/orka-ui:latest
```
## π Troubleshooting RedisStack
### Common Issues & Quick Fixes
| Issue | Quick Fix |
|-------|-----------|
| `"unknown command 'FT.CREATE'"` | You're using basic Redis. OrKa will auto-fallback, but install Docker for RedisStack |
| Slow performance | Check Docker is running: `docker ps` |
| Memory not persisting | Verify RedisStack container: `docker logs orka-redis` |
### Verify RedisStack is Working
```bash
# Check if vector search is available
redis-cli FT._LIST
# Should show OrKa memory indexes
# If empty, OrKa will create them automatically
```
## π Why OrKa V0.7.0 is Game-Changing
**Enterprise Performance**: 100x faster vector search makes OrKa suitable for production AI applications that were previously impossible.
**Zero Configuration**: Automatic RedisStack setup means you focus on building, not infrastructure.
**Intelligent Memory**: Context-aware search with temporal ranking provides human-like memory patterns.
**Complete Transparency**: Every decision is auditable and explainable.
**Ready to experience the future of AI orchestration?** Your RedisStack-powered OrKa system is now running with 100x faster vector search!
---
[π Getting Start](./getting-started.md) | [π€ Agent Types](./agents.md) | [π Architecture](./architecture.md) | [π§ Idea](./index.md) | [π§ͺ Extending Agents](./extending-agents.md) | [π Observability](./observability.md) | [π YAML Schema](./orka.yaml-schema.md) | [π YAML Configuration Guide](./yaml-configuration-guide.md) | [β Runtime Modes](./runtime-modes.md) | [π Security](./security.md) | [β FAQ](./faq.md)
|