File-based Chat
A cheap RAG-ish knowledge base from your own files, via Kimi
- STRING
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.example → api_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.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| file_paths | STRING | — | |
| user_input | STRING | — | |
| use_cache | BOOLEAN | true | — |
| cache_tag | STRING | file_cache | — |
| ttl | INT | 30060–3600 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |