Add pirate treasure goal and more info to documentation re: how to make goals and tools

This commit is contained in:
Laine
2025-03-17 16:01:30 -04:00
parent d20c6c53a5
commit c1b662090d
6 changed files with 179 additions and 30 deletions

View File

@@ -12,6 +12,9 @@ from .hr.current_pto import current_pto
from .hr.book_pto import book_pto
from .hr.future_pto_calc import future_pto_calc
from .give_hint import give_hint
from .guess_location import guess_location
def get_handler(tool_name: str):
if tool_name == "SearchFixtures":
@@ -38,5 +41,9 @@ def get_handler(tool_name: str):
return book_pto
if tool_name == "FuturePTOCalc":
return future_pto_calc
if tool_name == "GiveHint":
return give_hint
if tool_name == "GuessLocation":
return guess_location
raise ValueError(f"Unknown tool: {tool_name}")

42
tools/give_hint.py Normal file
View File

@@ -0,0 +1,42 @@
TREASURE_LOCATION = {
"address": "300 Lenora",
"city": "Seattle",
"state_full": "Washington",
"state_abbrev": "WA",
"zip": "98121",
"country": "USA"
}
HINTS = [
"state of Washington",
"city of Seattle",
"at a company HQ",
]
''' Grok provided hints:
Here are additional company-specific clues about Temporal that could help players in your game guess the address (300 Lenora St, Seattle, WA) by focusing on the company itself. These are designed to be intriguing and game-friendly:
"This company was founded by two engineers who previously worked on a system named after a South American river at Uber."
"Their platform is all about orchestrating workflows that can survive failures—like a conductor keeping the music going."
"They offer a tool that lets developers write code as if its running forever, no matter what crashes."
"The companys tech traces its roots to a project called Cadence, which they took to the next level."
"Their mission is tied to making distributed systems feel as simple as writing a single app."
"Theyve got a knack for durability—both in their software and their growing reputation."
"This outfit spun out of experiences at AWS and Uber, blending cloud and ride-sharing know-how."
"Their open-source framework has a community thats ticking along, fixing bugs and adding features daily."
"Theyre backed by big venture capital names like Sequoia, betting on their vision for reliable software."
"The companys name might remind you of a word for something fleeting, yet their tech is built to last."'''
def give_hint(args: dict) -> dict:
hint_total = args.get("hint_total")
if hint_total is None:
hint_total = 0
index = hint_total % len(HINTS)
hint_text = HINTS[index]
print(f"hint_total: {hint_total}, length: {len(HINTS)}, index: {index}")
hint_total = hint_total + 1
return {
"hint_number": hint_total,
"hint": hint_text
}

View File

@@ -47,6 +47,55 @@ goal_choose_agent_type = AgentGoal(
),
)
# Easter egg - if silly mode = a pirate, include goal_pirate_treasure as a "system" goal so it always shows up.
# Can also turn make this goal available by setting the GOAL_CATEGORIES in the env file to include 'pirate', but if SILLY_MODE
# is not 'a pirate', the interaction as a whole will be less pirate-y.
pirate_category_tag = "pirate"
if SILLY_MODE == "a pirate":
pirate_category_tag = "system"
goal_pirate_treasure = AgentGoal(
id = "goal_pirate_treasure",
category_tag=pirate_category_tag,
agent_name="Arrr, Find Me Treasure!",
agent_friendly_description="Sail the high seas and find me pirate treasure, ye land lubber!",
tools=[
tool_registry.give_hint_tool,
tool_registry.guess_location_tool,
tool_registry.list_agents_tool,
],
description="The user wants to find a pirate treasure. "
"Help the user gather args for these tools, in a loop, until treasure_found is True or the user requests to be done: "
"1. GiveHint: If the user wants a hint regarding the location of the treasure, give them a hint. If they do not want a hint, this tool is optional."
"2. GuessLocation: The user guesses where the treasure is, by giving an address. ",
starter_prompt=starter_prompt_generic,
example_conversation_history="\n ".join(
[
"user: I'd like to try to find the treasure",
"agent: Sure! Do you want a hint?",
"user: yes",
"agent: Here is hint number 1!",
"user_confirmed_tool_run: <user clicks confirm on GiveHint tool>",
"tool_result: { 'hint_number': 1, 'hint': 'The treasure is in the state of Arizona.' }",
"agent: The treasure is in the state of Arizona. Would you like to guess the address of the treasure? ",
"user: Yes, address is 123 Main St Phoenix, AZ",
"agent: Let's see if you found the treasure...",
"user_confirmed_tool_run: <user clicks confirm on GuessLocation tool>"
"tool_result: {'treasure_found':False}",
"agent: Nope, that's not the right location! Do you want another hint?",
"user: yes",
"agent: Here is hint number 2.",
"user_confirmed_tool_run: <user clicks confirm on GiveHint tool>",
"tool_result: { 'hint_number': 2, 'hint': 'The treasure is in the city of Tucson, AZ.' }",
"agent: The treasure is in the city of Tucson, AZ. Would you like to guess the address of the treasure? ",
"user: Yes, address is 456 Main St Tucson, AZ",
"agent: Let's see if you found the treasure...",
"user_confirmed_tool_run: <user clicks confirm on GuessLocation tool>",
"tool_result: {'treasure_found':True}",
"agent: Congratulations, Land Lubber, you've found the pirate treasure!",
]
),
)
goal_match_train_invoice = AgentGoal(
id = "goal_match_train_invoice",
category_tag="travel",
@@ -181,6 +230,7 @@ goal_hr_schedule_pto = 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_pirate_treasure)
goal_list.append(goal_event_flight_invoice)
goal_list.append(goal_match_train_invoice)
goal_list.append(goal_hr_schedule_pto)

18
tools/guess_location.py Normal file
View File

@@ -0,0 +1,18 @@
from .give_hint import TREASURE_LOCATION
def guess_location(args: dict) -> dict:
guess_address = args.get("address").lower()
guess_city = args.get("city").lower()
guess_state = args.get("state").lower()
if len(guess_state) == 2:
compare_state = TREASURE_LOCATION.get("state_abbrev").lower()
else:
compare_state = TREASURE_LOCATION.get("state_full").lower()
#Check for the street address to be included in the guess to account for "st" vs "street" or leaving Street off entirely
if TREASURE_LOCATION.get("address").lower() in guess_address and TREASURE_LOCATION.get("city").lower() == guess_city and compare_state == guess_state:
return {"treasure_found": "True"}
else:
return {"treasure_found": "False"}

View File

@@ -1,5 +1,5 @@
from models.tool_definitions import ToolDefinition, ToolArgument
# ----- System tools -----
list_agents_tool = ToolDefinition(
name="ListAgents",
description="List available agents to interact with, pulled from goal_registry. ",
@@ -18,6 +18,39 @@ change_goal_tool = ToolDefinition(
],
)
give_hint_tool = ToolDefinition(
name="GiveHint",
description="Give a hint to the user regarding the location of the pirate treasure. Use previous conversation to determine the hint_total, it should initially be 0 ",
arguments=[
ToolArgument(
name="hint_total",
type="number",
description="How many hints have been given",
),],
)
guess_location_tool = ToolDefinition(
name="GuessLocation",
description="Allow the user to guess the location (in the form of an address) of the pirate treasure. ",
arguments=[
ToolArgument(
name="address",
type="string",
description="Address at which the user is guessing the treasure is located",
),
ToolArgument(
name="city",
type="string",
description="City at which the user is guessing the treasure is located",
),
ToolArgument(
name="state",
type="string",
description="State at which the user is guessing the treasure is located",
),
],
)
# ----- Travel use cases tools -----
search_flights_tool = ToolDefinition(
name="SearchFlights",
description="Search for return flights from an origin to a destination within a date range (dateDepart, dateReturn).",
@@ -143,6 +176,7 @@ find_events_tool = ToolDefinition(
],
)
# ----- HR use cases tools -----
current_pto_tool = ToolDefinition(
name="CurrentPTO",
description="Find how much PTO a user currently has accrued. "
@@ -179,23 +213,6 @@ future_pto_calc_tool = ToolDefinition(
],
)
calendar_conflict_tool = ToolDefinition(
name="CalendarConflict",
description="Determine if the proposed PTO date(s) have conflicts. Returns list of conflicts. ",
arguments=[
ToolArgument(
name="check_self_calendar",
type="boolean",
description="Check self calendar for conflicts?",
),
ToolArgument(
name="check_team_calendar",
type="boolean",
description="Check team calendar for conflicts?",
),
],
)
book_pto_tool = ToolDefinition(
name="BookPTO",
description="Book PTO start and end date. Either 1) makes calendar item, or 2) sends calendar invite to self and boss? "