-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Try out SK planner with a chat interface (#71)
* ✨ Try out SK planner with a chat interface Improved prompt Add Date range feature (week of timesheets at once) * 🧵 Parrallelize some stuff * Bug fixes for demo * Get rid of warnings * ⚡️ Use stringBuilder * Move styling to css file * Removed styles, updated package use fast GPT * Add appInsights * Fix some warnings
- Loading branch information
1 parent
72596ad
commit b5770b1
Showing
30 changed files
with
740 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
using TimesheetGPT.Core.Models; | ||
|
||
namespace TimesheetGPT.Core.Interfaces; | ||
|
||
public interface IAiService | ||
{ | ||
public Task<string> GetSummary(string text, string extraPrompts, string additionalNotes); | ||
public Task<string?> ChatWithGraphApi(string ask); | ||
public Task<string> GetSummaryBoring(IList<Email> emails, IEnumerable<Meeting> meetings, string extraPrompts, CancellationToken cancellationToken, string additionalNotes = ""); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace TimesheetGPT.Core.Models; | ||
|
||
public class Email | ||
{ | ||
public string? Subject { get; set; } | ||
public string? Body { get; set; } | ||
public string? To { get; set; } | ||
public string? Id { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
namespace TimesheetGPT.Core.Models; | ||
|
||
public class SummaryWithRaw | ||
public class Summary | ||
{ | ||
public List<string> Emails { get; set; } | ||
public List<Meeting> Meetings { get; set; } | ||
public string Summary { get; set; } | ||
public string ModelUsed { get; set; } | ||
public List<Email> Emails { get; set; } = []; | ||
public List<Meeting> Meetings { get; set; } = []; | ||
public string? Text { get; set; } | ||
public string? ModelUsed { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Microsoft.SemanticKernel; | ||
using System.ComponentModel; | ||
using System.Globalization; | ||
using TimesheetGPT.Core.Interfaces; | ||
using System.Text.Json; | ||
|
||
|
||
namespace TimesheetGPT.Core; | ||
|
||
public class GraphPlugins(IGraphService graphService) | ||
{ | ||
[SKFunction, Description("Get email body from Id")] | ||
public async Task<string?> GetEmailBody(string id) | ||
{ | ||
return (await graphService.GetEmailBody(id, new CancellationToken())).Body; | ||
} | ||
|
||
[SKFunction, Description("Get sent emails (subject, to, Id) for a date)")] | ||
public async Task<string> GetSentEmails(DateTime dateTime) | ||
{ | ||
var emails = await graphService.GetSentEmails(dateTime, new CancellationToken()); | ||
return JsonSerializer.Serialize(emails); | ||
} | ||
|
||
[SKFunction, Description("Get meetings for a date")] | ||
public async Task<string> GetMeetings(DateTime dateTime) | ||
{ | ||
var meetings = await graphService.GetMeetings(dateTime, new CancellationToken()); | ||
return JsonSerializer.Serialize(meetings); | ||
} | ||
|
||
[SKFunction, Description("Get todays date")] | ||
public string GetTodaysDate(DateTime dateTime) | ||
{ | ||
//TODO: Use browser datetime | ||
return DateTime.Today.ToString(CultureInfo.InvariantCulture); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using Microsoft.SemanticKernel.AI; | ||
using Microsoft.SemanticKernel.Connectors.AI.OpenAI; | ||
using Microsoft.SemanticKernel.TemplateEngine; | ||
|
||
namespace TimesheetGPT.Core; | ||
|
||
// TODO: Refactor into a JSON file | ||
// https://learn.microsoft.com/en-us/semantic-kernel/ai-orchestration/plugins/semantic-functions/serializing-semantic-functions | ||
public static class PromptConfigs | ||
{ | ||
public static readonly PromptTemplateConfig SummarizeEmailsAndCalendar = new() | ||
{ | ||
Schema = 1, | ||
Description = "Summarises users emails and meetings.", | ||
ModelSettings = new List<AIRequestSettings> | ||
{ | ||
// Note: Token limit hurts things like additional notes. If you don't have enough, the prompt will suck | ||
new OpenAIRequestSettings { MaxTokens = 1000, Temperature = 0, TopP = 0.5 } | ||
}, | ||
Input = | ||
{ | ||
Parameters = new List<PromptTemplateConfig.InputParameter> | ||
{ | ||
new() | ||
{ | ||
Name = PromptVariables.Meetings, | ||
Description = "meetings", | ||
DefaultValue = "" | ||
}, | ||
new() | ||
{ | ||
Name = PromptVariables.Emails, | ||
Description = "emails", | ||
DefaultValue = "" | ||
}, | ||
new() | ||
{ | ||
Name = PromptVariables.AdditionalNotes, | ||
Description = "Additional Notes", | ||
DefaultValue = "" | ||
}, | ||
new() | ||
{ | ||
Name = PromptVariables.ExtraPrompts, | ||
Description = "extraPrompts", | ||
DefaultValue = "" | ||
} | ||
} | ||
} | ||
}; | ||
|
||
public static readonly PromptTemplateConfig SummarizeEmailBody = new() | ||
{ | ||
Schema = 1, | ||
Description = "Summarizes body of an email", | ||
ModelSettings = new List<AIRequestSettings> | ||
{ | ||
// Note: Token limit hurts things like additional notes. If you don't have enough, the prompt will suck | ||
new OpenAIRequestSettings { MaxTokens = 1000, Temperature = 0, TopP = 0.5 } | ||
}, | ||
Input = | ||
{ | ||
Parameters = new List<PromptTemplateConfig.InputParameter> | ||
{ | ||
new() | ||
{ | ||
Name = PromptVariables.Recipients, | ||
Description = nameof(PromptVariables.Recipients), | ||
DefaultValue = "" | ||
}, | ||
new() | ||
{ | ||
Name = PromptVariables.Subject, | ||
Description = nameof(PromptVariables.Subject), | ||
DefaultValue = "" | ||
}, | ||
new() | ||
{ | ||
Name = PromptVariables.EmailBody, | ||
Description = nameof(PromptVariables.EmailBody), | ||
DefaultValue = "" | ||
} | ||
} | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
namespace TimesheetGPT.Core; | ||
|
||
public static class PromptTemplates | ||
{ | ||
// Doesn't hot reload | ||
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. 🌟 | ||
{PromptVarFormatter(PromptVariables.ExtraPrompts)} | ||
Here is the data: | ||
{PromptVarFormatter(PromptVariables.Emails)} | ||
{PromptVarFormatter(PromptVariables.Meetings)} | ||
Additional notes: | ||
{PromptVarFormatter(PromptVariables.AdditionalNotes)} | ||
"""; | ||
|
||
public static readonly string SummarizeEmailBody = $""" | ||
Summarise this email body in 1-2 sentences. This summary will later be used to generate a timesheet summary. | ||
Respond in this format: Recipients - Subject - Summary of body | ||
Here is the data: | ||
Recipients: {PromptVarFormatter(PromptVariables.Recipients)} | ||
Subject: {PromptVarFormatter(PromptVariables.Subject)} | ||
Body: {PromptVarFormatter(PromptVariables.Subject)} | ||
"""; | ||
|
||
private static string PromptVarFormatter(string promptVar) => "{{$" + promptVar + "}}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace TimesheetGPT.Core; | ||
|
||
public static class PromptVariables | ||
{ | ||
public const string Emails = "emails"; | ||
public const string Meetings = "meetings"; | ||
public const string ExtraPrompts = "extraPrompts"; | ||
public const string AdditionalNotes = "additionalNotes"; | ||
|
||
public const string Recipients = "recipients"; | ||
public const string Subject = "subject"; | ||
public const string EmailBody = "emailBody"; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.