prompt engineering

This commit is contained in:
Steve Androulakis
2025-02-14 11:35:20 -08:00
parent 6f40b96ef6
commit aa0fd19c20
2 changed files with 13 additions and 37 deletions

View File

@@ -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<T> : JsonConverter<List<T>>
{
public override List<T> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.StartArray)
{
return JsonSerializer.Deserialize<List<T>>(ref reader, options) ?? new List<T>();
}
else
{
// Single element wrap it in a list.
T element = JsonSerializer.Deserialize<T>(ref reader, options);
return new List<T> { element };
}
}
public override void Write(Utf8JsonWriter writer, List<T> value, JsonSerializerOptions options)
{
JsonSerializer.Serialize(writer, value, options);
}
}
}

View File

@@ -27,17 +27,22 @@ goal_match_train_invoice = AgentGoal(
"user: Wolves in May please", "user: Wolves in May please",
"agent: Great! Let's find a match for Wolverhampton Wanderers FC in May.", "agent: Great! Let's find a match for Wolverhampton Wanderers FC in May.",
"user_confirmed_tool_run: <user clicks confirm on SearchFixtures tool, passing the full team name as an input>", "user_confirmed_tool_run: <user clicks confirm on SearchFixtures tool, passing the full team name as an input>",
'tool_result: results including {"homeTeam": "Wolverhampton Wanderers FC", "awayTeam": "Manchester United", "date": "2025-05-04"}', '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: Found a match! <agent provides a human-readable list of match options including the location and date>", "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: <user clicks confirm on SearchTrains tool>", "user_confirmed_tool_run: <user clicks confirm on SearchTrains tool>",
"tool_result: <results including train dates and times, origin and depature stations>", '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: Found some trains! <agent provides a human-readable list of train options>", "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: <user clicks confirm on BookTrains tool>", "user_confirmed_tool_run: <user clicks confirm on BookTrains tool>",
'tool_result: results including {"status": "success"}', '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: Train tickets booked! Please confirm the following invoice for the journey. <agent infers total amount for the invoice and details from the conversation history>", "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: <user clicks confirm on CreateInvoice tool which includes details of the train journey, the match, and the total cost>", "user_confirmed_tool_run: <user clicks confirm on CreateInvoice tool which includes details of the train journey, the match, and the total cost>",
"tool_result: contains an invoiceURL", '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 <match>. You can view and pay your invoice at this link: https://invoice.stripe.com/i/acct_1NBOLuKVZbzw7QA5/test_YWNjdF8xTkJPTHVLVlpienc3UUE1LF9SaHlBTU9GYnFibEJ4VlpNaThkWkhrcUR6a1dwTmNULDEyOTE2MjkwNA0200CCUNvTox?s=ap", "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",
] ]
), ),
) )