From aa0fd19c2005730b7cd908d7fdf0a043b53c9013 Mon Sep 17 00:00:00 2001 From: Steve Androulakis Date: Fri, 14 Feb 2025 11:35:20 -0800 Subject: [PATCH] prompt engineering --- enterprise/SingleOrArrayConverter.cs | 29 ---------------------------- tools/goal_registry.py | 21 ++++++++++++-------- 2 files changed, 13 insertions(+), 37 deletions(-) delete mode 100644 enterprise/SingleOrArrayConverter.cs diff --git a/enterprise/SingleOrArrayConverter.cs b/enterprise/SingleOrArrayConverter.cs deleted file mode 100644 index f98f27e..0000000 --- a/enterprise/SingleOrArrayConverter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace TrainSearchWorker.Converters -{ - public class SingleOrArrayConverter : JsonConverter> - { - public override List Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType == JsonTokenType.StartArray) - { - return JsonSerializer.Deserialize>(ref reader, options) ?? new List(); - } - else - { - // Single element – wrap it in a list. - T element = JsonSerializer.Deserialize(ref reader, options); - return new List { element }; - } - } - - public override void Write(Utf8JsonWriter writer, List value, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, value, options); - } - } -} diff --git a/tools/goal_registry.py b/tools/goal_registry.py index 858589d..c440685 100644 --- a/tools/goal_registry.py +++ b/tools/goal_registry.py @@ -27,17 +27,22 @@ goal_match_train_invoice = AgentGoal( "user: Wolves in May please", "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! ", + 'tool_result: SearchFixtures responds in this JSON format and the results are parsed by the agent below {"fixtures": [{"awayTeam": "West Ham United FC","date": "2025-04-01","homeTeam": "Wolverhampton Wanderers FC"},...,' + "agent: I found 4 Wolves matches in May 2025: 1. Man City vs Wolves (Away) - May 3 2. Wolves vs Brighton (Home) - May 10 3. Crystal Palace vs Wolves (Away) - May 18 4. Wolves vs Brentford (Home) - May 25 Which match would you like to attend? I'll help you find trains from London.", + "user: How about the Man City match", + "agent: Great! Let's find trains to Manchester and back for the match.", "user_confirmed_tool_run: ", - "tool_result: ", - "agent: Found some trains! ", + 'tool_result: SearchTrains responds in this JSON format and the results are parsed by the agent below: {"journeys": [{"arrival": "Manchester","arrival_time": "2025-04-18T12:11","departure": "London","departure_time": "2025-04-18T11:00","id": "T8049","platform": "1","price": 73.5,"type": "outbound"},', + "agent: I found several train options for your journey to Manchester including outbound options on May 9 at 11am, 3:30pm and 4:30pm and return options on May 11 at 9am, 11am and 1pm. Which trains would you like to book?", + "user: I'd like the 11am outbound and 3:30pm return", + "agent: Sounds good, let's book train tickets for the 11am outbound and 3:30pm return trains on May 9 and May 11, one day before and after the match.", "user_confirmed_tool_run: ", - 'tool_result: results including {"status": "success"}', - "agent: Train tickets booked! Please confirm the following invoice for the journey. ", + 'tool_result: BookTrains responds in this JSON format and the results are parsed by the agent belowg [{"booking_reference": "BR10879","journey_id": "T9532,T1027","status": "confirmed"}]', + "agent: Your train tickets have been booked. Would you like me to create an invoice now for the cost of the train tickets?", + "user: Sure", "user_confirmed_tool_run: ", - "tool_result: contains an invoiceURL", - "agent: Great! I've generated your invoice for your trains to the . You can view and pay your invoice at this link: https://invoice.stripe.com/i/acct_1NBOLuKVZbzw7QA5/test_YWNjdF8xTkJPTHVLVlpienc3UUE1LF9SaHlBTU9GYnFibEJ4VlpNaThkWkhrcUR6a1dwTmNULDEyOTE2MjkwNA0200CCUNvTox?s=ap", + 'tool_result: CreateInvoice responds in this JSON format and the results are parsed by the agent below (including a link to the invoice): {"invoiceStatus": "open","invoiceURL": "https://invoice.stripe.com/i/acct_1NBOLuKVZbzw7QA5/test_YWNjdF8xTkJPTHVLVlpienc3UUE1LF9SbGJlZ2xLMjhlc3lxNzFkVVBXbkswOUlFa2Rna1RxLDEzMDAwMTY4Nw0200RLeJRMlw?s=ap","reference": "F9B01CD7-0001"}', + "agent: Great! I've generated your invoice for your trains to the Manchester City match on the 10th of May. You can view and pay your invoice at this link: https://invoice.stripe.com/i/acct_1NBOLuKVZbzw7QA5/test_YWNjdF8xTkJPTHVLVlpienc3UUE1LF9SbGJlZ2xLMjhlc3lxNzFkVVBXbkswOUlFa2Rna1RxLDEzMDAwMTY4Nw0200RLeJRMlw?s=ap", ] ), )