Browse Source

Add Inference prompt help tooltip

pull/629/head
Ionite 7 months ago
parent
commit
8e1c00312c
No known key found for this signature in database
  1. 30
      StabilityMatrix.Avalonia/Controls/Inference/PromptCard.axaml
  2. 2
      StabilityMatrix.Avalonia/Controls/Inference/PromptCard.axaml.cs
  3. 9
      StabilityMatrix.Avalonia/Languages/Resources.Designer.cs
  4. 3
      StabilityMatrix.Avalonia/Languages/Resources.resx
  5. 30
      StabilityMatrix.Avalonia/ViewModels/Inference/PromptCardViewModel.cs
  6. 1
      StabilityMatrix.Core/Models/Settings/TeachingTip.cs

30
StabilityMatrix.Avalonia/Controls/Inference/PromptCard.axaml

@ -8,6 +8,8 @@
xmlns:icons="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia"
xmlns:mocks="clr-namespace:StabilityMatrix.Avalonia.DesignData"
xmlns:vmInference="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Inference"
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:lang="clr-namespace:StabilityMatrix.Avalonia.Languages"
x:DataType="vmInference:PromptCardViewModel">
<Design.PreviewWith>
<Grid Width="460" Height="600">
@ -56,21 +58,29 @@
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button
Margin="0,-2,0,0"
Padding="10,4"
VerticalAlignment="Top"
VerticalContentAlignment="Top"
icons:Attached.Icon="fa-solid fa-question"
Classes="transparent-full"
Command="{Binding ShowHelpDialogCommand}" />
<Panel>
<Button
x:Name="PART_HelpButton"
Margin="0,-2,0,0"
Padding="10,4"
VerticalAlignment="Top"
VerticalContentAlignment="Top"
icons:Attached.Icon="fa-solid fa-question"
Classes="transparent-full"
Command="{Binding ShowHelpDialogCommand}" />
<ui:TeachingTip
Target="{Binding #PART_HelpButton}"
Title="{x:Static lang:Resources.TeachingTip_InferencePromptHelpButton}"
IsOpen="{Binding IsHelpButtonTeachingTipOpen}"/>
</Panel>
<Button
Padding="8,4"
Command="{Binding DebugShowTokensCommand}"
Content="Show Tokens"
IsVisible="{Binding SharedState.IsDebugMode}" />
</StackPanel>
<Border

2
StabilityMatrix.Avalonia/Controls/Inference/PromptCard.axaml.cs

@ -12,7 +12,7 @@ using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Controls;
[Transient]
public class PromptCard : TemplatedControl
public class PromptCard : TemplatedControlBase
{
/// <inheritdoc />
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)

9
StabilityMatrix.Avalonia/Languages/Resources.Designer.cs generated

@ -2795,6 +2795,15 @@ namespace StabilityMatrix.Avalonia.Languages {
}
}
/// <summary>
/// Looks up a localized string similar to Click here to review prompt syntax and how to include Lora / Embeddings..
/// </summary>
public static string TeachingTip_InferencePromptHelpButton {
get {
return ResourceManager.GetString("TeachingTip_InferencePromptHelpButton", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Additional folders such as IPAdapters and TextualInversions (embeddings) can be enabled here.
/// </summary>

3
StabilityMatrix.Avalonia/Languages/Resources.resx

@ -1068,4 +1068,7 @@
<data name="Label_WorkflowImportComplete" xml:space="preserve">
<value>The workflow and custom nodes have been imported.</value>
</data>
<data name="TeachingTip_InferencePromptHelpButton" xml:space="preserve">
<value>Click here to review prompt syntax and how to include Lora / Embeddings.</value>
</data>
</root>

30
StabilityMatrix.Avalonia/ViewModels/Inference/PromptCardViewModel.cs

@ -20,6 +20,7 @@ using StabilityMatrix.Core.Exceptions;
using StabilityMatrix.Core.Helper.Cache;
using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.Api.Comfy.Nodes;
using StabilityMatrix.Core.Models.Settings;
using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.Inference;
@ -30,6 +31,7 @@ namespace StabilityMatrix.Avalonia.ViewModels.Inference;
public partial class PromptCardViewModel : LoadableViewModelBase, IParametersLoadableState, IComfyStep
{
private readonly IModelIndexService modelIndexService;
private readonly ISettingsManager settingsManager;
/// <summary>
/// Cache of prompt text to tokenized Prompt
@ -48,6 +50,9 @@ public partial class PromptCardViewModel : LoadableViewModelBase, IParametersLoa
[ObservableProperty]
private bool isAutoCompletionEnabled;
[ObservableProperty]
private bool isHelpButtonTeachingTipOpen;
/// <inheritdoc />
public PromptCardViewModel(
ICompletionProvider completionProvider,
@ -59,6 +64,7 @@ public partial class PromptCardViewModel : LoadableViewModelBase, IParametersLoa
)
{
this.modelIndexService = modelIndexService;
this.settingsManager = settingsManager;
CompletionProvider = completionProvider;
TokenizerProvider = tokenizerProvider;
SharedState = sharedState;
@ -77,6 +83,30 @@ public partial class PromptCardViewModel : LoadableViewModelBase, IParametersLoa
);
}
partial void OnIsHelpButtonTeachingTipOpenChanging(bool oldValue, bool newValue)
{
// If the teaching tip is being closed, save the setting
if (oldValue && !newValue)
{
settingsManager.Transaction(settings =>
{
settings.SeenTeachingTips.Add(TeachingTip.InferencePromptHelpButtonTip);
});
}
}
/// <inheritdoc />
public override void OnLoaded()
{
base.OnLoaded();
// Show teaching tip for help button if not seen
if (!settingsManager.Settings.SeenTeachingTips.Contains(TeachingTip.InferencePromptHelpButtonTip))
{
IsHelpButtonTeachingTipOpen = true;
}
}
/// <summary>
/// Applies the prompt step.
/// Requires:

1
StabilityMatrix.Core/Models/Settings/TeachingTip.cs

@ -14,6 +14,7 @@ public record TeachingTip(string Value) : StringValue(Value)
public static TeachingTip PackageExtensionsInstallNotice => new("PackageExtensionsInstallNotice");
public static TeachingTip DownloadsTip => new("DownloadsTip");
public static TeachingTip WebUiButtonMovedTip => new("WebUiButtonMovedTip");
public static TeachingTip InferencePromptHelpButtonTip => new("InferencePromptHelpButtonTip");
/// <inheritdoc />
public override string ToString()

Loading…
Cancel
Save