Nodes/ComfyUI-Gemini-3/Gemini 3 聊天
ComfyUI Node

Gemini 3 聊天

The loop lives in a JSON string

By xuchenxu168·Created 10 months ago·Updated 10 months ago· 4
Gemini 3 聊天
    • response
    • updated_history
    • usage_metadata
    message你好,请介绍一下你自己
    api_providergoogle
    api_key
    modelgemini-3-pro-preview
    thinking_levelhigh
    chat_history
    system_instruction
    max_output_tokens8192

    Most LLM nodes are one-shot: prompt in, answer out, memory wiped. Gemini3Chat is the one node in this pack that's built for a conversation. It takes a message and a chat_history, returns an answer and an updated history, and if you wire that history back into the same node you get a real multi-turn loop - the kind of thing that's surprisingly rare in ComfyUI, where everything defaults to stateless plumbing.

    You'd reach for this when your workflow is a dialogue, not a single translation. A workflow that asks Gemini to critique a prompt, then asks follow-up questions about its own critique. An agent-style step where the model needs to remember what it decided three turns ago. The whole point is that the memory lives in the updated_history string, so the graph itself doesn't have to.

    How it works

    The node expects chat_history as JSON - an array of {"role": "user" | "model", "parts": [...]} entries. It parses that, appends your new message, sends the whole conversation to Google's generateContent endpoint, then rebuilds the history: your message goes in as a user turn, the model's reply goes in as a model turn, and critically, any thoughtSignature in the response is preserved in the history. That thought-signature carryover is what keeps the reasoning context coherent across turns instead of each message being a fresh start.

    The loop is manual but simple: connect updated_history to the chat_history input of the next copy of the node, or run the node once per turn in a pipeline and thread the string through.

    Inputs and outputs that matter

    Required: message (what you say this turn), plus the usual api_provider, api_key, model, and thinking_level - same defaults as the rest of the pack (gemini-3-pro-preview, high thinking).

    Optional:

    • chat_history - the JSON from a previous run. Leave it empty for the first turn.
    • system_instruction - set the persona once and it applies to every turn.
    • max_output_tokens - cap on the reply, default 8192.

    Outputs: response (the model's text), updated_history (the JSON to feed back in - this is the one that matters), and usage_metadata (token counts, useful when a long conversation is burning through your quota).

    Install

    Same pack as every Gemini 3 node here - ComfyUI Manager (search "ComfyUI-Gemini-3") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/xuchenxu168/ComfyUI-Gemini-3
    cd ComfyUI-Gemini-3
    pip install -r requirements.txt
    

    No models to download. You need a Google AI Studio key via GEMINI_API_KEY, the pack's config.json, or the api_key field on the node.

    Common issues

    • History never grows - if you don't wire updated_history back into chat_history, every turn starts fresh. That's the most common "why doesn't it remember" report, and it's expected behavior, not a bug.
    • Corrupt history JSON - if chat_history isn't valid JSON, the node silently drops it and treats the turn as the first one. If a long conversation suddenly forgets everything, check that the history string wasn't truncated somewhere in the plumbing.
    • It's a chat, not an agent. This node keeps a conversation alive, but it won't call tools on its own - for that, you want the pack's function calling node, and the two compose fine (a chat history can carry function-call parts).

    The one real gotcha is cost: every turn re-sends the whole history plus a thinking-level high model's deliberation, so a 20-turn session is 20 billable round-trips. If you're iterating on a long persona doc, consider caching the system context instead - that's what the pack's context cache nodes are for.

    CategoryGemini3/高级

    Inputs (8)

    NameTypeDefaultDescription
    messageSTRING你好,请介绍一下你自己
    api_providerCOMBOgoogle1 options: google
    api_keySTRING
    modelCOMBOgemini-3-pro-preview1 options: gemini-3-pro-preview
    thinking_levelCOMBOhigh2 options: high, low
    chat_historyoptSTRING
    system_instructionoptSTRING
    max_output_tokensoptINT819216–8192

    Outputs (3)

    NameTypeDescription
    responseSTRING
    updated_historySTRING
    usage_metadataSTRING