Bypass Temporal for direct agent execution
Build Agents Runtime / build (push) Successful in 4m17s
Details
Build Agents Runtime / build (push) Successful in 4m17s
Details
This commit is contained in:
parent
31576a1feb
commit
84b9571d9f
14
src/api.py
14
src/api.py
|
|
@ -11,15 +11,15 @@ class WebhookPayload(BaseModel):
|
|||
sender: str
|
||||
targetJid: str
|
||||
|
||||
from src.agent import run_agent_activity
|
||||
|
||||
async def trigger_workflow(payload: dict):
|
||||
try:
|
||||
client = await Client.connect("localhost:7233")
|
||||
await client.execute_workflow(
|
||||
CentralOrchestratorWorkflow.run,
|
||||
payload,
|
||||
id=f"whatsapp-cmd-{payload['sender']}-{asyncio.get_event_loop().time()}",
|
||||
task_queue="agent-task-queue"
|
||||
)
|
||||
# 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}")
|
||||
except Exception as e:
|
||||
print(f"Failed to trigger workflow: {e}")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue