mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-15 14:08:08 +01:00
Add source mocked data file, make current_pto tool functional, rename future_pto to future_pto_calc
This commit is contained in:
@@ -17,6 +17,17 @@ The agent is set up to allow for multiple goals and to switch back to choosing a
|
|||||||
|
|
||||||
### Adding Tools
|
### 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
|
#### Add to Tool Registry
|
||||||
- `tool_registry.py` contains the mapping of tool names to tool definitions (so the AI understands how to use them)
|
- `tool_registry.py` contains the mapping of tool names to tool definitions (so the AI understands how to use them)
|
||||||
- `name`:
|
- `name`:
|
||||||
|
|||||||
14
todo.md
14
todo.md
@@ -17,12 +17,11 @@
|
|||||||
[ ] create tests<br />
|
[ ] create tests<br />
|
||||||
|
|
||||||
[ ] create people management scenarios <br />
|
[ ] create people management scenarios <br />
|
||||||
[ ] 1. Book PTO
|
[x] 1. Schedule PTO goal
|
||||||
-- check current PTO level <br />
|
-- [ ] check current PTO level <br />
|
||||||
-- determine PTO available as of date <br />
|
-- [ ] determine PTO available as of date <br />
|
||||||
-- check for personal calendar conflicts <br />
|
-- [ ] check for personal, team, or both 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 />
|
||||||
-- book PTO around a date (send calendar invite?) (https://developers.google.com/calendar/api/guides/overview)? <br />
|
|
||||||
[ ] 2. Others:
|
[ ] 2. Others:
|
||||||
-- check pay status <br />
|
-- check pay status <br />
|
||||||
-- book work travel <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 />
|
[ ] 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 />
|
[ ] 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 />
|
||||||
@@ -11,7 +11,7 @@ from .transfer_control import transfer_control
|
|||||||
from .current_pto import current_pto
|
from .current_pto import current_pto
|
||||||
from .book_pto import book_pto
|
from .book_pto import book_pto
|
||||||
from .calendar_conflict import calendar_conflict
|
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):
|
def get_handler(tool_name: str):
|
||||||
@@ -39,7 +39,7 @@ def get_handler(tool_name: str):
|
|||||||
return book_pto
|
return book_pto
|
||||||
if tool_name == "CalendarConflict":
|
if tool_name == "CalendarConflict":
|
||||||
return calendar_conflict
|
return calendar_conflict
|
||||||
if tool_name == "FuturePTO":
|
if tool_name == "FuturePTOCalc":
|
||||||
return future_pto
|
return future_pto_calc
|
||||||
|
|
||||||
raise ValueError(f"Unknown tool: {tool_name}")
|
raise ValueError(f"Unknown tool: {tool_name}")
|
||||||
|
|||||||
@@ -1,14 +1,26 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
def current_pto(args: dict) -> dict:
|
def current_pto(args: dict) -> dict:
|
||||||
|
|
||||||
email = args.get("email")
|
email = args.get("email")
|
||||||
if email == "bob.johnson@emailzzz.com":
|
|
||||||
num_hours = 40
|
|
||||||
else:
|
|
||||||
num_hours = 20
|
|
||||||
|
|
||||||
num_days = float(num_hours/8)
|
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"]
|
||||||
|
|
||||||
return {
|
for employee in employee_list:
|
||||||
"num_hours": num_hours,
|
if employee["email"] == email:
|
||||||
"num_days": num_days,
|
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}
|
||||||
18
tools/data/employee_pto_data.json
Normal file
18
tools/data/employee_pto_data.json
Normal 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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
def future_pto(args: dict) -> dict:
|
def future_pto_calc(args: dict) -> dict:
|
||||||
|
|
||||||
start_date = args.get("start_date")
|
start_date = args.get("start_date")
|
||||||
end_date = args.get("end_date")
|
end_date = args.get("end_date")
|
||||||
@@ -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(
|
goal_hr_schedule_pto = AgentGoal(
|
||||||
id = "goal_hr_schedule_pto",
|
id = "goal_hr_schedule_pto",
|
||||||
agent_name="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: "
|
description="Help the user gather args for these tools in order: "
|
||||||
"1. CurrentPTO: Tell the user how much PTO they currently have "
|
"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 "
|
"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 "
|
"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 ",
|
"4. BookPTO: Book PTO ",
|
||||||
starter_prompt=starter_prompt_generic,
|
starter_prompt=starter_prompt_generic,
|
||||||
example_conversation_history="\n ".join(
|
example_conversation_history="\n ".join(
|
||||||
@@ -170,7 +171,7 @@ goal_hr_schedule_pto = AgentGoal(
|
|||||||
"user: yes "
|
"user: yes "
|
||||||
"user_confirmed_tool_run: <user clicks confirm on BookPTO tool>",
|
"user_confirmed_tool_run: <user clicks confirm on BookPTO tool>",
|
||||||
'tool_result: { "status": "success" }',
|
'tool_result: { "status": "success" }',
|
||||||
"agent: PTO successfully booked! Would you like to speak to another agent? ",
|
"agent: PTO successfully booked! ",
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ current_pto_tool = ToolDefinition(
|
|||||||
)
|
)
|
||||||
|
|
||||||
future_pto_calc_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 "
|
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. ",
|
"how many hours of PTO they will have if they take the proposed dates. ",
|
||||||
arguments=[
|
arguments=[
|
||||||
|
|||||||
Reference in New Issue
Block a user