Nodes/LiamUtil/AiStoreAzureGPT @Liam
ComfyUI Node

AiStoreAzureGPT @Liam

An Azure OpenAI chat node with built-in conversation memory

By ai-liam·Created 2 years ago·Updated 2 years ago· 2
AiStoreAzureGPT @Liam
    • text
    • messages
    • session_history
    prompthi
    api_keyapi-key
    api_urlhttp://ai.com/api
    system_contentYou are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.
    modelgpt-3.5
    context_size1
    topic_id1
    uid123

    This is a chat-completion node that talks to an Azure OpenAI–style API endpoint and, unusually for a ComfyUI LLM node, keeps a real conversation history alive across runs. If you've got an Azure OpenAI deployment (or any service that mimics its /chat/completions shape with an api-key header), this lets you drop a working LLM into the graph for prompt expansion, captioning, or any text task - and it'll remember what you said to it earlier.

    The name is doing a lot of work, though. There's no "AiStore" product behind this; it's a thin HTTP wrapper around whatever URL you point it at. The api_url default is literally http://ai.com/api - a placeholder that won't do anything until you replace it with your real Azure endpoint.

    How it works

    Each time it runs, the node builds a messages array - your system_content prompt, the last context_size exchanges of history, and your new prompt - and POSTs it to api_url with the api-key header that Azure OpenAI expects. It parses choices[0].message.content from the reply, hands it back as text, and appends your prompt and the assistant's answer to an in-memory history list.

    That history is the interesting part. It's stored on the node instance in Python, keyed by a uid you supply, so a single graph can keep distinct conversations per user. Change topic_id and the history for that uid resets - a cheap way to say "start a new conversation."

    The inputs that matter

    Most fields are self-explanatory, but three are worth calling out:

    • api_url - your actual Azure endpoint, e.g. https://<resource>.openai.azure.com/openai/deployments/<deployment>/chat/completions?api-version=2024-02-15-preview. This is the single field that makes or breaks the node.
    • api_key - your Azure key. It goes in the api-key header, not a Bearer token, which is exactly how Azure wants it.
    • context_size - how many past messages get sent with each call. The default is 1, so out of the box it barely uses that history it's so proud of. Raise it (the slider goes to 30) once you actually want multi-turn context.
    • model lets you pick gpt-3.5, gpt-4, or gpt-4o - the names are cosmetic unless your endpoint accepts them.

    The three outputs are text (the reply), messages (the JSON payload actually sent), and session_history (the accumulated conversation). The last two are great for debugging what the API actually saw, and text wires into anything that eats a string - a prompt encoder, a Save Text node, a display.

    Installing it

    This ships in the LiamUtil pack. Easiest path: ComfyUI Manager → search LiamUtil → install → restart. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ai-liam/comfyui-liam
    pip install -r requirements.txt
    

    The only dependency is opencv-python (used by the image half of the pack). No models to download.

    Where people get burned

    The big one is the memory. History lives in the Python process, keyed by uid - so it survives run to run, but the moment you restart ComfyUI the whole conversation vanishes. If you're building a chatbot-style workflow, don't expect persistence across restarts.

    Second, context_size defaulting to 1 makes the node feel memory-less even when it isn't - bump it before you judge the multi-turn behavior. And if the endpoint errors, the node quietly returns an empty string rather than surfacing the API's error body, so "no output" and "bad key" look identical until you inspect messages. Finally, the fixed model list (gpt-3.5/gpt-4/gpt-4o) is only a dropdown; if your deployment uses a custom name it just needs your endpoint to accept one of those strings.

    CategoryLiam/LLM

    Inputs (8)

    NameTypeDefaultDescription
    promptSTRINGhi
    api_keySTRINGapi-key
    api_urlSTRINGhttp://ai.com/api
    system_contentSTRINGYou are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.
    modelCOMBOgpt-3.53 options: gpt-3.5, gpt-4, gpt-4o
    context_sizeINT10–30
    topic_idSTRING1
    uidSTRING123

    Outputs (3)

    NameTypeDescription
    textSTRING
    messagesSTRING
    session_historySTRING