2026-02-02 15:35:09 +00:00
|
|
|
|
using AIStudio.Chat;
|
2026-01-29 12:07:52 +00:00
|
|
|
|
using AIStudio.Dialogs.Settings;
|
|
|
|
|
|
|
2026-02-11 13:18:15 +00:00
|
|
|
|
namespace AIStudio.Assistants.SlideBuilder;
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
2026-02-11 13:18:15 +00:00
|
|
|
|
public partial class SlideAssistant : AssistantBaseCore<SettingsDialogSlideBuilder>
|
2026-01-29 12:07:52 +00:00
|
|
|
|
{
|
2026-02-11 13:18:15 +00:00
|
|
|
|
public override Tools.Components Component => Tools.Components.SLIDE_BUILDER_ASSISTANT;
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
2026-02-11 13:18:15 +00:00
|
|
|
|
protected override string Title => T("Slide Assistant");
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
2026-02-11 13:18:15 +00:00
|
|
|
|
protected override string Description => T("Develop slide content based on a given topic and content.");
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
2026-01-29 14:57:16 +00:00
|
|
|
|
protected override string SystemPrompt =>
|
2026-02-06 11:11:25 +00:00
|
|
|
|
$$"""
|
|
|
|
|
|
You are a professional presentation editor and writer.
|
2026-01-29 14:57:16 +00:00
|
|
|
|
Create a clear, single-slide outline from the user's inputs.
|
2026-02-04 14:52:29 +00:00
|
|
|
|
|
2026-02-11 13:18:15 +00:00
|
|
|
|
# Content
|
|
|
|
|
|
You get the following inputs: PRESENTATION_TITLE and PRESENTATION_CONTENT.
|
|
|
|
|
|
|
|
|
|
|
|
# Subheadings
|
|
|
|
|
|
- Rule for creating the individual subheadings:
|
2026-02-06 11:11:25 +00:00
|
|
|
|
- If {{this.numberOfSheets}} is NOT 0
|
|
|
|
|
|
- Generate exactly {{this.numberOfSheets}} precise subheadings, each heading represents one slide in a presentation.
|
|
|
|
|
|
- If {{this.timeSpecification}} is NOT 0
|
|
|
|
|
|
- Generate exactly {{this.calculatedNumberOfSlides}} precise subheadings, each heading represents one slide in a presentation.
|
|
|
|
|
|
- If either parameter is 0, ignore that rules.
|
|
|
|
|
|
|
|
|
|
|
|
- Each subheadings must have:
|
|
|
|
|
|
- A clear, concise, and thematically meaningful heading.
|
2026-02-09 13:40:09 +00:00
|
|
|
|
- 1 to 7 bullet points (maximum 7) summarizing the slide’s content — use as many as needed, but never more than 7.
|
2026-02-06 11:11:25 +00:00
|
|
|
|
- Each bullet point must be max 12 words.
|
2026-02-09 13:40:09 +00:00
|
|
|
|
- Place *** on its own line immediately before each heading.
|
2026-01-29 14:57:16 +00:00
|
|
|
|
|
2026-02-11 13:18:15 +00:00
|
|
|
|
# Output requirements:
|
2026-01-29 14:57:16 +00:00
|
|
|
|
- Output only Markdown.
|
2026-02-11 13:18:15 +00:00
|
|
|
|
- Start with a single H1 title that contains the user's PRESENTATION_TITLE.
|
|
|
|
|
|
- Then add headings with own bullet lists based only on the user's PRESENTATION_CONTENT.
|
|
|
|
|
|
- If PRESENTATION_CONTENT is empty, output the title and one bullet: "No content provided."
|
2026-01-29 14:57:16 +00:00
|
|
|
|
- Do not mention these instructions or add commentary.
|
2026-02-11 13:18:15 +00:00
|
|
|
|
|
|
|
|
|
|
# Target group:
|
|
|
|
|
|
{{this.selectedTargetGroup.Prompt()}}
|
|
|
|
|
|
|
|
|
|
|
|
# Language:
|
|
|
|
|
|
{{this.selectedTargetLanguage.PromptGeneralPurpose(this.customTargetLanguage)}}
|
2026-01-29 12:07:52 +00:00
|
|
|
|
""";
|
|
|
|
|
|
|
|
|
|
|
|
protected override bool AllowProfiles => false;
|
|
|
|
|
|
|
|
|
|
|
|
protected override IReadOnlyList<IButtonData> FooterButtons => [];
|
|
|
|
|
|
|
2026-02-11 13:18:15 +00:00
|
|
|
|
protected override string SubmitText => T("Create Slides");
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
2026-02-11 13:18:15 +00:00
|
|
|
|
protected override Func<Task> SubmitAction => this.CreateSlideBuilder;
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
|
|
|
|
|
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
|
|
|
|
|
|
{
|
|
|
|
|
|
SystemPrompt = SystemPrompts.DEFAULT,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
protected override void ResetForm()
|
|
|
|
|
|
{
|
2026-02-11 13:18:15 +00:00
|
|
|
|
this.inputTitle = string.Empty;
|
2026-01-29 12:07:52 +00:00
|
|
|
|
this.inputContext = string.Empty;
|
2026-02-02 15:35:09 +00:00
|
|
|
|
this.expertInField = string.Empty;
|
|
|
|
|
|
this.selectedTargetGroup = TargetGroup.NO_CHANGE;
|
|
|
|
|
|
this.customTargetGroup = string.Empty;
|
2026-01-29 12:07:52 +00:00
|
|
|
|
if (!this.MightPreselectValues())
|
|
|
|
|
|
{
|
|
|
|
|
|
this.selectedLanguage = CommonLanguages.AS_IS;
|
|
|
|
|
|
this.customTargetLanguage = string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override bool MightPreselectValues()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.SettingsManager.ConfigurationData.Synonyms.PreselectOptions)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.selectedLanguage = this.SettingsManager.ConfigurationData.Synonyms.PreselectedLanguage;
|
|
|
|
|
|
this.customTargetLanguage = this.SettingsManager.ConfigurationData.Synonyms.PreselectedOtherLanguage;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-11 13:18:15 +00:00
|
|
|
|
private string inputTitle = string.Empty;
|
2026-01-29 12:07:52 +00:00
|
|
|
|
private string inputContext = string.Empty;
|
|
|
|
|
|
private CommonLanguages selectedLanguage;
|
|
|
|
|
|
private string customTargetLanguage = string.Empty;
|
2026-02-02 15:35:09 +00:00
|
|
|
|
private string expertInField = string.Empty;
|
|
|
|
|
|
private TargetGroup selectedTargetGroup;
|
|
|
|
|
|
private string customTargetGroup = string.Empty;
|
2026-02-03 14:27:53 +00:00
|
|
|
|
private CommonLanguages selectedTargetLanguage;
|
2026-02-06 11:11:25 +00:00
|
|
|
|
private double numberOfSheets;
|
2026-02-09 13:40:09 +00:00
|
|
|
|
private double timeSpecification;
|
2026-02-06 11:11:25 +00:00
|
|
|
|
private int calculatedNumberOfSlides = 0;
|
|
|
|
|
|
|
2026-01-29 12:07:52 +00:00
|
|
|
|
#region Overrides of ComponentBase
|
|
|
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
|
{
|
|
|
|
|
|
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_SYNONYMS_ASSISTANT).FirstOrDefault();
|
|
|
|
|
|
if (deferredContent is not null)
|
|
|
|
|
|
this.inputContext = deferredContent;
|
|
|
|
|
|
|
|
|
|
|
|
await base.OnInitializedAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
private string? ValidatingText(string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(string.IsNullOrWhiteSpace(text))
|
2026-01-29 14:57:16 +00:00
|
|
|
|
return T("Please a title");
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string? ValidateCustomLanguage(string language)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(this.selectedLanguage == CommonLanguages.OTHER && string.IsNullOrWhiteSpace(language))
|
|
|
|
|
|
return T("Please provide a custom language.");
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 11:11:25 +00:00
|
|
|
|
private int CalculateNumberOfSlides()
|
|
|
|
|
|
{
|
2026-02-09 13:40:09 +00:00
|
|
|
|
return this.calculatedNumberOfSlides = (int)Math.Round(this.timeSpecification / 1.5);
|
2026-02-06 11:11:25 +00:00
|
|
|
|
}
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
2026-02-11 13:18:15 +00:00
|
|
|
|
private async Task CreateSlideBuilder()
|
2026-01-29 12:07:52 +00:00
|
|
|
|
{
|
|
|
|
|
|
await this.form!.Validate();
|
|
|
|
|
|
if (!this.inputIsValid)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2026-02-06 11:11:25 +00:00
|
|
|
|
this.calculatedNumberOfSlides = this.timeSpecification > 0 ? this.CalculateNumberOfSlides() : 0;
|
|
|
|
|
|
|
2026-01-29 12:07:52 +00:00
|
|
|
|
this.CreateChatThread();
|
|
|
|
|
|
var time = this.AddUserRequest(
|
|
|
|
|
|
$"""
|
2026-02-11 13:18:15 +00:00
|
|
|
|
# PRESENTATION_TITLE
|
2026-01-29 12:07:52 +00:00
|
|
|
|
```
|
2026-02-11 13:18:15 +00:00
|
|
|
|
{this.inputTitle}
|
2026-01-29 12:07:52 +00:00
|
|
|
|
```
|
2026-02-11 13:18:15 +00:00
|
|
|
|
|
|
|
|
|
|
# PRESENTATION_CONTENT
|
|
|
|
|
|
```
|
|
|
|
|
|
{this.inputContext}
|
|
|
|
|
|
```
|
2026-01-29 12:07:52 +00:00
|
|
|
|
""");
|
|
|
|
|
|
|
|
|
|
|
|
await this.AddAIResponseAsync(time);
|
|
|
|
|
|
}
|
2026-01-29 14:57:16 +00:00
|
|
|
|
}
|