Files
Hopping-Mad-Games-ComfyUI_L…/js/htmlRenderer.js
TashaSkyUp 40831eaa28 Add agent node docstrings, improve error handling, and update config
- Add detailed docstrings to AgentNode, BasicRecursionFilterNode, and
DocumentChunkRecursionFilterNode for clarity and documentation. -
Improve input validation and error handling in agent nodes. - Update
.gitignore to cover more environment, config, and IDE files. - Refactor
LiteLLMCustomEndpointProvider for custom API endpoints. - Add
conditional imports and dummy functions for LightRAG when unavailable. -
Update config.yaml to use environment variables for API keys and clarify
usage. - Refine requirements.txt to avoid heavy LightRAG dependencies. -
Add tests/__init__.py with test suite metadata; remove redundant test
files. - Fix CustomDict import and model config handling in
litellmnodes.py. - Improve chunk processing and recursion filter logic
in agent nodes. - Update utils/__init__.py to include env_config.
2025-06-24 17:47:36 -06:00

79 lines
3.0 KiB
JavaScript
Executable File

import { app } from "/scripts/app.js";
import { ComfyWidgets } from "/scripts/widgets.js";
app.registerExtension({
name: "Comfy.HTMLRenderer",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === "HTMLRenderer" && nodeData.category === "ETK/LLM/LiteLLM") {
// Node Created
const onNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function () {
const ret = onNodeCreated
? onNodeCreated.apply(this, arguments)
: undefined;
// Only create the html_content widget if it doesn't exist
if (!this.widgets.find(w => w.name === "html_content")) {
ComfyWidgets.STRING(
this,
"html_content",
["STRING", {
multiline: true,
default: "",
placeholder: "HTML content..."
}],
app
);
}
// Create HTML display widget
const displayEl = document.createElement("div");
displayEl.style.width = "100%";
displayEl.style.height = "200px";
displayEl.style.overflow = "auto";
displayEl.style.border = "1px solid #ddd";
displayEl.style.borderRadius = "5px";
displayEl.style.padding = "0px";
displayEl.style.backgroundColor = "#FFFFFF";
this.displayWidget = this.addDOMWidget("html_display", "display", displayEl, {
serialize: false,
getValue() {
return displayEl.innerHTML;
},
setValue(v) {
displayEl.innerHTML = v;
},
});
this.setSize([350, 400]);
return ret;
};
// Function to update display
const updateDisplay = function (html_content) {
if (html_content && html_content.length > 0) {
this.displayWidget.value = html_content;
app.graph.setDirtyCanvas(true);
}
};
// onExecuted
const onExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function (message) {
onExecuted?.apply(this, arguments);
updateDisplay.call(this, message.string[0]);
};
// onConfigure
const onConfigure = nodeType.prototype.onConfigure;
nodeType.prototype.onConfigure = function (config) {
onConfigure?.apply(this, arguments);
if (config?.widgets_values?.length) {
updateDisplay.call(this, config.widgets_values[0]);
}
};
}
},
});