Whatever message this page gives is out now! Go check it out!
SimpleRAG(
source, // Required — String or Array
model, // Required — CF ChatModel or Struct
options // Optional — Struct
)Parameter | Type | Required | Description |
|---|---|---|---|
source | String / Array | Required | A local file path (e.g., "./docs/manual.pdf"), a local directory path (e.g., "./docs/") that is recursively scanned, a URL (e.g., "https://example.com/guide.html"), or an array of any combination of the above. |
model | CF ChatModel / Struct | Required | A CF ChatModel object returned by ChatModel(), or a Struct with at minimum provider and credential keys. |
options | Struct | Optional | Configuration overrides. See the Options Struct Keys table below. Omitting this parameter uses intelligent defaults suitable for most use cases. |
Key | Type | Default | Description |
|---|---|---|---|
chunkSize | Numeric | 1000 | Maximum character count per document chunk. |
chunkOverlap | Numeric | 200 | Overlapping characters between consecutive chunks to preserve context. |
splitterType | String | "recursive" | Splitting strategy: "recursive", "paragraph", "sentence", "line", "character", "word", "regex". When splitterType = "regex", the regexPattern key is required; omitting it throws an "Invalid document splitter configuration" validation error. |
maxResults | Numeric | 5 | Maximum document chunks retrieved per query. |
minScore | Numeric | 0.7 | Minimum similarity score (0.0–1.0) for retrieved chunks. |
vectorStore | VectorStore | In-memory | A VectorStore() instance. Defaults to in-memory with all-minilm-l6-v2 embeddings. |
batchSize | Numeric | 100 | Number of text segments processed per batch during ingestion. |
continueOnError | Boolean | false | When true, the ingestion pipeline skips failed segments and continues processing the remaining ones instead of stopping at the first failure. |
recursive | Boolean | false | When true, document loading traverses subdirectories under the given path. When false, loading is limited to the top-level directory only. |
.ingest() or .ingestAsync() before querying.// Minimum required: source path + model config
modelConfig = {
provider: "openai",
credential: "sk-your-api-key"
};
ragBot = SimpleRAG("./docs/", modelConfig);
ragBot.ingest();
answer = ragBot.ask("What are the system requirements?");
writeOutput(answer.message);chatModel = ChatModel({
provider: "openai",
model: "gpt-4",
apiKey: "sk-your-api-key"
});
vectorStoreClient = VectorStore({
provider: "qdrant",
url: "http://enterprise-qdrant.internal:6333",
collection: "cf_documentation",
embeddingModel: {
provider: "openai",
model: "text-embedding-3-large",
apiKey: "sk-your-api-key"
}
});
ragBot = SimpleRAG("./docs/", chatModel, {
vectorStore: vectorStoreClient,
chunkSize: 1500,
chunkOverlap: 200,
maxResults: 10,
minScore: 0.6
});
// Non-blocking ingestion
future = ragBot.ingestAsync();
result = future.get();
response = ragBot.ask("How do I use cfquery?");
writeOutput(response.message);ragBot = SimpleRAG(expandPath("./docs/"), chatModel, {
vectorStore: vs,
recursive: true,
continueOnError: false,
chunkSize: 500,
chunkOverlap: 100
});