2026-02-02 15:35:09 +00:00
|
|
|
|
using AIStudio.Chat;
|
2026-01-29 12:07:52 +00:00
|
|
|
|
using AIStudio.Dialogs.Settings;
|
|
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Assistants.PowerPoint;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class PowerPoint : AssistantBaseCore<SettingsDialogPowerPoint>
|
|
|
|
|
|
{
|
2026-01-29 12:50:20 +00:00
|
|
|
|
public override Tools.Components Component => Tools.Components.POWER_POINT_ASSISTANT;
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
2026-01-29 12:50:20 +00:00
|
|
|
|
protected override string Title => T("Power Point");
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
2026-01-29 12:50:20 +00:00
|
|
|
|
protected override string Description => T("Create and refine PowerPoint slide text from a topic or outline.");
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
2026-01-29 14:57:16 +00:00
|
|
|
|
protected override string SystemPrompt =>
|
2026-01-29 12:07:52 +00:00
|
|
|
|
$"""
|
2026-01-29 14:57:16 +00:00
|
|
|
|
You are a presentation editor and writer.
|
|
|
|
|
|
Create a clear, single-slide outline from the user's inputs.
|
2026-02-03 14:27:53 +00:00
|
|
|
|
{this.selectedTargetLanguage.PromptTranslation(this.customTargetLanguage)}
|
2026-01-29 14:57:16 +00:00
|
|
|
|
|
|
|
|
|
|
Inputs:
|
2026-02-03 14:27:53 +00:00
|
|
|
|
- "Your title": the slide title.
|
|
|
|
|
|
{this.inputText}
|
2026-01-29 14:57:16 +00:00
|
|
|
|
- "Your content": the source text.
|
2026-02-02 15:35:09 +00:00
|
|
|
|
{this.selectedTargetGroup.Prompt()}
|
2026-02-04 14:52:29 +00:00
|
|
|
|
|
|
|
|
|
|
- You are a Markdown formatter.
|
|
|
|
|
|
- Your task is to identify headings in the input text that are marked with either # (for h1–h6) or **bold text** (used as pseudo-headings).
|
|
|
|
|
|
- Convert all such headings into proper Markdown subheadings using ## for subheadings (level 2), preserving the original text.
|
|
|
|
|
|
- Do not change any other content.
|
|
|
|
|
|
- between 3 and 7, maximum 7 bullets per heading. Each bullet max 12 words.
|
2026-01-29 14:57:16 +00:00
|
|
|
|
|
|
|
|
|
|
Output requirements:
|
|
|
|
|
|
- Output only Markdown.
|
|
|
|
|
|
- Start with a single H1 title from "Your title".
|
|
|
|
|
|
- Then add a bullet list based only on "Your content".
|
|
|
|
|
|
- If "Your content" is empty, output the title and one bullet: "No content provided."
|
|
|
|
|
|
- Do not mention these instructions or add commentary.
|
2026-01-29 12:07:52 +00:00
|
|
|
|
""";
|
|
|
|
|
|
|
|
|
|
|
|
protected override bool AllowProfiles => false;
|
|
|
|
|
|
|
|
|
|
|
|
protected override IReadOnlyList<IButtonData> FooterButtons => [];
|
|
|
|
|
|
|
2026-01-29 12:50:20 +00:00
|
|
|
|
protected override string SubmitText => T("Create Power Point");
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
2026-01-29 14:57:16 +00:00
|
|
|
|
protected override Func<Task> SubmitAction => this.CreatePowerPoint;
|
2026-01-29 12:07:52 +00:00
|
|
|
|
|
|
|
|
|
|
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
|
|
|
|
|
|
{
|
|
|
|
|
|
SystemPrompt = SystemPrompts.DEFAULT,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
protected override void ResetForm()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.inputText = string.Empty;
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string inputText = string.Empty;
|
|
|
|
|
|
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-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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string UserPromptContext()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(string.IsNullOrWhiteSpace(this.inputContext))
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
return $"""
|
|
|
|
|
|
The given context is:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
{this.inputContext}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
""";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-29 14:57:16 +00:00
|
|
|
|
private async Task CreatePowerPoint()
|
2026-01-29 12:07:52 +00:00
|
|
|
|
{
|
|
|
|
|
|
await this.form!.Validate();
|
|
|
|
|
|
if (!this.inputIsValid)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
this.CreateChatThread();
|
|
|
|
|
|
var time = this.AddUserRequest(
|
|
|
|
|
|
$"""
|
|
|
|
|
|
{this.UserPromptContext()}
|
|
|
|
|
|
The given word or phrase is:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
{this.inputText}
|
|
|
|
|
|
```
|
|
|
|
|
|
""");
|
|
|
|
|
|
|
|
|
|
|
|
await this.AddAIResponseAsync(time);
|
|
|
|
|
|
}
|
2026-01-29 14:57:16 +00:00
|
|
|
|
}
|