Skip to content

Commit

Permalink
Improve prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
bradystroud committed Jan 23, 2024
1 parent fa760e9 commit 4094930
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/TimesheetGPT.Core/PromptTemplates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ 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.
Note that emails starting with 'RE:' are replies, not new tasks.
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)}
Expand Down
42 changes: 23 additions & 19 deletions src/TimesheetGPT.Core/Services/GraphService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,29 @@ public async Task<List<Email>> 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<Email>(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<string?>()),
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<Email>(); //slack
return []; //slack
}


Expand All @@ -62,8 +66,8 @@ public async Task<List<Meeting>> 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 })
Expand All @@ -77,7 +81,7 @@ public async Task<List<Meeting>> GetMeetings(DateTime date, CancellationToken ca
}).ToList();
}

return new List<Meeting>(); //slack
return []; //slack
}
public async Task<List<TeamsCall>> GetTeamsCalls(DateTime date)
{
Expand All @@ -90,16 +94,16 @@ public async Task<List<TeamsCall>> 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}";
});

if (calls is { Value.Count: > 1 })
{
return calls.Value.Select(m => new TeamsCall
{
Attendees = m.Participants?.Select(p => p.User?.DisplayName).ToList() ?? new List<string?>(),
Attendees = m.Participants?.Select(p => p.User?.DisplayName).ToList() ?? [],
Length = m.EndDateTime - m.StartDateTime ?? TimeSpan.Zero,
}).ToList();
}
Expand All @@ -109,7 +113,7 @@ public async Task<List<TeamsCall>> GetTeamsCalls(DateTime date)
throw new Exception("Need CallRecords.Read.All scopes", e);
}

return new List<TeamsCall>();
return [];
}

public async Task<Email> GetEmailBody(string id, CancellationToken ct)
Expand All @@ -118,15 +122,15 @@ public async Task<Email> GetEmailBody(string id, CancellationToken ct)
.GetAsync(rc =>
{
rc.QueryParameters.Select =
new[] { "bodyPreview", "toRecipients" };
["bodyPreview", "toRecipients"];
}, ct);

if (message != null)
{
return new Email
{
Body = message.BodyPreview,
To = string.Join(", ", (message.ToRecipients ?? new List<Recipient>()).Select(r => r.EmailAddress?.Name).ToList())
To = string.Join(", ", (message.ToRecipients ?? []).Select(r => r.EmailAddress?.Name).ToList())
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/TimesheetGPT.Core/Services/SemKerAiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public async Task<string> GetSummaryBoring(IList<Email> emails, IEnumerable<Meet
var builder = new KernelBuilder();

builder.WithOpenAIChatCompletionService(
"gpt-4-1106-preview", // ⏩
// "gpt-4-1106-preview", // ⏩
"gpt-4", // 💸
_apiKey);

var kernel = builder.Build();
Expand Down

0 comments on commit 4094930

Please sign in to comment.