RAG Nodes

Applies to: ChengOS v0.2.0+ | Last verified: 2026-09-25 | Source: crates/cheng-nodes/src/nodes/builtin/rag, crates/cheng-nodes/src/nodes/builtin/ai

A retrieval pipeline is assembled in order: rag/chunker splits a document, rag/document_indexer embeds and stores the chunks, rag/retriever pulls candidates back at query time, and rag/formatter turns them into the prompt an LLM node consumes. rag/kb_manager handles the knowledge base itself rather than its contents. ai/embedding_config and ai/qdrant_config are configuration ports shared by the pipeline. Prefer the *_artifact ports over the inline arrays: the inline forms are bounded previews, and the artifact carries the complete set.

Document Chunker — rag/chunker

Split documents into parent and child chunks, supports structural/fixed/semantic/hybrid modes

Inputs

FieldTypeRequiredDefaultDescription
contentstring—""Document text content to chunk (optional if content_artifact is provided)
content_artifactobject—nullArtifact holding the document text to chunk (preferred for large documents)
content_artifact_uristring—nullartifact:// URI for the document text to chunk
legacy_inline_chunksboolean—falseDeprecated compatibility: also emit the full parent_chunks / child_chunks arrays inline. Off by default — normal execution returns only chunks_artifact plus bounded previews.
document_idstring—nullDocument identifier (optional, auto-generated if not provided)
modestring—nullSelect document chunking method. Control: select
parent_chunk_charsinteger—nullParent chunk size in characters. Control: select
child_chunk_charsinteger—nullChild chunk size in characters. Control: select
max_embedding_charsinteger—nullMaximum embedding chunk size - HARD SAFETY LIMIT. Control: select

Outputs

FieldTypeDescription
document_idstringProcessed document ID
chunks_artifactobjectArtifact holding the complete parent+child chunk set
parent_previewarray<object>Bounded parent-chunk preview
child_previewarray<object>Bounded child-chunk preview
preview_truncatedbooleanTrue when previews omit chunks or truncate text
parent_chunksarray<object>Deprecated inline parent chunks
child_chunksarray<object>Deprecated inline child chunks
parent_countintegerTotal parent chunk count
child_countintegerTotal child chunk count
modestringChunking mode used

Document Indexer — rag/document_indexer

Index documents into vector database (standard/enhanced modes)

Inputs

FieldTypeRequiredDefaultDescription
kb_idstring✅—Target knowledge base (collection resolved from DB, workspace-validated). Control: dynamic-select
qdrant_configobject (port)✅—Qdrant configuration object from config node. Connection port, not a form field. Control: text
contentstring—nullDocument text content to index (optional if chunks are provided from chunker)
document_idstring—nullDocument identifier (optional, auto-generated if not provided)
document_titlestring—nullReadable document title/source label (optional, falls back to workspace name)
versioninteger—nullDocument version number (optional, for idempotency check)
parent_chunksarray—nullParent chunks from chunker node (optional, if provided skips internal chunking)
child_chunksarray—nullChild chunks from chunker node (optional)
chunks_artifactobject—nullArtifact from rag/chunker holding the full chunk set (preferred input)
chunks_artifact_uristring—nullartifact:// URI for the chunk collection
index_modestring—nullStandard or enhanced mode. Control: select
embedding_configobject (port)✅—Embedding configuration object from config node. Connection port, not a form field. Control: text
generate_contextboolean—nullUse LLM to generate context descriptions for each chunk (enhanced mode)
llm_configobject (port)—nullLLM configuration object from config node (optional, for context generation). Connection port, not a form field. Control: text

Outputs

FieldTypeDescription
document_idstringIndexed document ID
parent_chunksintegerNumber of parent chunks created
child_chunksintegerNumber of child chunks created
vectors_storedintegerTotal vectors stored
context_generatedbooleanWhether context descriptions were generated
index_modestringIndex mode used
collection_namestringTarget collection name
skippedbooleanWhether skipped due to idempotency check
successbooleanWhether indexing succeeded
summarystringExecution result summary
errorstringError message if any

Knowledge Retriever — rag/retriever

Retrieve relevant documents from vector database (economy/power/ultimate modes)

Inputs

FieldTypeRequiredDefaultDescription
workspace_scopeenum—ambientUse the runtime workspace, or pin this retriever to one configured workspace. Control: select. Options: ambient, pinned
workspace_idstring (port)—nullWorkspace identifier used when pinned, or an explicit override when wired. Connection port, not a form field. Control: text
kb_idstring✅—Target knowledge base (collection resolved from DB, workspace-validated). Control: dynamic-select
qdrant_configobject (port)✅—Qdrant configuration object from config node. Connection port, not a form field. Control: text
querystring✅—Query text for retrieval (accepts string or ChatContext)
retrieval_modestring—nullSelect retrieval strategy. Control: select
limitinteger—nullMaximum number of results to return
embedding_configobject (port)✅—Embedding configuration object from config node. Connection port, not a form field. Control: text
llm_configobject (port)—nullLLM configuration object from config node (optional, for HyDE). Connection port, not a form field. Control: text
document_filterarray—nullList of document IDs to limit retrieval scope (optional)

Outputs

FieldTypeDescription
documentsarray<object>Bounded list of retrieved documents
documents_artifactobjectArtifact holding the complete retrieved-document set
documents_previewstringBounded preview of retrieved documents
documents_truncatedbooleanTrue when the inline documents list omits results
countintegerNumber of results returned
retrieval_modestringRetrieval mode used
querystringQuery text used for retrieval
latency_msintegerRetrieval latency in milliseconds
collection_namestringCollection name retrieved from
token_usageobjectEstimated token usage
has_resultsbooleanTrue when at least one document was retrieved
summary_inputobjectLean AgentContext for downstream LLM summarization (conditional: absent when no results)

RAG Formatter — rag/formatter

Format retrieved documents and user query into LLM prompt

Inputs

FieldTypeRequiredDefaultDescription
querystring✅—User question from retriever node query output
documentsarray<object>—[]List of retrieved documents (compatibility; prefer documents_artifact)
documents_artifactobject—nullArtifact from rag/retriever holding the full document set (preferred input)
documents_artifact_uristring—nullartifact:// URI for the retrieved-document set
templatestring—nullSelect prompt template type. Control: select
custom_templatestring—nullCustom prompt template. Available placeholders: {query}, {documents}, {count}. Control: textarea
include_scoresboolean—nullInclude document relevance scores in formatted output
include_sourcesboolean—nullInclude document IDs and source information in formatted output
max_doc_charsinteger—nullMaximum characters per document chunk (0 = unlimited)

Outputs

FieldTypeDescription
promptstringFormatted prompt ready for LLM input (bounded)
prompt_artifactobjectArtifact holding the complete formatted prompt when large
prompt_truncatedbooleanTrue when the inline prompt is bounded and the full text is in prompt_artifact
querystringOriginal query text
document_countintegerNumber of documents included
total_charsintegerTotal characters in formatted output

Knowledge Base Manager — rag/kb_manager

Manage knowledge bases (list, delete, view details)

Inputs

FieldTypeRequiredDefaultDescription
qdrant_configobject (port)✅—Qdrant configuration object from config node. Connection port, not a form field. Control: text
operationstring—listOperation to perform. Control: select
kb_idstring—nullTarget knowledge base (required for delete and info operations). Control: dynamic-select

Outputs

FieldTypeDescription
operationstringOperation performed
successbooleanWhether operation succeeded
collectionsarrayList of knowledge bases
collection_infoobjectKnowledge base details
messagestringOperation message
errorstringError message if any
dataanyGeneric result data

Embedding Config — ai/embedding_config

Select connected Embedding model, output complete configuration

Inputs

FieldTypeRequiredDefaultDescription
embedding_modelstring✅—Select a connected Embedding model. Supports credential_id::model_name or model_name (requires CHENG_DEFAULT_EMBEDDING_CREDENTIAL_ID). Control: llm-model-select
dimensioninteger—1024向量维度. Control: select
batch_sizeinteger—null批量处理大小. Control: select
reranker_modelstring—nullSelect a reranker model (optional, for post-processing optimization). Control: llm-model-select
reranker_top_kinteger—nullReranker Top K. Control: select

Outputs

FieldTypeDescription
embedding_configobject (port)Complete Embedding configuration. Connection port, not a form field.
reranker_configobject (port)Reranker configuration (if a reranker model is configured). Connection port, not a form field.

Qdrant Config — ai/qdrant_config

Configure a Qdrant vector database connection (local/cloud/self-hosted)

Inputs

FieldTypeRequiredDefaultDescription
modestring—localSelect how Qdrant is deployed. Control: select
urlstring—nullQdrant gRPC endpoint URL (default for local mode: http://localhost:6334)
credential_idstring—nullCredential for Qdrant Cloud or an authenticated self-hosted server. Control: credential-select
collection_namestring—nullName of the Qdrant collection (optional, auto-derived from knowledge base if not set)
enable_fulltextboolean—nullWhether to enable a BM25 full-text search index on the collection

Outputs

FieldTypeDescription
modestringQdrant deployment mode
urlstringQdrant gRPC endpoint URL
api_keystringAPI key (used in cloud/authenticated modes)
collection_namestringQdrant collection name
enable_fulltextbooleanWhether full-text search is enabled
credential_idstringCredential ID used, if any
qdrant_configobject (port)Complete Qdrant configuration (JSON object). Connection port, not a form field.

Next steps