/** * @license * Copyright 2026 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import type { ChunkStrategy, IKbAiStrategy, SearchMode } from "@workglow/knowledge-base"; /** * Tuning knobs for the standard strategy. Most defaults come straight from * the KB (model IDs, chunkStrategy, searchMode); these overrides exist for * callers that want different chunker token budgets than the built-in * defaults or that need to pin a search mode different from what the KB * has stored. */ export interface CreateStandardKbStrategyOptions { readonly chunker?: { readonly maxTokens?: number; readonly overlap?: number; readonly reservedTokens?: number; }; /** Override KB's chunkStrategy at strategy-build time. */ readonly chunkStrategy?: ChunkStrategy; /** Override KB's searchMode at strategy-build time. */ readonly searchMode?: SearchMode; /** * Multiplier applied to `topK` to size the first-stage candidate pool * when `searchMode === "rerank"`. The reranker then narrows the pool * back down to `topK`. Defaults to `5`, i.e. first stage fetches * `topK * 5` candidates. Used together with `firstStageMinimum` — * the actual first-stage size is `max(topK * firstStageMultiplier, * firstStageMinimum)`, so a tiny `topK` (e.g. `1`) still yields a * meaningful candidate pool for the reranker to choose from instead of * collapsing to a single candidate. */ readonly firstStageMultiplier?: number; /** * Minimum first-stage candidate pool size when `searchMode === "rerank"`. * Defaults to `20`. Prevents the rerank pool from collapsing to * `topK` for very small `topK` values where `topK * firstStageMultiplier` * would still be too few candidates for the reranker to do useful work. * The effective first-stage size is * `max(topK * firstStageMultiplier, firstStageMinimum)`. */ readonly firstStageMinimum?: number; } /** * The standard KB strategy: hierarchical-by-default chunking + embedding * during ingest, and a single search mode for retrieval. Search and ingest * read the KB's stored model IDs (`docEmbeddingModel` / * `queryEmbeddingModel` / `rerankerModel`) and config fields * (`chunkStrategy` / `searchMode`) on every call, so updates to the KB * record take effect immediately on the next op. * * Score semantics: results carry `scoreType` matching the retrieval * mode — `"cosine"` for similarity, `"rrf"` for hybrid, `"rerank"` for * both reranker-model and heuristic fallback paths. **Cross-encoder * rerank scores are raw logits**, not probabilities or similarities, and * they are NOT comparable to cosine / BM25 / RRF scores. Always check * `scoreType` before applying a score threshold; the strategy itself * ignores `ISearchOptions.scoreThreshold` in the rerank branch. * * For custom RAG flows (per-tenant scoping, alternative chunkers, etc.) * write your own `IKbAiStrategy` — this factory is the "good defaults" * path, not the only path. */ export declare function createStandardKbStrategy(options?: CreateStandardKbStrategyOptions): IKbAiStrategy; //# sourceMappingURL=createStandardKbStrategy.d.ts.map