V 2.0.0 - Universal api #30

This commit is contained in:
DESKTOP-TVBJISQ\Primere
2026-02-27 20:19:57 +01:00
parent 5cd043f4a0
commit ffc3efd167
4 changed files with 79 additions and 14 deletions
+54 -4
View File
@@ -94,7 +94,53 @@ function ensureBooleanWidget(node, widgetName, values) {
return markDynamicWidget(node, widgetName);
}
function ensureNumberWidget(node, widgetName, valueType) {
const isInteger = valueType === "INT";
const defaultValue = isInteger ? 1 : 1.0;
const expectedStep = isInteger ? 1 : 0.01;
const expectedPrecision = isInteger ? 0 : 4;
let widget = getWidget(node, widgetName);
if (!widget || widget.type !== "number") {
removeWidgetByName(node, widgetName);
widget = node.addWidget("number", widgetName, defaultValue, () => {}, {
step: expectedStep,
precision: expectedPrecision,
});
}
widget.options = widget.options || {};
widget.options.step = expectedStep;
widget.options.precision = expectedPrecision;
if (typeof widget.value !== "number" || Number.isNaN(widget.value)) {
widget.value = defaultValue;
} else if (isInteger) {
widget.value = Math.round(widget.value);
}
return markDynamicWidget(node, widgetName);
}
function ensureStringWidget(node, widgetName) {
let widget = getWidget(node, widgetName);
if (!widget || widget.type !== "text") {
removeWidgetByName(node, widgetName);
widget = node.addWidget("text", widgetName, "", () => {}, {});
}
if (widget.value == null) {
widget.value = "";
}
return markDynamicWidget(node, widgetName);
}
function detectParameterType(values) {
if (values === "INT" || values === "FLOAT" || values === "STRING") {
return values;
}
if (!Array.isArray(values) || values.length === 0) {
return "combo";
}
@@ -103,10 +149,6 @@ function detectParameterType(values) {
return "boolean";
}
if (values.every((value) => Number.isInteger(value))) {
return "integer";
}
return "combo";
}
@@ -231,6 +273,14 @@ function updateParameterWidgets(node, schemaRegistry) {
ensureBooleanWidget(node, paramName, values);
continue;
}
if (paramType === "INT" || paramType === "FLOAT") {
ensureNumberWidget(node, paramName, paramType);
continue;
}
if (paramType === "STRING") {
ensureStringWidget(node, paramName);
continue;
}
ensureComboWidget(node, paramName, values);
}
}
+2
View File
@@ -52,6 +52,8 @@ def node_to_template(node: ast.AST, path: str) -> Any:
if isinstance(node, ast.Constant):
if node.value is None or isinstance(node.value, bool):
return node.value
if isinstance(node.value, str) and node.value in {"INT", "FLOAT", "STRING"}:
return node.value
return placeholder(path)
if isinstance(node, ast.Name):
+22 -9
View File
@@ -1,12 +1,25 @@
{
"BlackForest": {
"FluxFillPro": {
"FluxExpandPro": {
"provider": "BlackForest",
"service": "FluxFillPro",
"service": "FluxExpandPro",
"possible_parameters": {
"blackforest_guidance": "FLOAT",
"blackforest_steps": "INT",
"safety_tolerance": [1, 2, 3, 4, 5, 6]
"aspect_ratio": [
"fake_aspect_ratio_value_1",
"fake_aspect_ratio_value_2"
],
"mask_images": [
"fake_mask_images_value_1",
"fake_mask_images_value_2"
],
"output_format": [
"fake_output_format_value_1",
"fake_output_format_value_2"
],
"safety_tolerance": [
"fake_safety_tolerance_value_1",
"fake_safety_tolerance_value_2"
]
},
"request": {
"method": "SDK",
@@ -17,16 +30,16 @@
],
"kwargs": {
"payload": {
"output_format": "png",
"output_format": "{{output_format}}",
"image": "{{reference_images}}",
"mask": "{{mask_images}}",
"safety_tolerance": "{{safety_tolerance}}",
"prompt": "{{prompt}}",
"seed": "{{seed}}",
"aspect_ratio": "{{aspect_ratio}}",
"prompt_upsampling": false,
"guidance": "{{guidance}}",
"steps": "{{blackforest_steps}}"
"prompt_upsampling": "STRING",
"guidance": "FLOAT",
"steps": "INT"
}
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ response = requests.post("https://api.bfl.ai/v1/flux-pro-1.0-fill",
"prompt": prompt,
"seed": seed,
"aspect_ratio": aspect_ratio,
"prompt_upsampling": False,
"prompt_upsampling": "STRING",
"guidance": "FLOAT",
"steps": "INT"
}