Prof-Hunter commited on
Commit
2d30dfd
·
verified ·
1 Parent(s): badd0f9

Update orchestrator.py

Browse files
Files changed (1) hide show
  1. orchestrator.py +44 -15
orchestrator.py CHANGED
@@ -1,29 +1,58 @@
1
  from agents import *
 
2
 
3
- AGENT_MAP = {
4
- "Market": market_agent,
5
- "Finance": finance_agent,
6
- "Risk": risk_agent,
7
- "Ethics": ethics_agent
 
8
  }
9
 
10
- def run_workflow(problem, agent_order, bias=False):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  memory = []
12
  outputs = {}
13
 
14
- for agent_name in agent_order:
15
- agent_fn = AGENT_MAP[agent_name]
 
 
 
 
 
16
  context = "\n\n".join(memory)
17
 
18
- result = agent_fn(problem, context)
 
 
 
 
 
 
19
 
20
- if bias and agent_name == "Market":
21
- result += "\n\n[NOTE: This analysis is overly optimistic.]"
22
 
23
- outputs[agent_name] = result
24
- memory.append(f"{agent_name} Agent:\n{result}")
 
 
 
25
 
26
- final = synthesiser_agent(problem, "\n\n".join(memory))
27
- outputs["Final Recommendation"] = final
28
 
29
  return outputs
 
1
  from agents import *
2
+ from prompts import *
3
 
4
+
5
+ AGENTS = {
6
+ "Market": (market_agent, MARKET_PROMPT),
7
+ "Finance": (finance_agent, FINANCE_PROMPT),
8
+ "Risk": (risk_agent, RISK_PROMPT),
9
+ "Ethics": (ethics_agent, ETHICS_PROMPT)
10
  }
11
 
12
+
13
+ def parse_order(order_text):
14
+
15
+ order = [
16
+ x.strip().title()
17
+ for x in order_text.split(",")
18
+ if x.strip()
19
+ ]
20
+
21
+ return order
22
+
23
+
24
+ def run_workflow(problem, order_text, bias=False):
25
+
26
+ order = parse_order(order_text)
27
+
28
  memory = []
29
  outputs = {}
30
 
31
+ for name in order:
32
+
33
+ if name not in AGENTS:
34
+ continue
35
+
36
+ fn, prompt = AGENTS[name]
37
+
38
  context = "\n\n".join(memory)
39
 
40
+ result = fn(problem, context, prompt)
41
+
42
+ # Inject bias
43
+ if bias and name == "Market":
44
+ result += "\n\n⚠️ WARNING: Over-optimistic bias detected."
45
+
46
+ outputs[name] = result
47
 
48
+ memory.append(f"{name} Agent:\n{result}")
 
49
 
50
+ final = synthesis_agent(
51
+ problem,
52
+ "\n\n".join(memory),
53
+ SYNTHESIS_PROMPT
54
+ )
55
 
56
+ outputs["Final"] = final
 
57
 
58
  return outputs