Nodes/comfyui-aichat/OpenAI 文本块
ComfyUI Node

OpenAI 文本块

The text chunk builder for OpenAI messages

By spawner1145·Created about a year ago·Updated 10 days ago· 3
OpenAI 文本块
    • content_item
    text

    The most boring node in the pack, on purpose

    OpenAITextBlock wraps any string as an OAI_CONTENT_ITEM - a {"type": "text", "text": ...} part - so it can flow through the same content pipeline as encoded images and uploaded files. One input, one output, zero settings.

    You won't reach for it if you're sending a single literal prompt - OpenAIChat's user_prompt covers that. It earns its keep when the text isn't a typed literal but a value arriving from elsewhere in the graph: a wildcard expansion, a metadata string, an OCR output, a transcription. Drop that dynamic string into text, and the content_item output plugs into an OpenAIChat content slot or sits beside an encoded image in an OpenAIContentConnector.

    Inputs and output

    text - a multiline string, default empty. content_item - the resulting OAI_CONTENT_ITEM.

    That's all there is. No escaping, no templating, no merging - combine multiple texts upstream or run several blocks. If you want text plus image plus file in one message, text block + encoder/uploader + connector is the intended assembly.

    Gotchas

    • Sending the same text in user_prompt and in a text block duplicates it in the message. Pick one place.
    • An empty block produces an empty text part, which the Chat node skips as falsy - harmless, but keep the graph readable.
    • Local-only: nothing is sent until the content item reaches OpenAIChat, so a dormant block costs nothing.

    Install

    With the pack via ComfyUI Manager (search "comfyui-aichat") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/spawner1145/comfyui-aichat
    

    Restart ComfyUI. No models to download; dependencies are just openai, httpx, and PyYAML. When you're building multi-part messages, a node this simple is exactly what you want between the parts that actually do something.

    CategoryOpenAI API/Content

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (1)

    NameTypeDescription
    content_itemOAI_CONTENT_ITEM