Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Remove brackets if weight == 1

missionfloyd98ae4bbfdee1
diff --git a/web/extensions/core/editAttention.js b/web/extensions/core/editAttention.js
index cc51a04e5..b937bb103 100644
--- a/web/extensions/core/editAttention.js
+++ b/web/extensions/core/editAttention.js
@@ -128,8 +128,13 @@ app.registerExtension({
// Increment the weight
const weightDelta = event.key === "ArrowUp" ? delta : -delta;
- const updatedText = selectedText.replace(/(.*:)(\d+(\.\d+)?)(.*)/, (match, prefix, weight, _, suffix) => {
- return prefix + incrementWeight(weight, weightDelta) + suffix;
+ const updatedText = selectedText.replace(/\((.*):(\d+(?:\.\d+)?)\)/, (match, text, weight) => {
+ weight = incrementWeight(weight, weightDelta);
+ if (weight == 1) {
+ return text;
+ } else {
+ return `(${text}:${weight})`;
+ }
});
inputField.setRangeText(updatedText, start, end, "select");