Browse Source

Merge pull request #595 from ionite34/inference-tips

Add Inference prompt help tooltip
pull/629/head
Ionite 7 months ago committed by GitHub
parent
commit
94ff2fa40b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 30
      StabilityMatrix.Avalonia/Controls/Inference/PromptCard.axaml
  3. 2
      StabilityMatrix.Avalonia/Controls/Inference/PromptCard.axaml.cs
  4. 9
      StabilityMatrix.Avalonia/Languages/Resources.Designer.cs
  5. 3
      StabilityMatrix.Avalonia/Languages/Resources.resx
  6. 30
      StabilityMatrix.Avalonia/ViewModels/Inference/PromptCardViewModel.cs
  7. 1
      StabilityMatrix.Core/Models/Settings/TeachingTip.cs

1
CHANGELOG.md

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
- Added Reference-Only mode for Inference ControlNet, used for guiding the sampler with an image without a pretrained model. Part of the latent and attention layers will be connected to the reference image, similar to Image to Image or Inpainting.
- Inference ControlNet module now supports over 42 preprocessors, a new button next to the preprocessors dropdown allows previewing the output of the selected preprocessor on the image.
- Added resolution selection for Inference ControlNet module, this controls preprocessor resolution too.
- Added Layer Diffuse sampler addon to Inference, allows generating foreground with transparency with SD1.5 and SDXL.
- Added support for deep links from the new Stability Matrix Chrome extension
- Added OpenArt.AI workflow browser for ComfyUI workflows
- Added more metadata to the image dialog info flyout

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