if-ai / ComfyUI-IF_AI_tools

ComfyUI-IF_AI_tools is a set of custom nodes for ComfyUI that allows you to generate prompts using a local Large Language Model (LLM) via Ollama. This tool enables you to enhance your image generation workflow by leveraging the power of language models.
https://ko-fi.com/impactframes
366 stars 27 forks source link

Comfyui API cannot access local variable #32

Open ThomasRoyer24 opened 1 month ago

ThomasRoyer24 commented 1 month ago

I use a simple workflow from comfyui to generate an image. I tested it with the example proposed by Comfy: websockets_api_example.py and it worked fine. Then I added the ComfyUI-IF_AI_tools technology and there's a bug. The images are generated correctly, but the API get_image() function causes the code to bug. Here's the error:

Traceback (most recent call last): File "d:\ComfyUi\ComfyUI_windows_portable\ComfyUI\script_examples\websockets_api_example.py", line 108, in generated("n") File "d:\ComfyUi\ComfyUI_windows_portable\ComfyUI\script_examples\websockets_api_example.py", line 97, in generated images = get_images(ws, comfy_json) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "d:\ComfyUi\ComfyUI_windows_portable\ComfyUI\script_examples\websockets_api_example.py", line 79, in get_images output_images[node_id] = images_output ^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'images_output' where it is not associated with a value

if-ai commented 1 month ago

there is no mention of my node on this error how do you know is my node? could you provide the complete log from comfyui please, so I can check.

ThomasRoyer24 commented 1 month ago

there is no mention of my node on this error how do you know is my node? could you provide the complete log from comfyui please, so I can check.

There are no errors in the node. The images are generated correctly, but for 2 identical workflows, if I add your node at the beginning for inputs, the API no longer works. This is very strange

if-ai commented 1 month ago

I am kind of in the dark without a way to reproduce the error to see what is happening, I want to help but there is not enough information for me, I haven't come across this error yet. Could you share the workflow and tell me more about where you are running it? is it your local machine or a service somewhere because perhaps is some sort of Rule in the host machine?

ThomasRoyer24 commented 1 month ago

Capture d'écran 2024-05-10 190729

First of all, thank you for taking the time to reply. I'm on my local RTX2070 machine and I'm running the ComfyUI code: websockets_api_example.py which can be found on github: https://github.com/comfyanonymous/ComfyUI/blob/master/script_examples/websockets_api_example.py

This API code works very well with all my other workflows except this one, as well as all those using your node. That I run the code from Visual Studio code that returns the error that returns the error I sent in the first message. If you wish, I can send you my code so that you can test it on your machine.

if-ai commented 1 month ago

could you check with IFChatNode ? on the the new node I move some of the attr as optional to avoid this issue it also includes all the features from prompt to prompt and image to prompt C3gVZNyz8e please let me know if it fix the issue

if-ai commented 1 month ago

you can leave the assistant to none if you are using my models from ollama since they include a system prompt but if you use other models the system prompt will be override by the assistant you can select IFPromptMkr

ThomasRoyer24 commented 1 month ago

could you check with IFChatNode ? on the the new node I move some of the attr as optional to avoid this issue it also includes all the features from prompt to prompt and image to prompt C3gVZNyz8e please let me know if it fix the issue

Unfortunately not i keep getting the error even with the same settings as you...

UnboundLocalError: cannot access local variable 'images_output' where it is not associated with a value