Nodes/ComfyUI-GLM4/GLM文本翻译
ComfyUI Node

GLM文本翻译

Chinese ↔ English translation without leaving your workflow

By msola-ht·Created about a year ago·Updated about a year ago· 131
GLM文本翻译
    • translated_text
    text_input你好,世界!
    from_languagezh
    to_languageen
    api_key
    model_nameGLM-4.5-Flash
    temperature0.10
    top_p0.70
    max_tokens1024
    seed0

    The simplest node in the pack, and the most honest about its limits

    GLM_Translation_Text takes a chunk of text, translates it via Zhipu AI's GLM API, and hands back a string. That's it. It's the utility node of the ComfyUI-GLM4 pack, and its headline limitation is in the dropdown: zh and en, and only zh and en. If you need Japanese, Spanish, or anything else, this node isn't it - the supported-language list in the code literally ships with just those two. The source comment says more languages "can be added," but nobody's added them yet.

    Why you'd use it

    The pack's other nodes are built around Chinese-language prompts, and almost every diffusion model worth using was trained on English tags and natural language. So the practical job here is converting a Chinese prompt into English before it hits CLIP Text Encode for FLUX, SDXL, or a video model. You can also use it to translate workflow labels, metadata, or anything else text-shaped sitting in your graph. Wire the translated_text output into a CLIP Text Encode or a text display and you're done.

    How it works

    There's no dedicated translation API behind this. The node builds a system prompt - "you are a professional translation assistant; translate the user's text from X to Y; output only the translation" - and calls the same chat.completions endpoint the chat node uses. That's why temperature defaults to 0.1: the tooltip explicitly recommends a low value for translation so the model stays deterministic and doesn't get creative with your meaning. Leave it low.

    The inputs that matter are few:

    • text_input - what you want translated, multiline.
    • from_language / to_language - each is a dropdown with just zh and en. The config.json in the pack folder can set defaults here if you'd rather not touch the dropdown every time.
    • model_name - defaults to GLM-4.5-Flash, which is the free tier.
    • temperature - keep it at 0.1. That's the whole trick.

    api_key falls back to the ZHIPUAI_API_KEY env var and then config.json, same as the rest of the pack. And yes, seed is the same cosmetic no-op as its siblings - the tooltip admits it only affects node-internal randomness, not the model output.

    Installing it

    Same pack as the other two nodes, so one install gets you all three:

    cd ComfyUI/custom_nodes
    git clone https://github.com/msola-ht/ComfyUI-GLM4.git
    cd ComfyUI-GLM4
    pip install -r requirements.txt
    

    Restart ComfyUI. You need a Zhipu API key from bigmodel.cn (the Flash models are free), which goes in the node field, the ZHIPUAI_API_KEY env var, or the pack's config.json. No model downloads, no VRAM, no torch - the requirements.txt is just zhipuai, Pillow, and numpy.

    Gotchas

    • It's a translation node, not a multilingual one. Two languages, period. If your workflow needs more, you're looking at an LLM party node or a generic LLM chat node instead.
    • Empty input returns an empty string, quietly - no error, just nothing. If your workflow ever feeds it a blank, the output will be blank and nothing tells you why.
    • Errors come back as text. Like the rest of the pack, an API failure (bad key, quota, whatever) is returned as the node's output string rather than crashing ComfyUI. Read the output, not just the canvas.
    • Same thin maintenance. One-person hobby pack, Chinese README, and the changelog itself warns that Zhipu's library updates outran the plugin. It works today; treat it as a utility, not infrastructure.

    For a zero-cost zh↔en step inside a workflow, it does exactly what it says. Just don't ask it for more languages.

    CategoryGLM

    Inputs (9)

    NameTypeDefaultDescription
    text_inputSTRING你好,世界!
    from_languageCOMBOzh源语言
    to_languageCOMBOen目标语言
    api_keySTRING
    model_nameSTRINGGLM-4.5-Flash
    temperatureFLOAT0.100–1翻译任务建议较低的温度值以保持准确性
    top_pFLOAT0.700–1
    max_tokensINT10241–4096
    seedINT00–18446744073709550000设置为0时,每次运行生成随机种子;设置为其他值时,使用固定种子。注意:此种子仅影响ComfyUI节点内部的随机数生成,不直接影响智谱AI模型的输出结果。

    Outputs (1)

    NameTypeDescription
    translated_textSTRING