Refactor orchestrator: add LLM fallbacks and Temporal workflow integration
Build Agents Runtime / build (push) Successful in 4m18s
Details
Build Agents Runtime / build (push) Successful in 4m18s
Details
This commit is contained in:
parent
4d40c93d46
commit
345f1651a6
|
|
@ -109,7 +109,9 @@ def run_agent_activity(payload: dict) -> str:
|
|||
target_jid = payload.get("targetJid", "default")
|
||||
sender = payload.get("sender", "Unknown")
|
||||
|
||||
llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
|
||||
primary_llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
|
||||
fallback_llm = ChatGoogleGenerativeAI(model="gemini-1.5-pro")
|
||||
llm = primary_llm.with_fallbacks([fallback_llm])
|
||||
|
||||
system_prompt = f"""You are a highly capable AI assistant operating as an orchestrator.
|
||||
|
||||
|
|
|
|||
15
src/api.py
15
src/api.py
|
|
@ -15,11 +15,16 @@ from src.agent import run_agent_activity
|
|||
|
||||
async def trigger_workflow(payload: dict):
|
||||
try:
|
||||
# Bypass Temporal for now since it's not deployed in the cluster
|
||||
print(f"Directly invoking agent for payload: {payload}")
|
||||
# run_agent_activity is a synchronous function, so run in thread or just call it directly
|
||||
result = await asyncio.to_thread(run_agent_activity, payload)
|
||||
print(f"Agent finished. Result: {result}")
|
||||
print(f"Connecting to Temporal and dispatching workflow for payload: {payload}")
|
||||
client = await Client.connect("temporal-frontend.ai-core.svc.cluster.local:7233")
|
||||
|
||||
result = await client.execute_workflow(
|
||||
CentralOrchestratorWorkflow.run,
|
||||
payload,
|
||||
id=f"orchestrator-workflow-{payload.get('sender', 'unknown')}-{asyncio.get_event_loop().time()}",
|
||||
task_queue="agents-orchestrator",
|
||||
)
|
||||
print(f"Workflow finished. Result: {result}")
|
||||
except Exception as e:
|
||||
import traceback
|
||||
print(f"Failed to trigger workflow: {e}")
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ from src.orchestrator import CentralOrchestratorWorkflow
|
|||
from src.agent import run_agent_activity
|
||||
|
||||
async def main():
|
||||
client = await Client.connect("localhost:7233")
|
||||
client = await Client.connect("temporal-frontend.ai-core.svc.cluster.local:7233")
|
||||
worker = Worker(
|
||||
client,
|
||||
task_queue="agent-task-queue",
|
||||
task_queue="agents-orchestrator",
|
||||
workflows=[CentralOrchestratorWorkflow],
|
||||
activities=[run_agent_activity],
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue