Implement portrait generation and retrieval for people in the school system. Added new API endpoints for generating and fetching portraits, including support for avatar and full-body images. Updated the client-side to handle portrait states and display options. Enhanced the person card UI to include tabs for overview and portrait, with appropriate localization strings. Updated solution files to include new test projects. Adjusted server configuration for SwarmUI integration.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace HSchool.Server.Game;
|
||||
|
||||
/// <summary>Generation defaults and prompt templates loaded from swarmui.json next to the server.</summary>
|
||||
internal sealed class SwarmUiSettings
|
||||
{
|
||||
public string Model { get; init; } = "";
|
||||
|
||||
public int Steps { get; init; } = 8;
|
||||
|
||||
public double CfgScale { get; init; } = 1;
|
||||
|
||||
public int ClipSkip { get; init; } = 1;
|
||||
|
||||
public string Sampler { get; init; } = "euler";
|
||||
|
||||
public long Seed { get; init; } = -1;
|
||||
|
||||
public string Positive { get; init; } = "";
|
||||
|
||||
public string Negative { get; init; } = "";
|
||||
|
||||
public SwarmUiPreset Avatar { get; init; } = new();
|
||||
|
||||
public SwarmUiPreset FullBody { get; init; } = new();
|
||||
|
||||
internal sealed class SwarmUiPreset
|
||||
{
|
||||
public int Width { get; init; } = 512;
|
||||
|
||||
public int Height { get; init; } = 512;
|
||||
|
||||
public string Positive { get; init; } = "";
|
||||
}
|
||||
|
||||
private static readonly JsonSerializerOptions Json = new()
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
};
|
||||
|
||||
public static SwarmUiSettings Load(IHostEnvironment environment, ILogger logger)
|
||||
{
|
||||
var path = Path.Combine(environment.ContentRootPath, "swarmui.json");
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
logger.LogWarning("SwarmUI settings file {Path} is missing; portrait generation will use empty defaults.", path);
|
||||
return new SwarmUiSettings();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var json = File.ReadAllText(path);
|
||||
return JsonSerializer.Deserialize<SwarmUiSettings>(json, Json) ?? new SwarmUiSettings();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "Could not read SwarmUI settings from {Path}.", path);
|
||||
return new SwarmUiSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user