TrialPath / trialpath /agent /orchestrator.py
yakilee's picture
style: apply ruff format to entire codebase
e46883d
"""TrialPath Parlant agent orchestrator entry point."""
import asyncio
from parlant.sdk import Agent, Journey, PluginServer, Server
from trialpath.agent.guidelines import configure_guidelines
from trialpath.agent.journey import create_clinical_trial_journey
from trialpath.agent.setup import create_server_and_agent
from trialpath.agent.tools import ALL_TOOLS
async def start_parlant() -> tuple[Server, Agent, Journey, PluginServer]:
"""Initialize and start all Parlant components.
Returns:
Tuple of (server, agent, journey, plugin_server).
"""
# Step 1: Create server and agent
server, agent = await create_server_and_agent()
# Step 2: Register tools via PluginServer
plugin_server = PluginServer(tools=ALL_TOOLS, hosted=True)
# Step 3: Configure guidelines
await configure_guidelines(agent)
# Step 4: Create journey and attach to agent
journey = await create_clinical_trial_journey(agent)
await agent.attach_journey(journey)
return server, agent, journey, plugin_server
async def _main() -> None:
"""Run the orchestrator (for standalone testing)."""
server, agent, journey, plugin_server = await start_parlant()
print(f"TrialPath agent '{agent.name}' ready")
print(f"Journey '{journey.title}' attached")
print(f"Plugin server with {len(ALL_TOOLS)} tools")
# Keep running
try:
await asyncio.Event().wait()
except KeyboardInterrupt:
pass
if __name__ == "__main__":
asyncio.run(_main())