Add the category tag to the goals and example env file, and filter the results based on tags in list_agents

This commit is contained in:
Laine
2025-03-13 14:53:03 -04:00
parent 134414f647
commit ece3ac1d3c
4 changed files with 32 additions and 8 deletions

View File

@@ -35,8 +35,11 @@ OPENAI_API_KEY=sk-proj-...
# Uncomment if using API key (not needed for local dev server) # Uncomment if using API key (not needed for local dev server)
# TEMPORAL_API_KEY=abcdef1234567890 # TEMPORAL_API_KEY=abcdef1234567890
# Agent Goal Configuration # Set starting goal of agent
# AGENT_GOAL=goal_event_flight_invoice # (default) or goal_match_train_invoice AGENT_GOAL=goal_choose_agent_type # (default)
#Choose which category(ies) of goals you want to be listed by the Agent - options are system (always included), hr, travel, or all.
GOAL_CATEGORIES=hr,travel # default is all
# Set if the UI should force a user confirmation step or not # Set if the UI should force a user confirmation step or not
SHOW_CONFIRM=True SHOW_CONFIRM=True

View File

@@ -18,6 +18,7 @@ class ToolDefinition:
@dataclass @dataclass
class AgentGoal: class AgentGoal:
id: str id: str
category_tag: str
agent_name: str agent_name: str
agent_friendly_description: str agent_friendly_description: str
tools: List[ToolDefinition] tools: List[ToolDefinition]

View File

@@ -6,6 +6,7 @@ starter_prompt_generic = "Welcome me, give me a description of what you can do,
goal_choose_agent_type = AgentGoal( goal_choose_agent_type = AgentGoal(
id = "goal_choose_agent_type", id = "goal_choose_agent_type",
category_tag="system",
agent_name="Choose Agent", agent_name="Choose Agent",
agent_friendly_description="Choose the type of agent to assist you today.", agent_friendly_description="Choose the type of agent to assist you today.",
tools=[ tools=[
@@ -33,6 +34,7 @@ goal_choose_agent_type = AgentGoal(
goal_match_train_invoice = AgentGoal( goal_match_train_invoice = AgentGoal(
id = "goal_match_train_invoice", id = "goal_match_train_invoice",
category_tag="travel",
agent_name="UK Premier League Match Trip Booking", agent_name="UK Premier League Match Trip Booking",
agent_friendly_description="Book a trip to a city in the UK around the dates of a premier league match.", agent_friendly_description="Book a trip to a city in the UK around the dates of a premier league match.",
tools=[ tools=[
@@ -80,6 +82,7 @@ goal_match_train_invoice = AgentGoal(
goal_event_flight_invoice = AgentGoal( goal_event_flight_invoice = AgentGoal(
id = "goal_event_flight_invoice", id = "goal_event_flight_invoice",
category_tag="travel",
agent_name="Australia and New Zealand Event Flight Booking", agent_name="Australia and New Zealand Event Flight Booking",
agent_friendly_description="Book a trip to a city in Australia or New Zealand around the dates of events in that city.", agent_friendly_description="Book a trip to a city in Australia or New Zealand around the dates of events in that city.",
tools=[ tools=[
@@ -119,6 +122,7 @@ goal_event_flight_invoice = AgentGoal(
# This goal uses the data/employee_pto_data.json file as dummy data. # This goal uses the data/employee_pto_data.json file as dummy data.
goal_hr_schedule_pto = AgentGoal( goal_hr_schedule_pto = AgentGoal(
id = "goal_hr_schedule_pto", id = "goal_hr_schedule_pto",
category_tag="hr",
agent_name="Schedule PTO", agent_name="Schedule PTO",
agent_friendly_description="Schedule PTO based on your available PTO.", agent_friendly_description="Schedule PTO based on your available PTO.",
tools=[ tools=[

View File

@@ -1,16 +1,32 @@
import os
import tools.goal_registry as goals import tools.goal_registry as goals
def list_agents(args: dict) -> dict: def list_agents(args: dict) -> dict:
goal_categories_start = os.getenv("GOAL_CATEGORIES")
if goal_categories_start is None:
goal_categories = ["all"] # default to 'all' categories
else:
goal_categories_start.strip().lower() # handle extra spaces or non-lowercase
goal_categories = goal_categories_start.split(",")
# always show goals labeled as "system," like the goal chooser
if "system" not in goal_categories:
goal_categories.append("system")
agents = [] agents = []
if goals.goal_list is not None: if goals.goal_list is not None:
for goal in goals.goal_list: for goal in goals.goal_list:
agents.append( # add to list if either
{ # - all
"agent_name": goal.agent_name, # - current goal's tag is in goal_categories
"goal_id": goal.id, if "all" in goal_categories or goal.category_tag in goal_categories:
"agent_description": goal.agent_friendly_description, agents.append(
} {
"agent_name": goal.agent_name,
"goal_id": goal.id,
"agent_description": goal.agent_friendly_description,
}
) )
return { return {
"agents": agents, "agents": agents,