diff --git a/activities/tool_activities.py b/activities/tool_activities.py index d7617a4..f08f202 100644 --- a/activities/tool_activities.py +++ b/activities/tool_activities.py @@ -57,18 +57,20 @@ class ToolActivities: # Create validation prompt validation_prompt = f"""The user's prompt is: "{validation_input.prompt}" Please validate if this prompt makes sense given the agent goal and conversation history. - If the prompt doesn't make sense toward the goal then validationResult should be true. - Only return false if the prompt is nonsensical given the goal, tools available, and conversation history. + If the prompt makes sense toward the goal then validationResult should be true. + If the prompt is wildly nonsensical or makes no sense toward the goal and current conversation history then validationResult should be false. + If the response is low content such as "yes" or "that's right" then the user is probably responding to a previous prompt. + Therefore examine it in the context of the conversation history to determine if it makes sense and return true if it makes sense. Return ONLY a JSON object with the following structure: "validationResult": true/false, - "validationFailedReason": "If validationResult is false, provide a clear explanation to the user + "validationFailedReason": "If validationResult is false, provide a clear explanation to the user in the response field about why their request doesn't make sense in the context and what information they should provide instead. validationFailedReason should contain JSON in the format {{ "next": "question", "response": "[your reason here and a response to get the user back on track with the agent goal]" }} - If validationResult is true, return an empty dict {{}}" + If validationResult is true (the prompt makes sense), return an empty dict as its value {{}}" """ # Call the LLM with the validation prompt @@ -172,8 +174,10 @@ class ToolActivities: genai.configure(api_key=api_key) model = genai.GenerativeModel( - "models/gemini-2.0-flash-exp", - system_instruction=input.context_instructions, + "models/gemini-1.5-flash", + system_instruction=input.context_instructions + + ". The current date is " + + datetime.now().strftime("%B %d, %Y"), ) response = model.generate_content(input.prompt) response_content = response.text @@ -196,8 +200,9 @@ class ToolActivities: response = client.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=1024, - system=input.context_instructions + ". The current date is " - + get_current_date_human_readable(), + system=input.context_instructions + + ". The current date is " + + get_current_date_human_readable(), messages=[ { "role": "user", diff --git a/thirdparty/train_api.py b/thirdparty/train_api.py index 891be9f..d5dd584 100644 --- a/thirdparty/train_api.py +++ b/thirdparty/train_api.py @@ -23,17 +23,23 @@ def parse_datetime(datetime_str): "%Y-%m-%dT%H:%M", # e.g. "2025-04-18T09:00" "%Y-%m-%dT%H:%M:%S", # e.g. "2025-04-18T09:00:00" "%Y-%m-%d %H:%M:%S", # e.g. "2025-04-18 09:00:00" + "%Y-%m-%d", # e.g. "2025-04-11" ] for fmt in formats: try: parsed = time.strptime(datetime_str, fmt) + if fmt == "%Y-%m-%d": + # Default to 9am if no time provided + hour, minute = 9, 0 + else: + hour, minute = parsed.tm_hour, parsed.tm_min return ( parsed.tm_year, parsed.tm_mon, parsed.tm_mday, - parsed.tm_hour, - parsed.tm_min, + hour, + minute, ) except ValueError: continue diff --git a/tools/goal_registry.py b/tools/goal_registry.py index d7f8060..55f363d 100644 --- a/tools/goal_registry.py +++ b/tools/goal_registry.py @@ -16,9 +16,9 @@ goal_match_train_invoice = AgentGoal( ], description="Help the user book trains to a premier league match. The user lives in London. Gather args for these tools in order: " "1. SearchFixtures: Search for fixtures for a team in a given month" - "2. SearchTrains: Search for trains to visit somewhere before or after the match" + "2. SearchTrains: Search for trains to the city of the match and list them for the customer to choose from" "3. BookTrain: Book the train tickets" - "4. CreateInvoice: Create a simple invoice for the cost of the flights and train tickets", + "4. CreateInvoice: Proactively offer to create a simple invoice for the cost of the flights and train tickets", starter_prompt="Welcome me, give me a description of what you can do, then ask me for the details you need to do your job", example_conversation_history="\n ".join( [ @@ -28,13 +28,13 @@ goal_match_train_invoice = AgentGoal( "agent: Great! Let's find a match for Wolverhampton Wanderers FC in May.", "user_confirmed_tool_run: ", 'tool_result: results including {"homeTeam": "Wolverhampton Wanderers FC", "awayTeam": "Manchester United", "date": "2025-05-04"}', - "agent: Found a match! There's an away game against Manchester United on May 4 2025. Would you like to plan train travel from London for around this date?", + "agent: Found a match! ", "user_confirmed_tool_run: ", - "tool_result: results including train dates and times, origin and depature stations", - "agent: Found some trains! The best option is leaving on