mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-18 02:39:00 +00:00
Added a slide assistant (#647)
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
4a8348b9df
commit
03c4d72ab1
37 files changed
+1732
-141
No files matched your search
@@ -0,0 +1,10 @@
|
||||
namespace AIStudio.Assistants.SlideBuilder;
|
||||
|
||||
public enum AudienceAgeGroup
|
||||
{
|
||||
UNSPECIFIED = 0,
|
||||
|
||||
CHILDREN,
|
||||
TEENAGERS,
|
||||
ADULTS,
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace AIStudio.Assistants.SlideBuilder;
|
||||
|
||||
public static class AudienceAgeGroupExtensions
|
||||
{
|
||||
private static string TB(string fallbackEN) => Tools.PluginSystem.I18N.I.T(fallbackEN, typeof(AudienceAgeGroupExtensions).Namespace, nameof(AudienceAgeGroupExtensions));
|
||||
|
||||
public static string Name(this AudienceAgeGroup ageGroup) => ageGroup switch
|
||||
{
|
||||
AudienceAgeGroup.UNSPECIFIED => TB("Unspecified age group"),
|
||||
AudienceAgeGroup.CHILDREN => TB("Children"),
|
||||
AudienceAgeGroup.TEENAGERS => TB("Teenagers"),
|
||||
AudienceAgeGroup.ADULTS => TB("Adults"),
|
||||
|
||||
_ => TB("Unspecified age group"),
|
||||
};
|
||||
|
||||
public static string Prompt(this AudienceAgeGroup ageGroup) => ageGroup switch
|
||||
{
|
||||
AudienceAgeGroup.UNSPECIFIED => "Do not tailor the text to a specific age group.",
|
||||
AudienceAgeGroup.CHILDREN => "Use simple, concrete language with short sentences and minimal jargon.",
|
||||
AudienceAgeGroup.TEENAGERS => "Use clear, approachable language with relatable examples and limited jargon.",
|
||||
AudienceAgeGroup.ADULTS => "Use adult-appropriate language with clear structure and direct explanations.",
|
||||
|
||||
_ => "Do not tailor the text to a specific age group.",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace AIStudio.Assistants.SlideBuilder;
|
||||
|
||||
public enum AudienceExpertise
|
||||
{
|
||||
UNSPECIFIED = 0,
|
||||
|
||||
NON_EXPERTS,
|
||||
BASIC,
|
||||
INTERMEDIATE,
|
||||
EXPERTS,
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace AIStudio.Assistants.SlideBuilder;
|
||||
|
||||
public static class AudienceExpertiseExtensions
|
||||
{
|
||||
private static string TB(string fallbackEN) => Tools.PluginSystem.I18N.I.T(fallbackEN, typeof(AudienceExpertiseExtensions).Namespace, nameof(AudienceExpertiseExtensions));
|
||||
|
||||
public static string Name(this AudienceExpertise expertise) => expertise switch
|
||||
{
|
||||
AudienceExpertise.UNSPECIFIED => TB("Unspecified expertise"),
|
||||
AudienceExpertise.NON_EXPERTS => TB("No expertise"),
|
||||
AudienceExpertise.BASIC => TB("Basic expertise"),
|
||||
AudienceExpertise.INTERMEDIATE => TB("Intermediate expertise"),
|
||||
AudienceExpertise.EXPERTS => TB("Experts"),
|
||||
|
||||
_ => TB("Unspecified expertise"),
|
||||
};
|
||||
|
||||
public static string Prompt(this AudienceExpertise expertise) => expertise switch
|
||||
{
|
||||
AudienceExpertise.UNSPECIFIED => "Do not tailor the text to a specific expertise level.",
|
||||
AudienceExpertise.NON_EXPERTS => "Avoid jargon and explain specialized concepts plainly.",
|
||||
AudienceExpertise.BASIC => "Use simple terminology and briefly explain important technical terms.",
|
||||
AudienceExpertise.INTERMEDIATE => "Assume some familiarity with the topic, but still explain important details clearly.",
|
||||
AudienceExpertise.EXPERTS => "Assume deep familiarity with the topic and use precise domain-specific terminology.",
|
||||
|
||||
_ => "Do not tailor the text to a specific expertise level.",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace AIStudio.Assistants.SlideBuilder;
|
||||
|
||||
public enum AudienceOrganizationalLevel
|
||||
{
|
||||
UNSPECIFIED = 0,
|
||||
|
||||
TRAINEES,
|
||||
INDIVIDUAL_CONTRIBUTORS,
|
||||
TEAM_LEADS,
|
||||
MANAGERS,
|
||||
EXECUTIVES,
|
||||
BOARD_MEMBERS,
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
namespace AIStudio.Assistants.SlideBuilder;
|
||||
|
||||
public static class AudienceOrganizationalLevelExtensions
|
||||
{
|
||||
private static string TB(string fallbackEN) => Tools.PluginSystem.I18N.I.T(fallbackEN, typeof(AudienceOrganizationalLevelExtensions).Namespace, nameof(AudienceOrganizationalLevelExtensions));
|
||||
|
||||
public static string Name(this AudienceOrganizationalLevel level) => level switch
|
||||
{
|
||||
AudienceOrganizationalLevel.UNSPECIFIED => TB("Unspecified organizational level"),
|
||||
AudienceOrganizationalLevel.TRAINEES => TB("Trainees"),
|
||||
AudienceOrganizationalLevel.INDIVIDUAL_CONTRIBUTORS => TB("Individual contributors"),
|
||||
AudienceOrganizationalLevel.TEAM_LEADS => TB("Team leads"),
|
||||
AudienceOrganizationalLevel.MANAGERS => TB("Managers"),
|
||||
AudienceOrganizationalLevel.EXECUTIVES => TB("Executives"),
|
||||
AudienceOrganizationalLevel.BOARD_MEMBERS => TB("Board members"),
|
||||
|
||||
_ => TB("Unspecified organizational level"),
|
||||
};
|
||||
|
||||
public static string Prompt(this AudienceOrganizationalLevel level) => level switch
|
||||
{
|
||||
AudienceOrganizationalLevel.UNSPECIFIED => "Do not tailor the text to a specific organizational level.",
|
||||
AudienceOrganizationalLevel.TRAINEES => "Keep the content supportive and introductory. Explain context and avoid assuming prior organizational knowledge.",
|
||||
AudienceOrganizationalLevel.INDIVIDUAL_CONTRIBUTORS => "Focus on execution, clarity, responsibilities, and practical next steps.",
|
||||
AudienceOrganizationalLevel.TEAM_LEADS => "Focus on coordination, tradeoffs, risks, and concrete actions for a small team.",
|
||||
AudienceOrganizationalLevel.MANAGERS => "Focus on planning, priorities, outcomes, risks, and resource implications.",
|
||||
AudienceOrganizationalLevel.EXECUTIVES => "Focus on strategy, business impact, risks, and the decisions required.",
|
||||
AudienceOrganizationalLevel.BOARD_MEMBERS => "Provide a concise executive-level summary with governance, strategy, risk, and decision relevance.",
|
||||
|
||||
_ => "Do not tailor the text to a specific organizational level.",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace AIStudio.Assistants.SlideBuilder;
|
||||
|
||||
public enum AudienceProfile
|
||||
{
|
||||
UNSPECIFIED = 0,
|
||||
|
||||
STUDENTS,
|
||||
SCIENTISTS,
|
||||
LAWYERS,
|
||||
INVESTORS,
|
||||
ENGINEERS,
|
||||
SOFTWARE_DEVELOPERS,
|
||||
JOURNALISTS,
|
||||
HEALTHCARE_PROFESSIONALS,
|
||||
PUBLIC_OFFICIALS,
|
||||
BUSINESS_PROFESSIONALS,
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace AIStudio.Assistants.SlideBuilder;
|
||||
|
||||
public static class AudienceProfileExtensions
|
||||
{
|
||||
private static string TB(string fallbackEN) => Tools.PluginSystem.I18N.I.T(fallbackEN, typeof(AudienceProfileExtensions).Namespace, nameof(AudienceProfileExtensions));
|
||||
|
||||
public static string Name(this AudienceProfile profile) => profile switch
|
||||
{
|
||||
AudienceProfile.UNSPECIFIED => TB("Unspecified audience profile"),
|
||||
AudienceProfile.STUDENTS => TB("Students"),
|
||||
AudienceProfile.SCIENTISTS => TB("Scientists"),
|
||||
AudienceProfile.LAWYERS => TB("Lawyers"),
|
||||
AudienceProfile.INVESTORS => TB("Investors"),
|
||||
AudienceProfile.ENGINEERS => TB("Engineers"),
|
||||
AudienceProfile.SOFTWARE_DEVELOPERS => TB("Software developers"),
|
||||
AudienceProfile.JOURNALISTS => TB("Journalists"),
|
||||
AudienceProfile.HEALTHCARE_PROFESSIONALS => TB("Healthcare professionals"),
|
||||
AudienceProfile.PUBLIC_OFFICIALS => TB("Public officials"),
|
||||
AudienceProfile.BUSINESS_PROFESSIONALS => TB("Business professionals"),
|
||||
|
||||
_ => TB("Unspecified audience profile"),
|
||||
};
|
||||
|
||||
public static string Prompt(this AudienceProfile profile) => profile switch
|
||||
{
|
||||
AudienceProfile.UNSPECIFIED => "Do not tailor the text to a specific audience profile.",
|
||||
AudienceProfile.STUDENTS => "Write for students. Keep it structured, easy to study, and focused on key takeaways.",
|
||||
AudienceProfile.SCIENTISTS => "Use precise, technical language. Structure the content logically and focus on methods, evidence, and results.",
|
||||
AudienceProfile.LAWYERS => "Write with precise wording. Emphasize definitions, implications, compliance, and risks.",
|
||||
AudienceProfile.INVESTORS => "Focus on market potential, business model, differentiation, traction, risks, and financial upside.",
|
||||
AudienceProfile.ENGINEERS => "Be technically precise and practical. Focus on systems, constraints, implementation, and tradeoffs.",
|
||||
AudienceProfile.SOFTWARE_DEVELOPERS => "Use concise technical language. Focus on architecture, implementation details, tradeoffs, and maintainability.",
|
||||
AudienceProfile.JOURNALISTS => "Be clear, factual, and concise. Highlight the most newsworthy points and explain relevance plainly.",
|
||||
AudienceProfile.HEALTHCARE_PROFESSIONALS => "Use accurate professional language. Emphasize outcomes, safety, evidence, and practical implications.",
|
||||
AudienceProfile.PUBLIC_OFFICIALS => "Focus on public impact, feasibility, budget, compliance, risks, and implementation in a neutral institutional tone.",
|
||||
AudienceProfile.BUSINESS_PROFESSIONALS => "Be clear, practical, and concise. Focus on business relevance, decisions, and next steps.",
|
||||
|
||||
_ => "Do not tailor the text to a specific audience profile.",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
@attribute [Route(Routes.ASSISTANT_SLIDE_BUILDER)]
|
||||
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogSlideBuilder>
|
||||
|
||||
<MudText Typo="Typo.h5" Class="mb-1 mt-3"> @T("Content to derive slide from")</MudText>
|
||||
<MudJustifiedText Typo="Typo.body1" Class="mb-2">
|
||||
@T("You can enter text, use one or more documents or images, or use both. At least one of these options is required.")
|
||||
</MudJustifiedText>
|
||||
<MudTextField T="string" @bind-Text="@this.inputContent" Validation="@this.ValidatingContext" Adornment="Adornment.Start" Lines="6" MaxLines="12" AutoGrow="@false" Label="@T("Text content")" Variant="Variant.Outlined" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||
|
||||
<MudText Typo="Typo.h6" Class="mb-1 mt-1"> @T("Attach documents")</MudText>
|
||||
<AttachDocuments Name="Documents for input" Layer="@DropLayers.ASSISTANTS" @bind-DocumentPaths="@this.loadedDocumentPaths" OnChange="@this.OnDocumentsChanged" CatchAllDocuments="true" UseSmallForm="false" Provider="@this.providerSettings"/>
|
||||
|
||||
<MudText Typo="Typo.h5" Class="mb-3 mt-6"> @T("Details about the desired presentation")</MudText>
|
||||
|
||||
<MudText Typo="Typo.h6" Class="mb-1"> @T("Title")</MudText>
|
||||
<MudJustifiedText Typo="Typo.body1" Class="mb-2">
|
||||
@T("Please enter a title for the presentation. This will help the LLM to select more relevant content.")
|
||||
</MudJustifiedText>
|
||||
<MudTextField T="string" @bind-Text="@this.inputTitle" Validation="@this.ValidatingTitle" Adornment="Adornment.Start" Label="@T("Presentation title")" Variant="Variant.Outlined" Class="mb-1" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||
|
||||
<MudText Typo="Typo.h6" Class="mb-1 mt-3"> @T("Important Aspects")</MudText>
|
||||
<MudJustifiedText Typo="Typo.body1" Class="mb-2">
|
||||
@T("You might want to specify important aspects that the LLM should consider when creating the slides. For example, the use of emojis or specific topics that should be highlighted.")
|
||||
</MudJustifiedText>
|
||||
<MudTextField T="string" AutoGrow="true" Lines="3" @bind-Text="@this.importantAspects" class="mb-1" Label="@T("(Optional) Important Aspects")" HelperText="@T("(Optional) Specify aspects that the LLM should consider when creating the slides. For example, the use of emojis or specific topics that should be highlighted.")" ShrinkLabel="true" Variant="Variant.Outlined" AdornmentIcon="@Icons.Material.Filled.List" Adornment="Adornment.Start"/>
|
||||
|
||||
<MudText Typo="Typo.h6" Class="mb-1 mt-3"> @T("Extent of the planned presentation")</MudText>
|
||||
<MudJustifiedText Typo="Typo.body1" Class="mb-2">
|
||||
@T("Please specify the extent of the planned presentation. This can be the number of slides, the number of bullet points per slide, or the time specification for the presentation. This will help the LLM to create a presentation that fits your needs. Leave the default values if you don't have specific requirements regarding the extent of the presentation. You might only want to specify one of these parameters, for example the time specification, and leave the others at their default values.")
|
||||
</MudJustifiedText>
|
||||
<MudGrid>
|
||||
<MudItem xs="4">
|
||||
<MudNumericField @bind-Value="@this.numberOfSheets"
|
||||
Label="@T("Number of slides")"
|
||||
Variant="Variant.Outlined"
|
||||
Class="mb-3"
|
||||
Min="0" />
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="4">
|
||||
<MudNumericField @bind-Value="@this.numberOfBulletPoints"
|
||||
Label="@T("Number of bullet points")"
|
||||
Variant="Variant.Outlined"
|
||||
Min="0"
|
||||
Max="7"
|
||||
Class="mb-3" />
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="4">
|
||||
<MudNumericField @bind-Value="@this.timeSpecification"
|
||||
Label="@T("Time specification (minutes)")"
|
||||
Variant="Variant.Outlined"
|
||||
Class="mb-3"
|
||||
Min="0" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudText Typo="Typo.h6" Class="mb-1 mt-3"> @T("Language")</MudText>
|
||||
<EnumSelection T="CommonLanguages" NameFunc="@(language => language.Name())" @bind-Value="@this.selectedTargetLanguage" Icon="@Icons.Material.Filled.Translate" Label="@T("Target language")" AllowOther="@true" @bind-OtherInput="@this.customTargetLanguage" OtherValue="CommonLanguages.OTHER" LabelOther="@T("Custom target language")" ValidateOther="@this.ValidateCustomLanguage" />
|
||||
|
||||
<MudText Typo="Typo.h6" Class="mb-1 mt-3"> @T("Audience")</MudText>
|
||||
<MudJustifiedText Typo="Typo.body1" Class="mb-2">
|
||||
@T("Please specify the audience for the planned presentation. This will help the LLM to create a presentation that fits your needs. You can specify the audience profile, the age group, organizational level, and the expertise. You don't have to specify all of these parameters, for example you might only want to specify the audience profile and leave the other parameters at their default values.")
|
||||
</MudJustifiedText>
|
||||
<EnumSelection T="AudienceProfile" NameFunc="@(profile => profile.Name())" @bind-Value="@this.selectedAudienceProfile" Icon="@Icons.Material.Filled.Groups" Label="@T("Audience profile")" />
|
||||
<EnumSelection T="AudienceAgeGroup" NameFunc="@(ageGroup => ageGroup.Name())" @bind-Value="@this.selectedAudienceAgeGroup" Icon="@Icons.Material.Filled.Cake" Label="@T("Audience age group")" />
|
||||
<EnumSelection T="AudienceOrganizationalLevel" NameFunc="@(level => level.Name())" @bind-Value="@this.selectedAudienceOrganizationalLevel" Icon="@Icons.Material.Filled.AccountTree" Label="@T("Audience organizational level")" />
|
||||
<EnumSelection T="AudienceExpertise" NameFunc="@(expertise => expertise.Name())" @bind-Value="@this.selectedAudienceExpertise" Icon="@Icons.Material.Filled.School" Label="@T("Audience expertise")" />
|
||||
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
|
||||
@@ -0,0 +1,408 @@
|
||||
using System.Text;
|
||||
using AIStudio.Chat;
|
||||
using AIStudio.Dialogs.Settings;
|
||||
|
||||
namespace AIStudio.Assistants.SlideBuilder;
|
||||
|
||||
public partial class SlideAssistant : AssistantBaseCore<SettingsDialogSlideBuilder>
|
||||
{
|
||||
protected override Tools.Components Component => Tools.Components.SLIDE_BUILDER_ASSISTANT;
|
||||
|
||||
protected override string Title => T("Slide Assistant");
|
||||
|
||||
protected override string Description => T("This assistant helps you create clear, structured slides from long texts or documents. Enter a presentation title and provide the content either as text or with one or more documents. Important aspects allow you to add instructions to the LLM regarding output or formatting. Set the number of slides either directly or based on your desired presentation duration. You can also specify the number of bullet points. If the default value of 0 is not changed, the LLM will independently determine how many slides or bullet points to generate. The output can be flexibly generated in various languages and tailored to a specific audience.");
|
||||
|
||||
protected override string SystemPrompt =>
|
||||
$$$"""
|
||||
You are a professional presentation editor and writer.
|
||||
Create a clear, single-slide outline from the user's inputs.
|
||||
|
||||
# Presentation title:
|
||||
- IGNORE the language of the PRESENTATION_TITLE.
|
||||
- Translate PRESENTATION_TITLE in: {{{this.selectedTargetLanguage.PromptGeneralPurpose(this.customTargetLanguage)}}}
|
||||
|
||||
# Content
|
||||
- You get the following inputs: PRESENTATION_TITLE, PRESENTATION_CONTENT, and any attached documents that may provide additional context or source material (DOCUMENTS).
|
||||
|
||||
{{{this.GetDocumentTaskDescription()}}}
|
||||
{{{this.PromptImportantAspects()}}}
|
||||
|
||||
# Subheadings
|
||||
- Rule for creating the individual subheadings:
|
||||
- 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.
|
||||
- Place *** on its own line immediately before each heading.
|
||||
|
||||
# Bullet points (per subheading)
|
||||
- You MUST generate exactly this {{{this.numberOfBulletPoints}}} many bullet points per subheading:
|
||||
- If {{{this.numberOfBulletPoints}}} == 0 → choose a number between 1 and 7 (your choice, but max 7).
|
||||
- Each bullet point must have:
|
||||
- Each bullet point must be max 12 words.
|
||||
- Clear and directly related to the subheading and summarizing the slide’s content.
|
||||
|
||||
# Output requirements:
|
||||
- Output only Markdown.
|
||||
- Start with a single H1 title that contains the user's PRESENTATION_TITLE.
|
||||
- Then add headings with own bullet lists based on the provided source material: PRESENTATION_CONTENT, DOCUMENTS, and attached images.
|
||||
- If both PRESENTATION_CONTENT and attached source material are provided, use all of them, while prioritizing direct user instructions from PRESENTATION_CONTENT when resolving ambiguity.
|
||||
- If PRESENTATION_CONTENT is empty but attached source material is available, create the slides from the attached source material.
|
||||
- If neither PRESENTATION_CONTENT nor any attached source material is available, output the title and one bullet: "No content provided."
|
||||
- Do not mention these instructions or add commentary.
|
||||
|
||||
# Audience:
|
||||
{{{this.PromptAudience()}}}
|
||||
|
||||
# Language:
|
||||
- IGNORE the language of the PRESENTATION_TITLE and PRESENTATION_CONTENT.
|
||||
- OUTPUT AND PRESENTATION_TITLE MUST BE IN: {{{this.selectedTargetLanguage.PromptGeneralPurpose(this.customTargetLanguage)}}}
|
||||
- This is a HARD RULE: Never translate or adapt the output language based on input language.
|
||||
- Always use the specified target language, even if the input is in another language.
|
||||
|
||||
# Language-Override (IMPORTANT!):
|
||||
- Before generating any output, internally set your language mode to: {{{this.selectedTargetLanguage.PromptGeneralPurpose(this.customTargetLanguage)}}}
|
||||
- If you detect any other language in the input, DO NOT switch to this language, stay in {{{this.selectedTargetLanguage.PromptGeneralPurpose(this.customTargetLanguage)}}}
|
||||
- Translate PRESENTATION_TITLE in: {{{this.selectedTargetLanguage.PromptGeneralPurpose(this.customTargetLanguage)}}}
|
||||
- Your output must be in {{{this.selectedTargetLanguage.PromptGeneralPurpose(this.customTargetLanguage)}}}, without any comment, note, or marker about it.
|
||||
""";
|
||||
|
||||
protected override bool AllowProfiles => true;
|
||||
|
||||
protected override IReadOnlyList<IButtonData> FooterButtons => [];
|
||||
|
||||
protected override string SubmitText => T("Create Slides");
|
||||
|
||||
protected override Func<Task> SubmitAction => this.CreateSlideBuilder;
|
||||
|
||||
protected override ChatThread ConvertToChatThread
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.chatThread is null || this.chatThread.Blocks.Count < 2)
|
||||
{
|
||||
return new ChatThread
|
||||
{
|
||||
SystemPrompt = SystemPrompts.DEFAULT
|
||||
};
|
||||
}
|
||||
|
||||
return new ChatThread
|
||||
{
|
||||
ChatId = Guid.NewGuid(),
|
||||
Name = string.Format(T("{0} - Slide Builder Session"), this.inputTitle),
|
||||
SystemPrompt = SystemPrompts.DEFAULT,
|
||||
Blocks =
|
||||
[
|
||||
// Visible user block:
|
||||
new ContentBlock
|
||||
{
|
||||
Time = this.chatThread.Blocks.First().Time,
|
||||
Role = ChatRole.USER,
|
||||
HideFromUser = false,
|
||||
ContentType = ContentType.TEXT,
|
||||
Content = new ContentText
|
||||
{
|
||||
Text = this.T("The result of your previous slide builder session."),
|
||||
FileAttachments = this.loadedDocumentPaths.ToList(),
|
||||
}
|
||||
},
|
||||
|
||||
// Hidden user block with inputContent data:
|
||||
new ContentBlock
|
||||
{
|
||||
Time = this.chatThread.Blocks.First().Time,
|
||||
Role = ChatRole.USER,
|
||||
HideFromUser = true,
|
||||
ContentType = ContentType.TEXT,
|
||||
Content = new ContentText
|
||||
{
|
||||
Text = string.IsNullOrWhiteSpace(this.inputContent)
|
||||
? $"""
|
||||
# PRESENTATION_TITLE
|
||||
```
|
||||
{this.inputTitle}
|
||||
```
|
||||
"""
|
||||
|
||||
: $"""
|
||||
# PRESENTATION_TITLE
|
||||
```
|
||||
{this.inputTitle}
|
||||
```
|
||||
|
||||
# PRESENTATION_CONTENT
|
||||
```
|
||||
{this.inputContent}
|
||||
```
|
||||
""",
|
||||
}
|
||||
},
|
||||
|
||||
// Then, append the last block of the current chat thread
|
||||
// (which is expected to be the AI response):
|
||||
this.chatThread.Blocks.Last(),
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ResetForm()
|
||||
{
|
||||
this.inputTitle = string.Empty;
|
||||
this.inputContent = string.Empty;
|
||||
this.loadedDocumentPaths.Clear();
|
||||
this.selectedAudienceProfile = AudienceProfile.UNSPECIFIED;
|
||||
this.selectedAudienceAgeGroup = AudienceAgeGroup.UNSPECIFIED;
|
||||
this.selectedAudienceOrganizationalLevel = AudienceOrganizationalLevel.UNSPECIFIED;
|
||||
this.selectedAudienceExpertise = AudienceExpertise.UNSPECIFIED;
|
||||
if (!this.MightPreselectValues())
|
||||
{
|
||||
this.selectedTargetLanguage = CommonLanguages.AS_IS;
|
||||
this.customTargetLanguage = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool MightPreselectValues()
|
||||
{
|
||||
if (this.SettingsManager.ConfigurationData.SlideBuilder.PreselectOptions)
|
||||
{
|
||||
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.SlideBuilder.PreselectedTargetLanguage;
|
||||
this.customTargetLanguage = this.SettingsManager.ConfigurationData.SlideBuilder.PreselectedOtherLanguage;
|
||||
this.selectedAudienceProfile = this.SettingsManager.ConfigurationData.SlideBuilder.PreselectedAudienceProfile;
|
||||
this.selectedAudienceAgeGroup = this.SettingsManager.ConfigurationData.SlideBuilder.PreselectedAudienceAgeGroup;
|
||||
this.selectedAudienceOrganizationalLevel = this.SettingsManager.ConfigurationData.SlideBuilder.PreselectedAudienceOrganizationalLevel;
|
||||
this.selectedAudienceExpertise = this.SettingsManager.ConfigurationData.SlideBuilder.PreselectedAudienceExpertise;
|
||||
this.importantAspects = this.SettingsManager.ConfigurationData.SlideBuilder.PreselectedImportantAspects;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private string inputTitle = string.Empty;
|
||||
private string inputContent = string.Empty;
|
||||
private string customTargetLanguage = string.Empty;
|
||||
private AudienceProfile selectedAudienceProfile;
|
||||
private AudienceAgeGroup selectedAudienceAgeGroup;
|
||||
private AudienceOrganizationalLevel selectedAudienceOrganizationalLevel;
|
||||
private AudienceExpertise selectedAudienceExpertise;
|
||||
private CommonLanguages selectedTargetLanguage;
|
||||
private int numberOfSheets;
|
||||
private int numberOfBulletPoints;
|
||||
private int timeSpecification;
|
||||
private int calculatedNumberOfSlides;
|
||||
private string importantAspects = string.Empty;
|
||||
private HashSet<FileAttachment> loadedDocumentPaths = [];
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_SLIDE_BUILDER_ASSISTANT).FirstOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputContent = deferredContent;
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private string? ValidatingTitle(string text)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(text))
|
||||
return T("Please provide a title");
|
||||
|
||||
return null;
|
||||
}
|
||||
private string? ValidatingContext(string text)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(text) && !this.HasValidInputDocuments())
|
||||
return T("Please provide a text or at least one valid document or image.");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private bool HasValidInputDocuments() => this.loadedDocumentPaths.Any(n => n is { Exists: true });
|
||||
|
||||
private async Task OnDocumentsChanged(HashSet<FileAttachment> _)
|
||||
{
|
||||
if(this.form is not null)
|
||||
await this.form.Validate();
|
||||
}
|
||||
|
||||
private string? ValidateCustomLanguage(string language)
|
||||
{
|
||||
if(this.selectedTargetLanguage == CommonLanguages.OTHER && string.IsNullOrWhiteSpace(language))
|
||||
return T("Please provide a custom language.");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private int CalculateNumberOfSlides()
|
||||
{
|
||||
return this.calculatedNumberOfSlides = (int)Math.Round(this.timeSpecification / 1.5);
|
||||
}
|
||||
|
||||
private string PromptImportantAspects()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(this.importantAspects))
|
||||
return string.Empty;
|
||||
|
||||
return $"""
|
||||
|
||||
# Important aspects
|
||||
Emphasize the following aspects in your presentation:
|
||||
{this.importantAspects}
|
||||
""";
|
||||
}
|
||||
|
||||
private string PromptAudience()
|
||||
{
|
||||
var prompts = new List<string>();
|
||||
|
||||
if (this.selectedAudienceProfile is not AudienceProfile.UNSPECIFIED)
|
||||
prompts.Add(this.selectedAudienceProfile.Prompt());
|
||||
|
||||
if (this.selectedAudienceAgeGroup is not AudienceAgeGroup.UNSPECIFIED)
|
||||
prompts.Add(this.selectedAudienceAgeGroup.Prompt());
|
||||
|
||||
if (this.selectedAudienceOrganizationalLevel is not AudienceOrganizationalLevel.UNSPECIFIED)
|
||||
prompts.Add(this.selectedAudienceOrganizationalLevel.Prompt());
|
||||
|
||||
if (this.selectedAudienceExpertise is not AudienceExpertise.UNSPECIFIED)
|
||||
prompts.Add(this.selectedAudienceExpertise.Prompt());
|
||||
|
||||
if (prompts.Count == 0)
|
||||
return " - Do not tailor the text to a specific audience.";
|
||||
|
||||
return string.Join(Environment.NewLine, prompts.Select(prompt => $" - {prompt}"));
|
||||
}
|
||||
|
||||
private string GetDocumentTaskDescription()
|
||||
{
|
||||
var numDocuments = this.loadedDocumentPaths.Count(x => x is { Exists: true, IsImage: false });
|
||||
var numImages = this.loadedDocumentPaths.Count(x => x is { Exists: true, IsImage: true });
|
||||
|
||||
return (numDocuments, numImages) switch
|
||||
{
|
||||
(0, 1) => "Your task is to analyze a single image file attached as a document.",
|
||||
(0, > 1) => $"Your task is to analyze {numImages} image file(s) attached as documents.",
|
||||
|
||||
(1, 0) => "Your task is to analyze a single DOCUMENT.",
|
||||
(1, 1) => "Your task is to analyze a single DOCUMENT and 1 image file attached as a document.",
|
||||
(1, > 1) => $"Your task is to analyze a single DOCUMENT and {numImages} image file(s) attached as documents.",
|
||||
|
||||
(> 0, 0) => $"Your task is to analyze {numDocuments} DOCUMENTS. Different DOCUMENTS are divided by a horizontal rule in markdown formatting followed by the name of the document.",
|
||||
(> 0, 1) => $"Your task is to analyze {numDocuments} DOCUMENTS and 1 image file attached as a document. Different DOCUMENTS are divided by a horizontal rule in Markdown formatting followed by the name of the document.",
|
||||
(> 0, > 0) => $"Your task is to analyze {numDocuments} DOCUMENTS and {numImages} image file(s) attached as documents. Different DOCUMENTS are divided by a horizontal rule in Markdown formatting followed by the name of the document.",
|
||||
|
||||
_ => "Your task is to analyze a single DOCUMENT."
|
||||
};
|
||||
}
|
||||
|
||||
private async Task<string> PromptLoadDocumentsContent()
|
||||
{
|
||||
if (this.loadedDocumentPaths.Count == 0)
|
||||
return string.Empty;
|
||||
|
||||
var documents = this.loadedDocumentPaths.Where(n => n is { Exists: true, IsImage: false }).ToList();
|
||||
var sb = new StringBuilder();
|
||||
|
||||
if (documents.Count > 0)
|
||||
{
|
||||
sb.AppendLine("""
|
||||
# DOCUMENTS:
|
||||
|
||||
""");
|
||||
}
|
||||
|
||||
var numDocuments = 1;
|
||||
foreach (var document in documents)
|
||||
{
|
||||
if (document.IsForbidden)
|
||||
{
|
||||
this.Logger.LogWarning($"Skipping forbidden file: '{document.FilePath}'.");
|
||||
continue;
|
||||
}
|
||||
|
||||
var fileContent = await this.RustService.ReadArbitraryFileData(document.FilePath, int.MaxValue);
|
||||
sb.AppendLine($"""
|
||||
|
||||
## DOCUMENT {numDocuments}:
|
||||
File path: {document.FilePath}
|
||||
Content:
|
||||
```
|
||||
{fileContent}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
""");
|
||||
numDocuments++;
|
||||
}
|
||||
|
||||
var numImages = this.loadedDocumentPaths.Count(x => x is { IsImage: true, Exists: true });
|
||||
if (numImages > 0)
|
||||
{
|
||||
if (documents.Count == 0)
|
||||
{
|
||||
sb.AppendLine($"""
|
||||
|
||||
There are {numImages} image file(s) attached as documents.
|
||||
Please consider them as documents as well and use them to
|
||||
answer accordingly.
|
||||
|
||||
""");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendLine($"""
|
||||
|
||||
Additionally, there are {numImages} image file(s) attached.
|
||||
Please consider them as documents as well and use them to
|
||||
answer accordingly.
|
||||
|
||||
""");
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private async Task CreateSlideBuilder()
|
||||
{
|
||||
await this.form!.Validate();
|
||||
if (!this.inputIsValid)
|
||||
return;
|
||||
|
||||
this.calculatedNumberOfSlides = this.timeSpecification > 0 ? this.CalculateNumberOfSlides() : 0;
|
||||
|
||||
this.CreateChatThread();
|
||||
var documentContent = await this.PromptLoadDocumentsContent();
|
||||
var imageAttachments = this.loadedDocumentPaths.Where(n => n is { Exists: true, IsImage: true }).ToList();
|
||||
|
||||
var time = this.AddUserRequest(
|
||||
$"""
|
||||
# PRESENTATION_TITLE
|
||||
```
|
||||
{this.inputTitle}
|
||||
```
|
||||
|
||||
# PRESENTATION_CONTENT
|
||||
|
||||
```
|
||||
{this.inputContent}
|
||||
```
|
||||
|
||||
{documentContent}
|
||||
""",
|
||||
hideContentFromUser: true,
|
||||
imageAttachments);
|
||||
|
||||
await this.AddAIResponseAsync(time);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user