mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-15 22:18:09 +01:00
Dynamically generate list of agents, try to fix goal changing flow
This commit is contained in:
@@ -1,18 +1,8 @@
|
||||
# can this just call the API endpoint to set the goal, if that changes to allow a param?
|
||||
# if this functions, it could work to both send a signal and also circumvent the UI -> API thing. Maybe?
|
||||
|
||||
# --- OR ---
|
||||
|
||||
# end this workflow and start a new one with the new goal
|
||||
|
||||
# --- OR ---
|
||||
|
||||
# send a signal to the workflow from here?
|
||||
import shared.config
|
||||
|
||||
def change_goal(args: dict) -> dict:
|
||||
|
||||
new_goal = args.get("goalID")
|
||||
if new_goal is None:
|
||||
new_goal = "goal_choose_agent_type"
|
||||
|
||||
return {
|
||||
"new_goal": new_goal,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from typing import List
|
||||
from models.tool_definitions import AgentGoal
|
||||
from tools.tool_registry import (
|
||||
search_fixtures_tool,
|
||||
@@ -13,9 +14,12 @@ from tools.tool_registry import (
|
||||
starter_prompt_generic = "Welcome me, give me a description of what you can do, then ask me for the details you need to do your job"
|
||||
|
||||
goal_choose_agent_type = AgentGoal(
|
||||
id = "goal_choose_agent_type",
|
||||
agent_name="Choose Agent",
|
||||
agent_friendly_description="Choose the type of agent to assist you today.",
|
||||
tools=[
|
||||
list_agents_tool,
|
||||
change_goal_tool
|
||||
change_goal_tool,
|
||||
],
|
||||
description="The user wants to choose which type of agent they will interact with. "
|
||||
"Help the user gather args for these tools, in order: "
|
||||
@@ -38,6 +42,9 @@ goal_choose_agent_type = AgentGoal(
|
||||
)
|
||||
|
||||
goal_match_train_invoice = AgentGoal(
|
||||
id = "goal_match_train_invoice",
|
||||
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.",
|
||||
tools=[
|
||||
search_fixtures_tool,
|
||||
search_trains_tool,
|
||||
@@ -81,10 +88,14 @@ goal_match_train_invoice = AgentGoal(
|
||||
)
|
||||
|
||||
goal_event_flight_invoice = AgentGoal(
|
||||
id = "goal_event_flight_invoice",
|
||||
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.",
|
||||
tools=[
|
||||
find_events_tool,
|
||||
search_flights_tool,
|
||||
create_invoice_tool,
|
||||
list_agents_tool,
|
||||
],
|
||||
description="Help the user gather args for these tools in order: "
|
||||
"1. FindEvents: Find an event to travel to "
|
||||
@@ -113,3 +124,9 @@ goal_event_flight_invoice = AgentGoal(
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
#Add the goals to a list for more generic processing, like listing available agents
|
||||
goal_list: List[AgentGoal] = []
|
||||
goal_list.append(goal_choose_agent_type)
|
||||
goal_list.append(goal_event_flight_invoice)
|
||||
goal_list.append(goal_match_train_invoice)
|
||||
|
||||
@@ -1,27 +1,17 @@
|
||||
from pathlib import Path
|
||||
import json
|
||||
import tools.goal_registry as goals
|
||||
|
||||
def list_agents(args: dict) -> dict:
|
||||
|
||||
# file_path = Path(__file__).resolve().parent / "goal_regsitry.py"
|
||||
#if not file_path.exists():
|
||||
# return {"error": "Data file not found."}
|
||||
|
||||
agents = []
|
||||
agents.append(
|
||||
{
|
||||
"agent_name": "Event Flight Helper",
|
||||
"goal_id": "goal_event_flight_invoice",
|
||||
"agent_description": "Helps users find interesting events and arrange travel to them",
|
||||
}
|
||||
)
|
||||
agents.append(
|
||||
{
|
||||
"agent_name": "Soccer Train Thing Guy",
|
||||
"goal_id": "goal_match_train_invoice",
|
||||
"agent_description": "Something about soccer and trains and stuff",
|
||||
}
|
||||
)
|
||||
if goals.goal_list is not None:
|
||||
for goal in goals.goal_list:
|
||||
agents.append(
|
||||
{
|
||||
"agent_name": goal.agent_name,
|
||||
"goal_id": goal.id,
|
||||
"agent_description": goal.agent_friendly_description,
|
||||
}
|
||||
)
|
||||
return {
|
||||
"agents": agents,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user