Browse Source

Add override serialization for Prompt Card

pull/165/head
Ionite 1 year ago
parent
commit
77b512a598
No known key found for this signature in database
  1. 23
      StabilityMatrix.Avalonia/ViewModels/Inference/PromptCardViewModel.cs

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

@ -1,6 +1,8 @@
using AvaloniaEdit.Document;
using System.Text.Json.Nodes;
using AvaloniaEdit.Document;
using CommunityToolkit.Mvvm.ComponentModel;
using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Models.Inference;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.ViewModels.Inference;
@ -14,4 +16,23 @@ public partial class PromptCardViewModel : LoadableViewModelBase
[ObservableProperty] private int editorFontSize = 14;
[ObservableProperty] private string editorFontFamily = "Consolas";
/// <inheritdoc />
public override JsonObject SaveStateToJsonObject()
{
return SerializeModel(new PromptCardModel
{
Prompt = PromptDocument.Text,
NegativePrompt = NegativePromptDocument.Text
});
}
/// <inheritdoc />
public override void LoadStateFromJsonObject(JsonObject state)
{
var model = DeserializeModel<PromptCardModel>(state);
PromptDocument.Text = model.Prompt ?? "";
NegativePromptDocument.Text = model.NegativePrompt ?? "";
}
}

Loading…
Cancel
Save