Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions bizyui/js/handle_node_configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ function chainCallback(originalCallback, newCallback) {
}
}

function isImagesInputSlot(slot) {
return slot?.name === 'images' || slot?.localized_name === 'images'
}

app.registerExtension({
name: 'bizyair.handle.node.configure',
nodeCreated(node, app) {
Expand All @@ -28,6 +32,28 @@ app.registerExtension({
if (!hasModelInput(node)) {
return
}

if (!node._bizyairPriceConnectionHooked) {
const originalOnConnectionsChange = node.onConnectionsChange
node.onConnectionsChange = chainCallback(
originalOnConnectionsChange,
async function (type, slotIndex, isConnected, linkInfo, ioSlot) {
const inputSlot = this.inputs?.[slotIndex]
if (!isImagesInputSlot(inputSlot)) {
return
}

// 只处理 images 输入槽位本身的连线变化,避免误判 output 变化。
if (ioSlot && ioSlot !== inputSlot) {
return
}

await applyBadgeToNode(node, true)
}
)
node._bizyairPriceConnectionHooked = true
}

// 不仅仅是切换model才会修改模型定价,比如切换输入参数也会修改模型定价
node.widgets.forEach(widget => {
// 对于prompt这种输入频繁的widget 不做获取价格操作
Expand Down
14 changes: 14 additions & 0 deletions bizyui/js/model_price.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ export function getBadgeConfigByCoinType(coinType, priceText) {
};
}

function getImagesLinkFlag(node) {
if (!node?.inputs || !Array.isArray(node.inputs)) {
return "false";
}

const imagesInput = node.inputs.find(
(input) => input?.name === "images" || input?.localized_name === "images"
);

return imagesInput?.link != null ? "true" : "false";
}

/**
* 为节点添加价格徽章
* @param {Object} node - 节点对象,包含 widgets 和其他节点信息
Expand All @@ -167,6 +179,8 @@ export async function addPriceBadgeToNode(node, modelName = "") {
nodeInputs.model = modelName;
}

nodeInputs.images = getImagesLinkFlag(node);

// 获取价格信息
const priceResult = await fetchNodePrice(modelName, nodeInputs);

Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.18
1.3.19
Loading