Spaces:
Running
Running
Commit ·
4c95ea4
1
Parent(s): 55dcc42
docs
Browse files- docs/agents-advanced.md +17 -7
- docs/agents.md +51 -2
- docs/architecture.md +38 -22
- docs/extending-agents.md +38 -4
- docs/yaml-configuration-guide.md +60 -0
docs/agents-advanced.md
CHANGED
|
@@ -10,12 +10,16 @@
|
|
| 10 |
| duckduckgo | string | list of strings | Search snippets |
|
| 11 |
| router | string + context | string (next agent) | Branching logic control |
|
| 12 |
| builder | dict | string | Compose structured final response |
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
---
|
| 15 |
## Error Handling
|
| 16 |
-
- All agents return
|
| 17 |
-
- Use `MemoryLogger` to log status.
|
| 18 |
- Malformed outputs will raise orchestration halt unless fallback is defined.
|
|
|
|
| 19 |
|
| 20 |
---
|
| 21 |
# 🧠 Orchestrator Example
|
|
@@ -97,7 +101,7 @@ Waits for all branches from `fork_parallel_checks` to finish before continuing.
|
|
| 97 |
Tries child agents in order. If the first fails, moves to the next.
|
| 98 |
|
| 99 |
---
|
| 100 |
-
# 🔍 Classification Agent Example
|
| 101 |
|
| 102 |
```yaml
|
| 103 |
- id: initial_classify
|
|
@@ -106,12 +110,14 @@ Tries child agents in order. If the first fails, moves to the next.
|
|
| 106 |
Classify this input "{{ input }}".
|
| 107 |
options: [tech, science, history, nonsense]
|
| 108 |
queue: orka:domain
|
|
|
|
|
|
|
| 109 |
```
|
| 110 |
|
| 111 |
Used for multi-class reasoning tasks. Outputs one label from predefined options.
|
| 112 |
|
| 113 |
---
|
| 114 |
-
# ✅ Binary Agent Example
|
| 115 |
|
| 116 |
```yaml
|
| 117 |
- id: search_required
|
|
@@ -119,12 +125,14 @@ Used for multi-class reasoning tasks. Outputs one label from predefined options.
|
|
| 119 |
prompt: >
|
| 120 |
Is "{{ input }}" a question that requires deep internet research?
|
| 121 |
queue: orka:need_search
|
|
|
|
|
|
|
| 122 |
```
|
| 123 |
|
| 124 |
-
Evaluates a yes/no question. Returns
|
| 125 |
|
| 126 |
---
|
| 127 |
-
# 🧩
|
| 128 |
|
| 129 |
```yaml
|
| 130 |
- id: final_builder_true
|
|
@@ -134,9 +142,11 @@ Evaluates a yes/no question. Returns `true` or `false`.
|
|
| 134 |
- Classification result: {{ previous_outputs.initial_classify }}
|
| 135 |
- Search result: {{ previous_outputs.failover_search }}
|
| 136 |
queue: orka:final_output
|
|
|
|
|
|
|
| 137 |
```
|
| 138 |
|
| 139 |
-
Builds a composed final output using previous agent results.
|
| 140 |
|
| 141 |
|
| 142 |
[📘 Getting Start](./getting-started.md) | [🤖 Advanced Agents](./agents-advanced.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)
|
|
|
|
| 10 |
| duckduckgo | string | list of strings | Search snippets |
|
| 11 |
| router | string + context | string (next agent) | Branching logic control |
|
| 12 |
| builder | dict | string | Compose structured final response |
|
| 13 |
+
| openai-binary | string | bool | LLM-powered yes/no decision |
|
| 14 |
+
| openai-classification | string | string (label) | LLM-powered multi-class classifier |
|
| 15 |
+
| openai-answer| dict/string | string | LLM-powered response generation |
|
| 16 |
|
| 17 |
---
|
| 18 |
## Error Handling
|
| 19 |
+
- All agents return standardized output formats.
|
| 20 |
+
- Use `MemoryLogger` to log status and track execution progress.
|
| 21 |
- Malformed outputs will raise orchestration halt unless fallback is defined.
|
| 22 |
+
- LLM agents gracefully handle API errors with configurable fallbacks.
|
| 23 |
|
| 24 |
---
|
| 25 |
# 🧠 Orchestrator Example
|
|
|
|
| 101 |
Tries child agents in order. If the first fails, moves to the next.
|
| 102 |
|
| 103 |
---
|
| 104 |
+
# 🔍 OpenAI Classification Agent Example
|
| 105 |
|
| 106 |
```yaml
|
| 107 |
- id: initial_classify
|
|
|
|
| 110 |
Classify this input "{{ input }}".
|
| 111 |
options: [tech, science, history, nonsense]
|
| 112 |
queue: orka:domain
|
| 113 |
+
model: gpt-3.5-turbo
|
| 114 |
+
temperature: 0.7
|
| 115 |
```
|
| 116 |
|
| 117 |
Used for multi-class reasoning tasks. Outputs one label from predefined options.
|
| 118 |
|
| 119 |
---
|
| 120 |
+
# ✅ OpenAI Binary Agent Example
|
| 121 |
|
| 122 |
```yaml
|
| 123 |
- id: search_required
|
|
|
|
| 125 |
prompt: >
|
| 126 |
Is "{{ input }}" a question that requires deep internet research?
|
| 127 |
queue: orka:need_search
|
| 128 |
+
model: gpt-3.5-turbo
|
| 129 |
+
temperature: 0.2
|
| 130 |
```
|
| 131 |
|
| 132 |
+
Evaluates a yes/no question using LLM reasoning. Returns a strict boolean value (true/false).
|
| 133 |
|
| 134 |
---
|
| 135 |
+
# 🧩 OpenAI Answer Builder Example
|
| 136 |
|
| 137 |
```yaml
|
| 138 |
- id: final_builder_true
|
|
|
|
| 142 |
- Classification result: {{ previous_outputs.initial_classify }}
|
| 143 |
- Search result: {{ previous_outputs.failover_search }}
|
| 144 |
queue: orka:final_output
|
| 145 |
+
model: gpt-4
|
| 146 |
+
temperature: 0.7
|
| 147 |
```
|
| 148 |
|
| 149 |
+
Builds a composed final output using previous agent results, leveraging OpenAI's capabilities.
|
| 150 |
|
| 151 |
|
| 152 |
[📘 Getting Start](./getting-started.md) | [🤖 Advanced Agents](./agents-advanced.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)
|
docs/agents.md
CHANGED
|
@@ -93,6 +93,55 @@ Branching logic, optional agent execution, fallback control.
|
|
| 93 |
|
| 94 |
---
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
## 🛠 Custom Agents
|
| 97 |
|
| 98 |
OrKa supports two patterns for creating custom agents:
|
|
@@ -113,9 +162,9 @@ class MyCustomAgent(BaseAgent):
|
|
| 113 |
### Legacy Sync Pattern (Backward Compatibility)
|
| 114 |
|
| 115 |
```python
|
| 116 |
-
from orka.agents.
|
| 117 |
|
| 118 |
-
class MyCustomAgent(
|
| 119 |
def run(self, input_data):
|
| 120 |
# Process input synchronously
|
| 121 |
return {"result": "custom processing"}
|
|
|
|
| 93 |
|
| 94 |
---
|
| 95 |
|
| 96 |
+
## 🤖 LLM Agents
|
| 97 |
+
|
| 98 |
+
OrKa includes built-in integrations with large language models:
|
| 99 |
+
|
| 100 |
+
### 🧠 `openai-answer`
|
| 101 |
+
|
| 102 |
+
Uses OpenAI models to generate answers based on a prompt and input data.
|
| 103 |
+
|
| 104 |
+
**Example config:**
|
| 105 |
+
|
| 106 |
+
```yaml
|
| 107 |
+
- id: generate_answer
|
| 108 |
+
type: openai-answer
|
| 109 |
+
prompt: >
|
| 110 |
+
Generate a detailed answer about {{topic}} considering {{context}}.
|
| 111 |
+
queue: orka:openai_answer
|
| 112 |
+
model: gpt-3.5-turbo
|
| 113 |
+
temperature: 0.7
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
### 🔄 `openai-binary`
|
| 117 |
+
|
| 118 |
+
Leverages OpenAI models to make binary decisions (yes/no).
|
| 119 |
+
|
| 120 |
+
**Example config:**
|
| 121 |
+
|
| 122 |
+
```yaml
|
| 123 |
+
- id: fact_check
|
| 124 |
+
type: openai-binary
|
| 125 |
+
prompt: >
|
| 126 |
+
Is the following statement correct? Answer with yes or no only.
|
| 127 |
+
queue: orka:openai_binary
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
### 📊 `openai-classification`
|
| 131 |
+
|
| 132 |
+
Uses OpenAI models to classify inputs into predefined categories.
|
| 133 |
+
|
| 134 |
+
**Example config:**
|
| 135 |
+
|
| 136 |
+
```yaml
|
| 137 |
+
- id: classify_topic
|
| 138 |
+
type: openai-classification
|
| 139 |
+
prompt: >
|
| 140 |
+
Classify the following text into one of these categories.
|
| 141 |
+
options: [technology, science, politics, entertainment, sports]
|
| 142 |
+
queue: orka:openai_classification
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
## 🛠 Custom Agents
|
| 146 |
|
| 147 |
OrKa supports two patterns for creating custom agents:
|
|
|
|
| 162 |
### Legacy Sync Pattern (Backward Compatibility)
|
| 163 |
|
| 164 |
```python
|
| 165 |
+
from orka.agents.base_agent import LegacyBaseAgent # Updated import path
|
| 166 |
|
| 167 |
+
class MyCustomAgent(LegacyBaseAgent):
|
| 168 |
def run(self, input_data):
|
| 169 |
# Process input synchronously
|
| 170 |
return {"result": "custom processing"}
|
docs/architecture.md
CHANGED
|
@@ -46,34 +46,50 @@ This document breaks down the key architectural components and how they work tog
|
|
| 46 |
|
| 47 |
## 🔁 Agent Implementation
|
| 48 |
|
| 49 |
-
OrKa
|
| 50 |
|
| 51 |
-
|
| 52 |
-
```
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
### Legacy Sync Pattern
|
| 62 |
```python
|
| 63 |
-
from orka.
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
return result
|
| 69 |
-
```
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
- Standardized error handling
|
| 75 |
-
- Consistent output formatting
|
| 76 |
-
- Resource lifecycle management
|
| 77 |
|
| 78 |
---
|
| 79 |
|
|
|
|
| 46 |
|
| 47 |
## 🔁 Agent Implementation
|
| 48 |
|
| 49 |
+
OrKa's agent architecture provides two key implementation patterns:
|
| 50 |
|
| 51 |
+
1. **Modern Async Pattern (Recommended)**
|
| 52 |
+
- Inherits from `BaseAgent` in `orka.agents.base_agent`
|
| 53 |
+
- Uses `async/await` for concurrency support
|
| 54 |
+
- Full lifecycle management through initialization hooks
|
| 55 |
+
- Support for timeouts and concurrency limits
|
| 56 |
|
| 57 |
+
2. **Legacy Sync Pattern (Backward Compatibility)**
|
| 58 |
+
- Inherits from `LegacyBaseAgent` in `orka.agents.base_agent`
|
| 59 |
+
- Simple synchronous execution model
|
| 60 |
+
- Compatible with older agent implementations
|
| 61 |
+
|
| 62 |
+
### Built-in Agent Types
|
| 63 |
+
|
| 64 |
+
- **Core Processing Agents**
|
| 65 |
+
- `BinaryAgent`: Yes/no decisions
|
| 66 |
+
- `ClassificationAgent`: Multi-class classification
|
| 67 |
+
- `RouterAgent`: Dynamic flow control
|
| 68 |
+
|
| 69 |
+
- **LLM Integration Agents**
|
| 70 |
+
- `OpenAIAnswerBuilder`: Text generation using OpenAI models
|
| 71 |
+
- `OpenAIBinaryAgent`: Yes/no decisions using OpenAI
|
| 72 |
+
- `OpenAIClassificationAgent`: Classification using OpenAI
|
| 73 |
+
|
| 74 |
+
- **Node Control Agents**
|
| 75 |
+
- `ForkNode`: Splits processing into parallel branches
|
| 76 |
+
- `JoinNode`: Combines parallel branches
|
| 77 |
+
- `FailoverNode`: Provides fallback mechanisms
|
| 78 |
+
|
| 79 |
+
### Agent Registry System
|
| 80 |
+
|
| 81 |
+
The agent registry system maps agent type identifiers to their implementation classes:
|
| 82 |
|
|
|
|
| 83 |
```python
|
| 84 |
+
from orka.registry import registry
|
| 85 |
|
| 86 |
+
# Built-in registrations happen at framework initialization
|
| 87 |
+
registry.register_agent("binary", BinaryAgent)
|
| 88 |
+
registry.register_agent("openai-binary", OpenAIBinaryAgent)
|
|
|
|
|
|
|
| 89 |
|
| 90 |
+
# Custom agents can be registered by applications
|
| 91 |
+
registry.register_agent("my_custom_agent", MyCustomAgent)
|
| 92 |
+
```
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
---
|
| 95 |
|
docs/extending-agents.md
CHANGED
|
@@ -37,9 +37,9 @@ class MySummarizer(BaseAgent):
|
|
| 37 |
|
| 38 |
### 1. Subclass `LegacyBaseAgent`
|
| 39 |
```python
|
| 40 |
-
from orka.agents.
|
| 41 |
|
| 42 |
-
class MySummarizer(
|
| 43 |
def run(self, input_data):
|
| 44 |
# Direct synchronous processing
|
| 45 |
result = self.summarize(input_data)
|
|
@@ -57,8 +57,42 @@ class MySummarizer(BaseAgent):
|
|
| 57 |
queue: orka:summarize
|
| 58 |
```
|
| 59 |
|
| 60 |
-
##
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
## Benefits of Modern Async Pattern
|
| 64 |
|
|
|
|
| 37 |
|
| 38 |
### 1. Subclass `LegacyBaseAgent`
|
| 39 |
```python
|
| 40 |
+
from orka.agents.base_agent import LegacyBaseAgent # Updated import path
|
| 41 |
|
| 42 |
+
class MySummarizer(LegacyBaseAgent):
|
| 43 |
def run(self, input_data):
|
| 44 |
# Direct synchronous processing
|
| 45 |
result = self.summarize(input_data)
|
|
|
|
| 57 |
queue: orka:summarize
|
| 58 |
```
|
| 59 |
|
| 60 |
+
## Extending LLM Agents
|
| 61 |
+
|
| 62 |
+
You can also extend existing LLM agents to customize their behavior:
|
| 63 |
+
|
| 64 |
+
```python
|
| 65 |
+
from orka.agents.llm_agents import OpenAIAnswerBuilder
|
| 66 |
+
|
| 67 |
+
class CustomAnswerBuilder(OpenAIAnswerBuilder):
|
| 68 |
+
def run(self, input_data):
|
| 69 |
+
# Preprocess the input
|
| 70 |
+
enhanced_input = self.enhance_input(input_data)
|
| 71 |
+
|
| 72 |
+
# Call the parent implementation
|
| 73 |
+
result = super().run(enhanced_input)
|
| 74 |
+
|
| 75 |
+
# Post-process the result
|
| 76 |
+
return self.format_output(result)
|
| 77 |
+
|
| 78 |
+
def enhance_input(self, input_data):
|
| 79 |
+
# Add context or modify input before sending to LLM
|
| 80 |
+
return input_data
|
| 81 |
+
|
| 82 |
+
def format_output(self, result):
|
| 83 |
+
# Format or clean up the LLM output
|
| 84 |
+
return result
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
## 3. Register in `agent_registry`
|
| 88 |
+
Add your custom class to the agent registry by registering it in your application code:
|
| 89 |
+
|
| 90 |
+
```python
|
| 91 |
+
from orka.registry import registry
|
| 92 |
+
|
| 93 |
+
# Register your custom agent
|
| 94 |
+
registry.register_agent("my_summarizer", MySummarizer)
|
| 95 |
+
```
|
| 96 |
|
| 97 |
## Benefits of Modern Async Pattern
|
| 98 |
|
docs/yaml-configuration-guide.md
CHANGED
|
@@ -227,6 +227,66 @@ OrKa supports Jinja2-style templating in prompts:
|
|
| 227 |
queue: orka:summary
|
| 228 |
```
|
| 229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
## Complete Example
|
| 231 |
|
| 232 |
```yaml
|
|
|
|
| 227 |
queue: orka:summary
|
| 228 |
```
|
| 229 |
|
| 230 |
+
## OpenAI Agent Configuration
|
| 231 |
+
|
| 232 |
+
### OpenAI Answer Builder
|
| 233 |
+
|
| 234 |
+
```yaml
|
| 235 |
+
- id: research_question
|
| 236 |
+
type: openai-answer
|
| 237 |
+
prompt: |
|
| 238 |
+
Generate a detailed answer to the following question:
|
| 239 |
+
"{{ input }}"
|
| 240 |
+
|
| 241 |
+
Include all relevant information and cite sources where appropriate.
|
| 242 |
+
queue: orka:research_answers
|
| 243 |
+
model: gpt-4
|
| 244 |
+
temperature: 0.7
|
| 245 |
+
|
| 246 |
+
### OpenAI Binary Agent
|
| 247 |
+
|
| 248 |
+
```yaml
|
| 249 |
+
- id: is_medical_question
|
| 250 |
+
type: openai-binary
|
| 251 |
+
prompt: |
|
| 252 |
+
Determine if the following is a medical question:
|
| 253 |
+
"{{ input }}"
|
| 254 |
+
|
| 255 |
+
Return ONLY true or false.
|
| 256 |
+
queue: orka:binary_medical_filter
|
| 257 |
+
model: gpt-3.5-turbo
|
| 258 |
+
temperature: 0.2
|
| 259 |
+
```
|
| 260 |
+
|
| 261 |
+
### OpenAI Classification Agent
|
| 262 |
+
|
| 263 |
+
```yaml
|
| 264 |
+
- id: categorize_request
|
| 265 |
+
type: openai-classification
|
| 266 |
+
prompt: |
|
| 267 |
+
Classify the following user request into exactly one of these categories:
|
| 268 |
+
"{{ input }}"
|
| 269 |
+
options:
|
| 270 |
+
- technical_support
|
| 271 |
+
- account_related
|
| 272 |
+
- billing_question
|
| 273 |
+
- feature_request
|
| 274 |
+
- bug_report
|
| 275 |
+
- general_inquiry
|
| 276 |
+
queue: orka:request_categorizer
|
| 277 |
+
model: gpt-3.5-turbo
|
| 278 |
+
temperature: 0.3
|
| 279 |
+
```
|
| 280 |
+
|
| 281 |
+
### Configuration Parameters
|
| 282 |
+
|
| 283 |
+
| Parameter | Description | Default | Required |
|
| 284 |
+
|---------------|--------------------------------------------|-------------- |----------|
|
| 285 |
+
| model | OpenAI model to use | gpt-3.5-turbo | No |
|
| 286 |
+
| temperature | Randomness of output (0.0-1.0) | 1.0 | No |
|
| 287 |
+
| prompt | Template for request to the model | - | Yes |
|
| 288 |
+
| options | List of choices (for classification only) | - | For classification |
|
| 289 |
+
|
| 290 |
## Complete Example
|
| 291 |
|
| 292 |
```yaml
|