refactor: clarify agent pattern names
- Remove redundant workflow suffix from agentic pattern names and related classes - Update documentation to reflect pattern name changes
This commit is contained in:
committed by
Christian Tzolov
parent
1433ff7382
commit
9f8cb92aa9
85
agentic-patterns/orchestrator-workers/README.md
Normal file
85
agentic-patterns/orchestrator-workers/README.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# Orchestrator-Workers Workflow Pattern
|
||||
|
||||
This project demonstrates the Orchestrator-Workers workflow pattern for building effective LLM-based systems, as described in [Anthropic's research on building effective agents](https://www.anthropic.com/research/building-effective-agents).
|
||||
|
||||

|
||||
|
||||
## Overview
|
||||
|
||||
The Orchestrator-Workers pattern is a flexible approach for handling complex tasks that require dynamic task decomposition and specialized processing. It consists of three main components:
|
||||
|
||||
- **Orchestrator**: A central LLM that analyzes tasks and determines required subtasks
|
||||
- **Workers**: Specialized LLMs that execute specific subtasks
|
||||
- **Synthesizer**: Component that combines worker outputs into a final result
|
||||
|
||||
## When to Use
|
||||
|
||||
This pattern is particularly effective for:
|
||||
|
||||
- Complex tasks where subtasks can't be predicted upfront
|
||||
- Tasks requiring different approaches or perspectives
|
||||
- Situations needing adaptive problem-solving
|
||||
- Tasks benefiting from specialized processing
|
||||
|
||||
|
||||
## Implementation
|
||||
|
||||
The implementation uses Spring AI's ChatClient for LLM interactions and consists of:
|
||||
|
||||
```java
|
||||
public class OrchestratorWorkers {
|
||||
public WorkerResponse process(String taskDescription) {
|
||||
// 1. Orchestrator analyzes task and determines subtasks
|
||||
OrchestratorResponse orchestratorResponse = // ...
|
||||
|
||||
// 2. Workers process subtasks in parallel
|
||||
List<String> workerResponses = // ...
|
||||
|
||||
// 3. Results are combined into final response
|
||||
return new WorkerResponse(/*...*/);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Usage Example
|
||||
|
||||
```java
|
||||
ChatClient chatClient = // ... initialize chat client
|
||||
OrchestratorWorkers agent = new OrchestratorWorkers(chatClient);
|
||||
|
||||
// Process a task
|
||||
WorkerResponse response = agent.process(
|
||||
"Generate both technical and user-friendly documentation for a REST API endpoint"
|
||||
);
|
||||
|
||||
// Access results
|
||||
System.out.println("Analysis: " + response.analysis());
|
||||
System.out.println("Worker Outputs: " + response.workerResponses());
|
||||
```
|
||||
|
||||
## Customization
|
||||
|
||||
The pattern can be customized through:
|
||||
|
||||
1. **Custom Prompts**: Provide specialized prompts for orchestrator and workers
|
||||
```java
|
||||
agent = new OrchestratorWorkers(
|
||||
chatClient,
|
||||
customOrchestratorPrompt,
|
||||
customWorkerPrompt
|
||||
);
|
||||
```
|
||||
|
||||
2. **Default Templates**: Modify the default prompts for common use cases
|
||||
- `DEFAULT_ORCHESTRATOR_PROMPT`: Template for task analysis
|
||||
- `DEFAULT_WORKER_PROMPT`: Template for worker processing
|
||||
|
||||
## Dependencies
|
||||
|
||||
- Spring AI
|
||||
- Spring Boot
|
||||
- Java 17 or later
|
||||
|
||||
## References
|
||||
|
||||
- [Building Effective Agents (Anthropic Research)](https://www.anthropic.com/research/building-effective-agents)
|
||||
Reference in New Issue
Block a user