Nodes/ComfyUI_DW_Chat/File-based Chat
ComfyUI Node

File-based Chat

A cheap RAG-ish knowledge base from your own files, via Kimi

By yiwangsimple·Created 2 years ago·Updated about a year ago· 89
File-based Chat
    • STRING
    file_paths
    user_input
    use_cachetrue
    cache_tagfile_cache
    ttl300

    File-based Chat is the pack's "chat with your documents" node, and the README frames it exactly right: a low-cost knowledge-base trick built on Kimi (Moonshot AI). You give it a list of files - the README explicitly mentions pdf, doc, xlsx, ppt, txt, and images - plus a question, and it answers based on those files. The author's example workflow is telling: they uploaded a "common error problems" document so the chat could help fix ComfyUI errors by consulting the docs. That's the use case: a mini RAG for your own reference material, without setting up a vector database.

    The mechanism is Moonshot's file API. The node takes file_paths (multiline, one file per line), uploads each to Moonshot via an HTTP POST, pulls the parsed text back down, and stuffs it into the message list as a system message - so the model literally reads your document's text as context, then answers user_input. It uses the moonshot-v1-8k model with a Kimi system prompt, and it keeps conversation history too, so follow-ups build on earlier answers.

    The caching inputs are the interesting bit: use_cache (default true), cache_tag, and ttl (default 300s, 60–3600). The node checks Moonshot's server-side caching by tag and serves a cached answer if one is fresh, rather than re-spending tokens on the same question. That's a real cost-saver for repeated queries, and it's the only node in this pack with built-in caching.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/yiwangsimple/ComfyUI_GroqChat
    

    restart, copy api_key.ini.exampleapi_key.ini, and set MOONSHOT_API_KEY from platform.moonshot.cn/console/api-keys. httpx and openai come from requirements.txt. No model downloads - it's all cloud.

    Gotchas

    The upload-and-reparse happens once per node lifetime (files are cached in self.file_messages), so if you change a file on disk you need a fresh node to pick it up. If the file's text is huge, you'll blow past the 8k context - there's no 128k variant here, which is a real ceiling for long docs. And the whole thing is Moonshot's API doing the heavy lifting, so you're trusting your document contents to a Chinese cloud provider; fine for error docs, worth a pause for sensitive material. Also note the ini section quirk: it reads MOONSHOT_API_KEY from [API_KEYS], which the example file provides. Cheap, clever, narrow - for a permanent knowledge base you'd want real RAG tooling, but as a "ask my doc a question" node it works.

    Category🌙DW/Chat

    Inputs (5)

    NameTypeDefaultDescription
    file_pathsSTRING
    user_inputSTRING
    use_cacheBOOLEANtrue
    cache_tagSTRINGfile_cache
    ttlINT30060–3600

    Outputs (1)

    NameTypeDescription
    STRINGSTRING