05 Gemini Prompt from ZMongo Doc
Pulling a stored document into a Gemini call
- session
- json
- source_text
- gemini_text
- success
05 Gemini Prompt from ZMongo Doc is the node where this pack's two halves - the document store and the Gemini layer - actually fuse. It loads a document from a ZMongo collection, extracts one field from it, wraps that text with your prefix and suffix, and sends the assembled prompt to Gemini.
If you're building the "document ingestion pipeline" the README advertises, this is the workhorse. Store source material as ZMongo documents (from a file ingest or just manual Create Doc), then have Gemini analyze each one by pointing this node at it. It's also the pattern behind "stored prompt templates": keep the content in a database, let this node assemble the actual prompt.
How it works
Required inputs:
session- from the API Key Session node.collection_name/document_id- which document to read.field_path- which dot-path field to pull, defaulttext. Deep paths likeprompt.positivework via dot-notation.prompt_prefix- default "Analyze the following content:\n\n" - prepended to the document text.prompt_suffix- appended after it.model,max_output_tokens,temperature- the usual Gemini knobs.
Optional: system_instruction, cache (cache the document fetch, default off), gemini_prefix, refresh_token.
Outputs:
json- merged payload including both the document fetch and the Gemini response.source_text- the exact field value that got pulled from the document. Hugely useful for debugging "did it read the right thing?"gemini_text- the model's response. The output you wire onward.success- boolean.
Notes
- Field-path errors fail visibly. If the path doesn't exist,
source_textcomes back empty and the node reports failure - a good reason to keepsource_textvisible on a preview while developing. cachematters for big docs. If you're iterating on prompts over the same large document, flippingcacheon avoids re-fetching it every run. Leave it off when the document may have changed.- Watch token budgets. Document text can be huge; pair this with Gemini Count Tokens (count the assembled prompt) or you'll hit context limits on long docs.
- The prefix/suffix split is the design's elegance: content stays in the database, instructions live in the graph. Change "Analyze" to "Summarize" by editing one field, never touching your stored data.
Install
ComfyUI Manager → ComfyUI-ZMongo, or:
cd ComfyUI/custom_nodes
git clone https://github.com/CentralFloridaAttorney/ComfyUI-ZMongo
restart. Needs the API session for both the document fetch and the server-side Gemini call - the pack's heavier local deps (langchain, etc.) aren't needed by this node.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| session | ZMONGO_API_SESSION | — | |
| collection_name | STRING | — | |
| document_id | STRING | — | |
| field_path | STRING | text | — |
| prompt_prefix | STRING | Analyze the following content: | — |
| prompt_suffix | STRING | — | |
| model | STRING | gemini-2.5-flash | — |
| max_output_tokens | INT | 20481–65536 | — |
| temperature | FLOAT | 0.400–2 | — |
| system_instructionopt | STRING | — | |
| cacheopt | BOOLEAN | false | — |
| gemini_prefixopt | STRING | /gemini | — |
| refresh_tokenopt | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| json | STRING | — |
| source_text | STRING | — |
| gemini_text | STRING | — |
| success | BOOLEAN | — |