From 4094930cc4c471e46ded158f3e9350890898b130 Mon Sep 17 00:00:00 2001 From: "Brady Stroud [SSW]" Date: Mon, 22 Jan 2024 18:04:52 -0800 Subject: [PATCH] Improve prompt --- src/TimesheetGPT.Core/PromptTemplates.cs | 6 +-- .../Services/GraphService.cs | 42 ++++++++++--------- .../Services/SemKerAiService.cs | 3 +- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/TimesheetGPT.Core/PromptTemplates.cs b/src/TimesheetGPT.Core/PromptTemplates.cs index 4d7dc37..8e191c8 100644 --- a/src/TimesheetGPT.Core/PromptTemplates.cs +++ b/src/TimesheetGPT.Core/PromptTemplates.cs @@ -6,7 +6,6 @@ public static class PromptTemplates public static readonly string SummarizeEmailsAndCalendar = $""" Generate a concise timesheet summary in chronological order from my meetings and emails. - For meetings, follow the format 'Meeting Name - Meeting Length' Skip non-essential meetings like Daily Scrums. Treat all-day (or 9-hour) meetings as bookings e.g. Brady was booked as the Bench Master. Use email subjects to figure out what tasks were completed. @@ -14,8 +13,9 @@ Use email subjects to figure out what tasks were completed. An email titled 'Sprint X Review' means I led that Sprint review/retro. Merge meetings and emails into one summary. If an item appears in both, mention it just once. Ignore the day's meetings if an email is marked 'Sick Today.' - Appointments labeled 'Leave' should be omitted. - Only output the timesheet summary so i can copy it directly. Use a Markdown unordered list, keeping it lighthearted with a few emojis. 🌟 + Omit emails regarding event non-participation like 'Declined: NDC Sydney 2024.' + Appointments containing 'leave' should be omitted. + Only output the timesheet summary so i can copy it directly. Use a Markdown unordered list, keeping it lighthearted with a few emojis. {PromptVarFormatter(PromptVariables.ExtraPrompts)} diff --git a/src/TimesheetGPT.Core/Services/GraphService.cs b/src/TimesheetGPT.Core/Services/GraphService.cs index b32145d..4924797 100644 --- a/src/TimesheetGPT.Core/Services/GraphService.cs +++ b/src/TimesheetGPT.Core/Services/GraphService.cs @@ -29,25 +29,29 @@ public async Task> GetSentEmails(DateTime date, CancellationToken ca { rc.QueryParameters.Top = 999; rc.QueryParameters.Select = - new[] { "subject", "bodyPreview", "toRecipients", "id" }; + ["subject", "bodyPreview", "toRecipients", "id"]; rc.QueryParameters.Filter = $"sentDateTime ge {dateUtc:yyyy-MM-ddTHH:mm:ssZ} and sentDateTime lt {nextDayUtc:yyyy-MM-ddTHH:mm:ssZ}"; - rc.QueryParameters.Orderby = new[] { "sentDateTime asc" }; + rc.QueryParameters.Orderby = ["sentDateTime asc"]; }, cancellationToken); if (messages is { Value.Count: > 1 }) { - return new List(messages.Value.Select(m => new Email - { - Subject = m.Subject, - Body = m.BodyPreview ?? "", - To = string.Join(", ", m.ToRecipients?.Select(r => r.EmailAddress?.Name).ToList() ?? new List()), - Id = m.Id - })); + return + [ + ..messages.Value.Select(m => new Email + { + Subject = m.Subject, + Body = m.BodyPreview ?? "", + To = string.Join(", ", + m.ToRecipients?.Select(r => r.EmailAddress?.Name).ToList() ?? []), + Id = m.Id + }) + ]; } - return new List(); //slack + return []; //slack } @@ -62,8 +66,8 @@ public async Task> GetMeetings(DateTime date, CancellationToken ca rc.QueryParameters.Top = 999; rc.QueryParameters.StartDateTime = dateUtc.ToString("o"); rc.QueryParameters.EndDateTime = nextDayUtc.ToString("o"); - rc.QueryParameters.Orderby = new[] { "start/dateTime" }; - rc.QueryParameters.Select = new[] { "subject", "start", "end", "occurrenceId" }; + rc.QueryParameters.Orderby = ["start/dateTime"]; + rc.QueryParameters.Select = ["subject", "start", "end", "occurrenceId"]; }, cancellationToken); if (meetings is { Value.Count: > 1 }) @@ -77,7 +81,7 @@ public async Task> GetMeetings(DateTime date, CancellationToken ca }).ToList(); } - return new List(); //slack + return []; //slack } public async Task> GetTeamsCalls(DateTime date) { @@ -90,8 +94,8 @@ public async Task> GetTeamsCalls(DateTime date) var calls = await _client.Communications.CallRecords.GetAsync(rc => { rc.QueryParameters.Top = 999; - rc.QueryParameters.Orderby = new[] { "startDateTime" }; - rc.QueryParameters.Select = new[] { "startDateTime", "endDateTime", "participants" }; + rc.QueryParameters.Orderby = ["startDateTime"]; + rc.QueryParameters.Select = ["startDateTime", "endDateTime", "participants"]; rc.QueryParameters.Filter = $"startDateTime ge {dateUtc:o} and endDateTime lt {nextDayUtc:o}"; }); @@ -99,7 +103,7 @@ public async Task> GetTeamsCalls(DateTime date) { return calls.Value.Select(m => new TeamsCall { - Attendees = m.Participants?.Select(p => p.User?.DisplayName).ToList() ?? new List(), + Attendees = m.Participants?.Select(p => p.User?.DisplayName).ToList() ?? [], Length = m.EndDateTime - m.StartDateTime ?? TimeSpan.Zero, }).ToList(); } @@ -109,7 +113,7 @@ public async Task> GetTeamsCalls(DateTime date) throw new Exception("Need CallRecords.Read.All scopes", e); } - return new List(); + return []; } public async Task GetEmailBody(string id, CancellationToken ct) @@ -118,7 +122,7 @@ public async Task GetEmailBody(string id, CancellationToken ct) .GetAsync(rc => { rc.QueryParameters.Select = - new[] { "bodyPreview", "toRecipients" }; + ["bodyPreview", "toRecipients"]; }, ct); if (message != null) @@ -126,7 +130,7 @@ public async Task GetEmailBody(string id, CancellationToken ct) return new Email { Body = message.BodyPreview, - To = string.Join(", ", (message.ToRecipients ?? new List()).Select(r => r.EmailAddress?.Name).ToList()) + To = string.Join(", ", (message.ToRecipients ?? []).Select(r => r.EmailAddress?.Name).ToList()) }; } diff --git a/src/TimesheetGPT.Core/Services/SemKerAiService.cs b/src/TimesheetGPT.Core/Services/SemKerAiService.cs index c151d92..f9bf4c6 100644 --- a/src/TimesheetGPT.Core/Services/SemKerAiService.cs +++ b/src/TimesheetGPT.Core/Services/SemKerAiService.cs @@ -48,7 +48,8 @@ public async Task GetSummaryBoring(IList emails, IEnumerable