Files
Hopping-Mad-Games-ComfyUI_L…/js/genericLiteGraphTextNode.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

71 lines
1.9 KiB
JavaScript
Executable File

import { app } from "/scripts/app.js";
import { ComfyWidgets } from "/scripts/widgets.js";
app.registerExtension({
name: "Comfy.LiteLLMTextNode",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if ((nodeData.name === "ShowLastMessage" || nodeData.name === "ShowMessages") && nodeData.category === "ETK/LLM/LiteLLM") {
// Node Created
const onNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function () {
const ret = onNodeCreated
? onNodeCreated.apply(this, arguments)
: undefined;
// let ShowText = app.graph._nodes.filter(
// (wi) => wi.type == nodeData.name
// ),
// nodeName = `${nodeData.name}_${ShowText.length}`;
// const wi = ComfyWidgets.STRING(
// this,
// nodeName,
// [
// "STRING",
// {
// default: "",
// placeholder: "Text output...",
// multiline: true,
// },
// ],
// app
// );
// wi.widget.inputEl.readOnly = true;
return ret;
};
// Function set value
const outSet = function (texts) {
if (texts.length > 0) {
let widget_id = this?.widgets.findIndex(
(w) => w.name == "list_display"
);
if (Array.isArray(texts))
texts = texts
.filter((word) => word.trim() !== "")
.map((word) => word.trim())
.join(" ");
this.widgets[widget_id].value = texts;
app.graph.setDirtyCanvas(true);
}
};
// onExecuted
const onExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function (texts) {
onExecuted?.apply(this, arguments);
outSet.call(this, texts?.string);
};
// onConfigure
const onConfigure = nodeType.prototype.onConfigure;
nodeType.prototype.onConfigure = function (w) {
onConfigure?.apply(this, arguments);
if (w?.widgets_values?.length) {
outSet.call(this, w.widgets_values);
}
};
}
},
});