Add source mocked data file, make current_pto tool functional, rename future_pto to future_pto_calc

This commit is contained in:
Laine
2025-03-13 11:33:38 -04:00
parent ea1ad383bb
commit 5c3bfcf957
8 changed files with 66 additions and 24 deletions

View File

@@ -17,6 +17,17 @@ The agent is set up to allow for multiple goals and to switch back to choosing a
### Adding Tools
#### Notes
Tools can be optional - you can indicate this in the tool listing of goal description (see above section re: goal registry) by adding something like, "This step is optional and can be skipped by moving to the next tool." Here is an example from the CalendarConflict tool/step of the [goal_hr_schedule_pto](tools/goal_registry.py#L134) goal:
```
description="Help the user gather args for these tools in order: "
"1. CurrentPTO: Tell the user how much PTO they currently have "
"2. FuturePTO: Tell the user how much PTO they will have as of the prospective date "
"3. CalendarConflict: Tell the user what conflicts if any exist around the prospective date on a list of calendars. This step is optional and can be skipped by moving to the next tool. "
"4. BookPTO: Book PTO "
```
#### Add to Tool Registry
- `tool_registry.py` contains the mapping of tool names to tool definitions (so the AI understands how to use them)
- `name`:

14
todo.md
View File

@@ -17,12 +17,11 @@
[ ] create tests<br />
[ ] create people management scenarios <br />
[ ] 1. Book PTO
-- check current PTO level <br />
-- determine PTO available as of date <br />
-- check for personal calendar conflicts <br />
-- check for team calendar conflicts <br />
-- book PTO around a date (send calendar invite?) (https://developers.google.com/calendar/api/guides/overview)? <br />
[x] 1. Schedule PTO goal
-- [ ] check current PTO level <br />
-- [ ] determine PTO available as of date <br />
-- [ ] check for personal, team, or both calendar conflicts <br />
-- [ ] book PTO around a date (send calendar invite?) (https://developers.google.com/calendar/api/guides/overview)? <br />
[ ] 2. Others:
-- check pay status <br />
-- book work travel <br />
@@ -45,4 +44,5 @@
[ ] non-retry the api key error - "Invalid API Key provided: sk_test_**J..." and "AuthenticationError" <br />
[ ] make it so you can yeet yourself out of a goal and pick a new one <br />
[ ] add visual feedback when workflow starting
[ ] add visual feedback when workflow starting <br />
[ ] figure out how to allow user to list agents at any time - like end conversation <br />

View File

@@ -11,7 +11,7 @@ from .transfer_control import transfer_control
from .current_pto import current_pto
from .book_pto import book_pto
from .calendar_conflict import calendar_conflict
from .future_pto import future_pto
from .future_pto_calc import future_pto_calc
def get_handler(tool_name: str):
@@ -39,7 +39,7 @@ def get_handler(tool_name: str):
return book_pto
if tool_name == "CalendarConflict":
return calendar_conflict
if tool_name == "FuturePTO":
return future_pto
if tool_name == "FuturePTOCalc":
return future_pto_calc
raise ValueError(f"Unknown tool: {tool_name}")

View File

@@ -1,14 +1,26 @@
from pathlib import Path
import json
def current_pto(args: dict) -> dict:
email = args.get("email")
if email == "bob.johnson@emailzzz.com":
num_hours = 40
else:
num_hours = 20
file_path = Path(__file__).resolve().parent / "data" / "employee_pto_data.json"
if not file_path.exists():
return {"error": "Data file not found."}
data = json.load(open(file_path))
employee_list = data["theCompany"]["employees"]
for employee in employee_list:
if employee["email"] == email:
num_hours = int(employee["currentPTOHrs"])
num_days = float(num_hours/8)
return {
"num_hours": num_hours,
"num_days": num_days,
}
return_msg = "Employee not found with email address " + email
return {"error": return_msg}

View File

@@ -0,0 +1,18 @@
{
"theCompany": {
"weLove": "theCompany",
"accrualPer": "month",
"employees": [
{
"email": "josh.smith@temporal.io",
"currentPTOHrs": 400,
"accrualHrsRate": 8
},
{
"email": "laine.smith@awesome.com",
"currentPTOHrs": 40,
"accrualHrsRate": 12
}
]
}
}

View File

@@ -1,4 +1,4 @@
def future_pto(args: dict) -> dict:
def future_pto_calc(args: dict) -> dict:
start_date = args.get("start_date")
end_date = args.get("end_date")

View File

@@ -131,6 +131,7 @@ goal_event_flight_invoice = AgentGoal(
),
)
# This goal uses the data/employee_pto_data.json file as dummy data.
goal_hr_schedule_pto = AgentGoal(
id = "goal_hr_schedule_pto",
agent_name="Schedule PTO",
@@ -144,8 +145,8 @@ goal_hr_schedule_pto = AgentGoal(
],
description="Help the user gather args for these tools in order: "
"1. CurrentPTO: Tell the user how much PTO they currently have "
"2. FuturePTO: Tell the user how much PTO they will have as of the prospective date "
"3. CalendarConflict: Tell the user what conflicts if any exist around the prospective date on a list of calendars "
"2. FuturePTOCalc: Tell the user how much PTO they will have as of the prospective date "
"3. CalendarConflict: Tell the user what conflicts if any exist around the prospective date on a list of calendars. This step is optional and can be skipped by moving to the next tool. "
"4. BookPTO: Book PTO ",
starter_prompt=starter_prompt_generic,
example_conversation_history="\n ".join(
@@ -170,7 +171,7 @@ goal_hr_schedule_pto = AgentGoal(
"user: yes "
"user_confirmed_tool_run: <user clicks confirm on BookPTO tool>",
'tool_result: { "status": "success" }',
"agent: PTO successfully booked! Would you like to speak to another agent? ",
"agent: PTO successfully booked! ",
]
),
)

View File

@@ -157,7 +157,7 @@ current_pto_tool = ToolDefinition(
)
future_pto_calc_tool = ToolDefinition(
name="FuturePTO",
name="FuturePTOCalc",
description="Calculate if the user will have enough PTO as of their proposed date to accommodate the request. Returns a boolean enough_pto and "
"how many hours of PTO they will have if they take the proposed dates. ",
arguments=[