diff --git a/src/TimesheetGPT.Core/Interfaces/IGraphService.cs b/src/TimesheetGPT.Core/Interfaces/IGraphService.cs index 79c5c03..7e68073 100644 --- a/src/TimesheetGPT.Core/Interfaces/IGraphService.cs +++ b/src/TimesheetGPT.Core/Interfaces/IGraphService.cs @@ -8,5 +8,5 @@ public interface IGraphService public Task> GetSentEmails(DateTime date, CancellationToken cancellationToken); public Task> GetMeetings(DateTime date, CancellationToken cancellationToken); public Task> GetTeamsCalls(DateTime date); - Task GetEmailBody(string subject); + Task GetEmailBody(string subject, CancellationToken ct); } diff --git a/src/TimesheetGPT.Core/Plugins.cs b/src/TimesheetGPT.Core/Plugins.cs index c3c8b6a..2e59baa 100644 --- a/src/TimesheetGPT.Core/Plugins.cs +++ b/src/TimesheetGPT.Core/Plugins.cs @@ -12,7 +12,7 @@ public class GraphPlugins(IGraphService graphService) [SKFunction, Description("Get email body from Id")] public async Task GetEmailBody(string id) { - return (await graphService.GetEmailBody(id)).Body; + return (await graphService.GetEmailBody(id, new CancellationToken())).Body; } [SKFunction, Description("Get sent emails (subject, to, Id) for a date)")] @@ -32,6 +32,7 @@ public async Task GetMeetings(DateTime dateTime) [SKFunction, Description("Get todays date")] public string GetTodaysDate(DateTime dateTime) { + //TODO: Use browser datetime return DateTime.Today.ToString(CultureInfo.InvariantCulture); } diff --git a/src/TimesheetGPT.Core/PromptTemplates.cs b/src/TimesheetGPT.Core/PromptTemplates.cs index d92a61b..4d7dc37 100644 --- a/src/TimesheetGPT.Core/PromptTemplates.cs +++ b/src/TimesheetGPT.Core/PromptTemplates.cs @@ -8,7 +8,7 @@ Generate a concise timesheet summary in chronological order from my meetings and 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. They indicate the client I worked for or, if tagged with 'SSW,' an internal focus day. + 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. Note that emails starting with 'RE:' are replies, not new tasks. An email titled 'Sprint X Review' means I led that Sprint review/retro. diff --git a/src/TimesheetGPT.Core/Services/GraphService.cs b/src/TimesheetGPT.Core/Services/GraphService.cs index af46693..b32145d 100644 --- a/src/TimesheetGPT.Core/Services/GraphService.cs +++ b/src/TimesheetGPT.Core/Services/GraphService.cs @@ -112,14 +112,14 @@ public async Task> GetTeamsCalls(DateTime date) return new List(); } - public async Task GetEmailBody(string id) + public async Task GetEmailBody(string id, CancellationToken ct) { var message = await _client.Me.Messages[id] .GetAsync(rc => { rc.QueryParameters.Select = new[] { "bodyPreview", "toRecipients" }; - }); + }, ct); if (message != null) { diff --git a/src/TimesheetGPT.Core/Services/SemKerAiService.cs b/src/TimesheetGPT.Core/Services/SemKerAiService.cs index 1720198..c3ff351 100644 --- a/src/TimesheetGPT.Core/Services/SemKerAiService.cs +++ b/src/TimesheetGPT.Core/Services/SemKerAiService.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Planners; +using System.Text; using TimesheetGPT.Core.Interfaces; using TimesheetGPT.Core.Models; @@ -68,22 +69,27 @@ public async Task GetSummaryBoring(IList emails, IEnumerable meetings) { - var result = "Calendar Events (name - length) \n"; + var sb = new StringBuilder(); + sb.AppendLine("Calendar Events (name - length)"); + foreach (var meeting in meetings) { - result += $"{meeting.Name} - {meeting.Length} \n"; + sb.AppendLine($"{meeting.Name} - {meeting.Length}"); } - return result; + return sb.ToString(); } + private static string StringifyEmails(IEnumerable emails) { - var result = "Sent emails (recipients - subject - bodyPreview) \n"; + var sb = new StringBuilder(); + sb.AppendLine("Sent emails (recipients - subject - bodyPreview)"); + foreach (var email in emails) { - result += $"{email.To} - {email.Subject} \n"; + sb.AppendLine($"{email.To} - {email.Subject}"); } - return result; + return sb.ToString(); } }