-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy path07-parallel-agents.ts
More file actions
73 lines (63 loc) · 2.22 KB
/
Copy path07-parallel-agents.ts
File metadata and controls
73 lines (63 loc) · 2.22 KB
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
/**
* Parallel Agents — fan-out / fan-in.
*
* Demonstrates the parallel strategy where all sub-agents run concurrently
* on the same input and their results are aggregated.
*
* Requirements:
* - Conductor server with LLM support
* - CONDUCTOR_SERVER_URL=http://localhost:8080/api
* - CONDUCTOR_AGENT_LLM_MODEL=openai/gpt-4o-mini
*/
import { Agent, AgentRuntime } from '@io-orkes/conductor-javascript/agents';
import { llmModel } from './settings';
// -- Specialist analysts -----------------------------------------------------
export const marketAnalyst = new Agent({
name: 'market_analyst',
model: llmModel,
instructions:
'You are a market analyst. Analyze the given topic from a market perspective: ' +
'market size, growth trends, key players, and opportunities.',
});
export const riskAnalyst = new Agent({
name: 'risk_analyst',
model: llmModel,
instructions:
'You are a risk analyst. Analyze the given topic for risks: ' +
'regulatory risks, technical risks, competitive threats, and mitigation strategies.',
});
export const complianceChecker = new Agent({
name: 'compliance',
model: llmModel,
instructions:
'You are a compliance specialist. Check the given topic for compliance considerations: ' +
'data privacy, regulatory requirements, and industry standards.',
});
// -- Parallel analysis -------------------------------------------------------
export const analysis = new Agent({
name: 'analysis',
model: llmModel,
agents: [marketAnalyst, riskAnalyst, complianceChecker],
strategy: 'parallel',
});
async function main() {
const runtime = new AgentRuntime();
try {
const result = await runtime.run(
analysis,
'Launching an AI-powered healthcare diagnostic tool in the US market',
);
result.printResult();
// Production pattern:
// 1. Deploy once during CI/CD (optional -- serve() below also deploys):
// await runtime.deploy(analysis);
// CLI alternative:
// conductor deploy --package examples/agents --agents analysis
//
// 2. In a separate long-lived worker process (deploys + registers workers + starts polling):
// await runtime.serve(analysis);
} finally {
await runtime.shutdown();
}
}
main().catch(console.error);