Not working, but the roundtrip-scaffolding is there.
This commit is contained in:
@@ -4,6 +4,7 @@ from .nodes.string_replace import StringReplace
|
||||
from .nodes.string_node import StringNode
|
||||
from .nodes.string_concat import StringConcat
|
||||
from .nodes.string_from_int import StringFromInt
|
||||
from .nodes.ollama_generate_string import OllamaGenerateString
|
||||
|
||||
from .nodes.tokenizer_vocab import TokenizerVocab
|
||||
|
||||
@@ -24,6 +25,7 @@ NODE_CLASS_MAPPINGS = {
|
||||
"IW_JsonPickItem": JsonPickItem,
|
||||
|
||||
"IW_ModelHook": ModelHook,
|
||||
"IW_OllamaGenerateString": OllamaGenerateString,
|
||||
}
|
||||
|
||||
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
||||
@@ -40,5 +42,9 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"IW_JsonPickItem": "IW JsonPickItem",
|
||||
|
||||
"IW_ModelHook": "IW ModelHook",
|
||||
"IW_OllamaGenerateString": "IW Ollama Generate String",
|
||||
}
|
||||
|
||||
|
||||
|
||||
WEB_DIRECTORY = "./web"
|
||||
@@ -0,0 +1,40 @@
|
||||
import os
|
||||
import json
|
||||
from collections import deque
|
||||
|
||||
from server import PromptServer
|
||||
class OllamaGenerateString :
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"int_value": ("INT",{"defaultInput": True}),
|
||||
"prompt": ("STRING",{"defaultInput": True, "default": "", "multiline": True, "dynamicPrompts": False}),
|
||||
},
|
||||
"optional": {
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING", )
|
||||
FUNCTION = "execute"
|
||||
OUTPUT_IS_LIST = (True,)
|
||||
|
||||
CATEGORY = "iw"
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, int_value, prompt ):
|
||||
return "foo"
|
||||
|
||||
|
||||
def execute(self, int_value, prompt):
|
||||
result = (prompt,)
|
||||
print("Executing with ", prompt)
|
||||
print(" generating new with ", int_value)
|
||||
return { "ui": { "next_int": [int_value], "next_value": [f"super cool: {int_value}"]}, "result": [result] }
|
||||
|
||||
@PromptServer.instance.routes.get("/iw/api/ollama_generate")
|
||||
async def load_drawing(request):
|
||||
print("/iw/api/ollama_generate")
|
||||
@@ -0,0 +1,52 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { api } from "../../scripts/api.js";
|
||||
import { ComfyWidgets } from "../../scripts/widgets.js";
|
||||
|
||||
app.registerExtension({
|
||||
name: "iw.ollama.generate",
|
||||
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
let find_widget = (node, name) => node.widgets.find((w) => w.name === name);
|
||||
if (nodeData.name === "IW_OllamaGenerateString") {
|
||||
console.log("Something ollama thing");
|
||||
nodeType.prototype.initState = function () {
|
||||
console.log("hello");
|
||||
};
|
||||
nodeType.prototype.initWidgets = function (app) {
|
||||
this.setupWidgets();
|
||||
};
|
||||
|
||||
nodeType.prototype.setupWidgets = function (app) {
|
||||
this.addWidget(
|
||||
"combo",
|
||||
"model",
|
||||
"unknown",
|
||||
(value) => {
|
||||
this.tool = value;
|
||||
},
|
||||
{
|
||||
values: ["a", "b", "c"],
|
||||
default: "unknown",
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
this.initWidgets(app);
|
||||
this.initState();
|
||||
};
|
||||
|
||||
nodeType.prototype.onExecuted = function (ui) {
|
||||
// This is after the fact... so we ready the next value.
|
||||
console.log("onExecuted next_value", ui.next_value);
|
||||
let w = find_widget(this, "prompt");
|
||||
w.value = ui.next_value;
|
||||
w.setValue(w.value, false, true);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user