Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove result in UI after executed #186

Merged
merged 13 commits into from
Oct 26, 2024
Merged
10 changes: 9 additions & 1 deletion .github/workflows/workflow-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
check-modified-files:
runs-on: ubuntu-latest
Expand All @@ -16,10 +20,14 @@ jobs:
with:
fetch-depth: 0

- name: Fetch target branch
run: |
git fetch origin ${{ github.base_ref }} --depth=1

- name: Check modified files
id: check_files
run: |
modified_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
modified_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
only_non_code_files=true
for file in $modified_files; do
if [[ "$file" == *.py ]] || [[ "$file" == *.js ]] || [[ "$file" == *.json ]]; then
Expand Down
90 changes: 0 additions & 90 deletions js/siliconcloud_llm_api.js
Original file line number Diff line number Diff line change
@@ -1,95 +1,5 @@
import { app } from "../../scripts/app.js";
import { ComfyWidgets } from "../../scripts/widgets.js";

app.registerExtension({
name: "bizyair.siliconcloud.llm.api.populate",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === "BizyAirSiliconCloudLLMAPI") {
function populate(text) {
if (this.widgets) {
const pos = this.widgets.findIndex((w) => w.name === "showtext");
if (pos !== -1) {
for (let i = pos; i < this.widgets.length; i++) {
this.widgets[i].onRemove?.();
}
this.widgets.length = pos;
}
}

for (const list of text) {
const w = ComfyWidgets["STRING"](this, "showtext", ["STRING", { multiline: true }], app).widget;
w.inputEl.readOnly = true;
w.inputEl.style.opacity = 0.6;
w.value = list;
}

requestAnimationFrame(() => {
const sz = this.computeSize();
if (sz[0] < this.size[0]) {
sz[0] = this.size[0];
}
if (sz[1] < this.size[1]) {
sz[1] = this.size[1];
}
this.onResize?.(sz);
app.graph.setDirtyCanvas(true, false);
});
}

const onExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function (message) {
onExecuted?.apply(this, arguments);
populate.call(this, message.text);
};
}
},
});

app.registerExtension({
name: "bizyair.siliconcloud.vlm.api.populate",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === "BizyAirSiliconCloudVLMAPI") {
function populate(text) {
if (this.widgets) {
const pos = this.widgets.findIndex((w) => w.name === "showtext");
if (pos !== -1) {
for (let i = pos; i < this.widgets.length; i++) {
this.widgets[i].onRemove?.();
}
this.widgets.length = pos;
}
}

for (const list of text) {
const w = ComfyWidgets["STRING"](this, "showtext", ["STRING", { multiline: true }], app).widget;
w.inputEl.readOnly = true;
w.inputEl.style.opacity = 0.6;
w.value = list;
}

requestAnimationFrame(() => {
const sz = this.computeSize();
if (sz[0] < this.size[0]) {
sz[0] = this.size[0];
}
if (sz[1] < this.size[1]) {
sz[1] = this.size[1];
}
this.onResize?.(sz);
app.graph.setDirtyCanvas(true, false);
});
}

const onExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function (message) {
onExecuted?.apply(this, arguments);
populate.call(this, message.text);
};
}
},
});

// 通用的模型获取和更新函数
const createModelFetchExtension = (nodeName, endpoint) => {
return {
name: `bizyair.siliconcloud.${nodeName.toLowerCase()}.api.model_fetch`,
Expand Down
6 changes: 3 additions & 3 deletions llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_llm_model_response(
)
ret = json.loads(response)
text = ret["choices"][0]["message"]["content"]
return {"ui": {"text": (text,)}, "result": (text,)}
return (text,) # if update ui: {"ui": {"text": (text,)}, "result": (text,)}


class SiliconCloudVLMAPI:
Expand Down Expand Up @@ -183,7 +183,7 @@ def get_vlm_model_response(
)
ret = json.loads(response)
text = ret["choices"][0]["message"]["content"]
return {"ui": {"text": (text,)}, "result": (text,)}
return (text,)


class BizyAirJoyCaption:
Expand Down Expand Up @@ -269,7 +269,7 @@ def joycaption(self, image, do_sample, temperature, max_tokens):
raise Exception(f"Unexpected response type: {msg}")

caption = msg["data"]
return {"ui": {"text": (caption,)}, "result": (caption,)}
return (caption,)


NODE_CLASS_MAPPINGS = {
Expand Down
Loading