|
|
@ -3,8 +3,13 @@ using System.Collections.Generic; |
|
|
|
using System.Diagnostics.CodeAnalysis; |
|
|
|
using System.Diagnostics.CodeAnalysis; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using CommunityToolkit.Mvvm.ComponentModel; |
|
|
|
using CommunityToolkit.Mvvm.ComponentModel; |
|
|
|
|
|
|
|
using Sentry; |
|
|
|
using StabilityMatrix.Core.Api; |
|
|
|
using StabilityMatrix.Core.Api; |
|
|
|
|
|
|
|
using StabilityMatrix.Core.Helper; |
|
|
|
using StabilityMatrix.Core.Inference; |
|
|
|
using StabilityMatrix.Core.Inference; |
|
|
|
|
|
|
|
using StabilityMatrix.Core.Models; |
|
|
|
|
|
|
|
using StabilityMatrix.Core.Models.FileInterfaces; |
|
|
|
|
|
|
|
using StabilityMatrix.Core.Models.Packages; |
|
|
|
|
|
|
|
|
|
|
|
namespace StabilityMatrix.Avalonia.Services; |
|
|
|
namespace StabilityMatrix.Avalonia.Services; |
|
|
|
|
|
|
|
|
|
|
@ -16,6 +21,8 @@ public partial class InferenceClientManager : ObservableObject, IInferenceClient |
|
|
|
{ |
|
|
|
{ |
|
|
|
private readonly IApiFactory apiFactory; |
|
|
|
private readonly IApiFactory apiFactory; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Current |
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty, NotifyPropertyChangedFor(nameof(IsConnected))] |
|
|
|
[ObservableProperty, NotifyPropertyChangedFor(nameof(IsConnected))] |
|
|
|
private ComfyClient? client; |
|
|
|
private ComfyClient? client; |
|
|
|
|
|
|
|
|
|
|
@ -57,6 +64,28 @@ public partial class InferenceClientManager : ObservableObject, IInferenceClient |
|
|
|
await LoadSharedPropertiesAsync(); |
|
|
|
await LoadSharedPropertiesAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task ConnectAsync(PackagePair packagePair) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (IsConnected) return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (packagePair.BasePackage is not ComfyUI) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
throw new ArgumentException("Base package is not ComfyUI", nameof(packagePair)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tempClient = new ComfyClient(apiFactory, new Uri("http://127.0.0.1:8188")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add output dir if available |
|
|
|
|
|
|
|
if (packagePair.InstalledPackage.FullPath is { } path) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
tempClient.OutputImagesDir = new DirectoryPath(path, "output"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await tempClient.ConnectAsync(); |
|
|
|
|
|
|
|
Client = tempClient; |
|
|
|
|
|
|
|
await LoadSharedPropertiesAsync(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task CloseAsync() |
|
|
|
public async Task CloseAsync() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!IsConnected) return; |
|
|
|
if (!IsConnected) return; |
|
|
|