Nodes/Quality of life Suit:V2/Chat completion _O
ComfyUI Node

Chat completion _O

The payoff node of the advanced ChatGPT chain

By omar92·Created 3 years ago·Updated 5 months ago· 181
Chat completion _O
  • client
  • messages
  • STRING
  • OPENAI_CHAT_COMPLETION
modelgpt-3.5-turbo
seed0

Everything in the Quality of Life Suit's Advanced OpenAI section funnels into Chat completion _O. It's the node that actually calls OpenAI: you feed it a client, a model, and a list of chat messages, and it returns the model's reply as a STRING - ready to wire into a CLIP Text Encode - plus the raw completion object if you want to inspect it.

It sits under O/OpenAI/Advanced/ChatGPT, and the full chain is the pack's own documented example workflow:

  1. load_openAI _O - creates the API client.
  2. Chat_Message _O ×2 - one system message to set behavior, one user message with your prompt.
  3. combine_chat_messages _O - merges them into one message list.
  4. Chat completion _O - sends it, gets the answer.

Output that STRING into your positive conditioning and you've got an AI-assisted prompt pipeline where every stage is visible and editable.

How it works

The node calls client.chat.completions.create(model=model, messages=messages) and returns completion.choices[0].message.content as the string, plus the full completion object. It even retries once if the first call throws - a nod to flaky connections that people do hit.

Inputs:

  • client - a CLIENT from load_openAI _O. That loader defaults its base_url to a community Cloudflare-worker proxy, but you can point it at any OpenAI-compatible endpoint, including the official one.
  • model - dropdown: gpt-3.5-turbo (the one that works against a standard OpenAI endpoint) or @cf/meta/llama-2-7b-chat-int8 (Cloudflare Workers ID, only useful behind the proxy default).
  • messages - the OPENAI_CHAT_MESSAGES you built.
  • seed - optional, and ignored. The code accepts it but never passes it to the API; OpenAI's chat API has no seed parameter. Decorative.

Outputs: STRING (the reply) and OPENAI_CHAT_COMPLETION (the raw object, handy with the pack's debug nodes).

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/omar92/ComfyUI-QualityOfLifeSuit_Omar92.git

or ComfyUI Manager → search ComfyUI-QualityOfLifeSuit_Omar92, then restart. The openai package installs on demand. You need an API key - either passed into load_openAI _O or sitting in the pack's config.json.

Where it bites

The pack's OpenAI integration is historically fragile across SDK versions. The openai>=1.0.0 release broke the older interface (community threads showed openai.Model access errors), and while the current code uses the newer OpenAI client, expect the occasional "API key is invalid" message that's really a slow model-list check timing out. Also: because this node needs a real OpenAI account with billing, the whole advanced chain is a paid experiment - fine for tinkering, but if you just want a prompt starter, ChatGPT Simple _O gets you 80% there for half the moving parts.

CategoryO/OpenAI/Advanced/ChatGPT

Inputs (4)

NameTypeDefaultDescription
clientCLIENT
modelCOMBOgpt-3.5-turbo2 options: @cf/meta/llama-2-7b-chat-int8, gpt-3.5-turbo
messagesOPENAI_CHAT_MESSAGES
seedoptINT00–18446744073709550000

Outputs (2)

NameTypeDescription
STRINGSTRING
OPENAI_CHAT_COMPLETIONOPENAI_CHAT_COMPLETION