Change to use goal_list in the api code, add list_agents to the other goal as the last tool

This commit is contained in:
Laine
2025-03-12 09:40:56 -04:00
parent e872c9381d
commit df58eee9d4
3 changed files with 8 additions and 12 deletions

View File

@@ -9,7 +9,7 @@ import asyncio
from workflows.agent_goal_workflow import AgentGoalWorkflow from workflows.agent_goal_workflow import AgentGoalWorkflow
from models.data_types import CombinedInput, AgentGoalWorkflowParams from models.data_types import CombinedInput, AgentGoalWorkflowParams
from tools.goal_registry import goal_match_train_invoice, goal_event_flight_invoice, goal_choose_agent_type from tools.goal_registry import goal_list
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
from shared.config import get_temporal_client, TEMPORAL_TASK_QUEUE, AGENT_GOAL from shared.config import get_temporal_client, TEMPORAL_TASK_QUEUE, AGENT_GOAL
@@ -22,17 +22,13 @@ load_dotenv()
def get_initial_agent_goal(): def get_initial_agent_goal():
"""Get the agent goal from environment variables.""" """Get the agent goal from environment variables."""
goals = {
"goal_match_train_invoice": goal_match_train_invoice,
"goal_event_flight_invoice": goal_event_flight_invoice,
"goal_choose_agent_type": goal_choose_agent_type,
}
if AGENT_GOAL is not None: if AGENT_GOAL is not None:
return goals.get(AGENT_GOAL) for listed_goal in goal_list:
if listed_goal.id == AGENT_GOAL:
return listed_goal
else: else:
#if no goal is set in the env file, default to event/flight use case #if no goal is set in the config file, default to choosing an agent
return goals.get("goal_event_flight_invoice", goal_event_flight_invoice) return goal_list.get("goal_choose_agent_type")
@app.on_event("startup") @app.on_event("startup")

View File

@@ -50,6 +50,7 @@ goal_match_train_invoice = AgentGoal(
search_trains_tool, search_trains_tool,
book_trains_tool, book_trains_tool,
create_invoice_tool, create_invoice_tool,
list_agents_tool, #last tool must be list_agents to fasciliate changing back to picking an agent again at the end
], ],
description="The user wants to book a trip to a city in the UK around the dates of a premier league match. " description="The user wants to book a trip to a city in the UK around the dates of a premier league match. "
"Help the user find a premier league match to attend, search and book trains for that match and offers to invoice them for the cost of train tickets. " "Help the user find a premier league match to attend, search and book trains for that match and offers to invoice them for the cost of train tickets. "
@@ -95,7 +96,7 @@ goal_event_flight_invoice = AgentGoal(
find_events_tool, find_events_tool,
search_flights_tool, search_flights_tool,
create_invoice_tool, create_invoice_tool,
list_agents_tool, list_agents_tool, #last tool must be list_agents to fasciliate changing back to picking an agent again at the end
], ],
description="Help the user gather args for these tools in order: " description="Help the user gather args for these tools in order: "
"1. FindEvents: Find an event to travel to " "1. FindEvents: Find an event to travel to "

View File

@@ -180,7 +180,6 @@ class AgentGoalWorkflow:
if await helpers.handle_missing_args(current_tool, args, tool_data, self.prompt_queue): if await helpers.handle_missing_args(current_tool, args, tool_data, self.prompt_queue):
continue continue
# Would swapping these two get rid of the confirm button step?
waiting_for_confirm = True waiting_for_confirm = True
self.confirm = False self.confirm = False
workflow.logger.info("Waiting for user confirm signal...") workflow.logger.info("Waiting for user confirm signal...")