Spaces:
Sleeping
Sleeping
Update orchestrator.py
Browse files- orchestrator.py +44 -15
orchestrator.py
CHANGED
|
@@ -1,29 +1,58 @@
|
|
| 1 |
from agents import *
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
"
|
| 6 |
-
"
|
| 7 |
-
"
|
|
|
|
| 8 |
}
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
memory = []
|
| 12 |
outputs = {}
|
| 13 |
|
| 14 |
-
for
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
context = "\n\n".join(memory)
|
| 17 |
|
| 18 |
-
result =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
result += "\n\n[NOTE: This analysis is overly optimistic.]"
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 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
|