@@ -14,7 +14,7 @@ Webhook configuration comes in two parts: the URL, and the JSON data. For the UR
|
||||
|
||||
### Image Metadata In The JSON
|
||||
|
||||
For some webhooks, eg the `Every Gen` Webhook, you can include image metadata in the JSON body. This uses `%tag%` syntax, and mostly follows the same rules as the `Output Path` setting for what you can fill in. For example, `%prompt%` can be used to fill the prompt. Unlike `Output Path`, this text won't be trimmed or formatted, other than escaped to fit within a JSON string.
|
||||
For some webhooks, eg the `Every Gen` Webhook, you can include image metadata in the JSON body. This uses `%tag%` syntax, and mostly follows the same rules as the `Output Path` setting for what you can fill in (refer to [User Settings - Path Format](/docs/User%20Settings.md#path-format)). For example, `%prompt%` can be used to fill the prompt. Unlike `Output Path`, this text won't be trimmed or formatted, other than escaped to fit within a JSON string.
|
||||
|
||||
You may also use `%image%` to include the URL to an image. Be warned if `DoNotSave` is used this URL maybe a very large Base64 blob. This will use the `External URL` setting under `Server Configuration` to format the URL. Note that unless your server is externally accessible, this URL cannot be opened by anyone but you. This means for example you cannot embed the image onto a Discord message via the webhook, because Discord's servers cannot read the URL.
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
- `[second]`: 2-digit second, eg 30
|
||||
- `[prompt]`: the prompt (often cut off by `MaxLenPerPart`)
|
||||
- `[negative_prompt]`: the negative prompt (often cut off by `MaxLenPerPart`)
|
||||
- `[prompthash]`: a short (8 character) SHA256 hash prefix of the prompt
|
||||
- `[negativeprompthash]`: a short (8 character) SHA256 hash prefix of the negative prompt
|
||||
- `[seed]`: the seed number parameter
|
||||
- `[cfg_scale]`: the CFG Scale parameter
|
||||
- `[width]`: the Width parameter
|
||||
|
||||
@@ -6,6 +6,7 @@ using SwarmUI.DataHolders;
|
||||
using SwarmUI.Utils;
|
||||
using SwarmUI.Text2Image;
|
||||
using FreneticUtilities.FreneticExtensions;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace SwarmUI.Accounts;
|
||||
|
||||
@@ -271,10 +272,11 @@ public class User
|
||||
SkipFolders = LinkedUser?.Settings?.OutPathBuilder?.ModelPathsSkipFolders ?? false;
|
||||
}
|
||||
|
||||
/// <summary>Simplify a model filename appropriately in accordance with settings. Strips file extensions.</summary>
|
||||
public string SimplifyModel(string model)
|
||||
{
|
||||
model = model.Replace('\\', '/').Trim();
|
||||
if (model.EndsWith(".safetensors") || model.EndsWith(".sft") || model.EndsWith(".ckpt"))
|
||||
if (model.EndsWith(".ckpt") || T2IModel.NativelySupportedModelExtensions.Contains(model.AfterLast('.')))
|
||||
{
|
||||
model = model.BeforeLast('.');
|
||||
}
|
||||
@@ -285,6 +287,12 @@ public class User
|
||||
return model;
|
||||
}
|
||||
|
||||
/// <summary>Quick 8 character hash of some text.</summary>
|
||||
public string QuickHash(string val)
|
||||
{
|
||||
return Utilities.BytesToHex(SHA256.HashData(val.EncodeUTF8())[0..4]);
|
||||
}
|
||||
|
||||
public string FillPartUnformatted(string part)
|
||||
{
|
||||
string data = part switch
|
||||
@@ -298,7 +306,9 @@ public class User
|
||||
"minute" => $"{Time.Minute:00}",
|
||||
"second" => $"{Time.Second:00}",
|
||||
"prompt" => UserInput.Get(T2IParamTypes.Prompt),
|
||||
"prompthash" => QuickHash(UserInput.Get(T2IParamTypes.Prompt)),
|
||||
"negative_prompt" => UserInput.Get(T2IParamTypes.NegativePrompt),
|
||||
"negativeprompthash" => QuickHash(UserInput.Get(T2IParamTypes.NegativePrompt)),
|
||||
"seed" => $"{UserInput.Get(T2IParamTypes.Seed)}",
|
||||
"cfg_scale" => $"{UserInput.Get(T2IParamTypes.CFGScale)}",
|
||||
"width" => $"{UserInput.GetImageWidth()}",
|
||||
|
||||
Reference in New Issue
Block a user