/** * @license * Copyright 2025 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import type { IRunConfig, TaskConfig } from "@workglow/task-graph"; import { CreateWorkflow, IExecuteContext, Task } from "@workglow/task-graph"; import { DataPortSchema, TypedArray } from "@workglow/util/schema"; import type { Capability } from "../capability/Capabilities"; import type { ModelConfig } from "../model/ModelSchema"; export declare const ChunkRetrievalInputSchema: { readonly type: "object"; readonly properties: { readonly knowledgeBase: { readonly title: "Knowledge Base"; readonly description: "Knowledge base ID or instance"; } & { title: string; description: string; } & { readonly format: "knowledge-base"; readonly anyOf: readonly [{ readonly type: "string"; readonly title: "Knowledge Base ID"; }, { readonly title: "Knowledge Base Instance"; readonly additionalProperties: true; }]; }; readonly query: { readonly oneOf: readonly [{ readonly type: "string"; }, { readonly type: "array"; readonly format: "TypedArray"; readonly title: "Typed Array"; readonly description: "A typed array (Float32Array, Int8Array, etc.)"; }]; readonly title: "Query"; readonly description: "Query string (requires `model`) or pre-computed query vector"; }; readonly model: { readonly oneOf: readonly [{ readonly title: "Model"; readonly description: `The model ${string}`; } & { title: string; description: string; } & { readonly format: import(".").TypeModelSemantic; readonly type: "string"; }, { readonly type: "object"; readonly properties: { readonly model_id: { readonly type: "string"; }; readonly capabilities: { readonly type: "array"; readonly items: { readonly type: "string"; }; readonly "x-ui-editor": "multiselect"; }; readonly title: { readonly type: "string"; }; readonly description: { readonly type: "string"; readonly "x-ui-editor": "textarea"; }; readonly provider: { readonly type: "string"; }; readonly provider_config: { readonly type: "object"; readonly properties: { readonly credential_key: { readonly type: "string"; readonly format: "credential"; readonly "x-ui-hidden": true; }; readonly native_dimensions: { readonly type: "integer"; readonly description: "Native output vector dimensions for embedding models"; }; readonly mrl: { readonly type: "boolean"; readonly description: "Whether the model supports Matryoshka Representation Learning"; }; }; readonly additionalProperties: true; readonly default: {}; }; readonly metadata: { readonly type: "object"; readonly default: {}; readonly "x-ui-hidden": true; }; }; readonly required: readonly ["provider", "provider_config"]; readonly format: "model"; readonly additionalProperties: true; } & { title: string; description: string; } & { readonly format: import(".").TypeModelSemantic; }]; } & { title: string; description: string; } & { readonly format: import(".").TypeModelSemantic; }; readonly method: { readonly type: "string"; readonly enum: readonly ["similarity", "hybrid"]; readonly title: "Retrieval Method"; readonly description: string; readonly default: "similarity"; }; readonly topK: { readonly type: "number"; readonly title: "Top K"; readonly description: "Number of top results to return"; readonly minimum: 1; readonly default: 5; }; readonly filter: { readonly type: "object"; readonly title: "Metadata Filter"; readonly description: "Filter results by metadata fields"; }; readonly scoreThreshold: { readonly type: "number"; readonly title: "Score Threshold"; readonly description: string; readonly minimum: 0; readonly maximum: 1; readonly default: 0; }; readonly vectorWeight: { readonly type: "number"; readonly title: "Vector Weight"; readonly description: "For hybrid method: weight for vector similarity (0-1), remainder goes to text relevance"; readonly minimum: 0; readonly maximum: 1; readonly default: 0.7; }; readonly returnVectors: { readonly type: "boolean"; readonly title: "Return Vectors"; readonly description: "Whether to return vector embeddings in results"; readonly default: false; }; }; readonly required: readonly ["knowledgeBase", "query"]; readonly if: { readonly properties: { readonly query: { readonly type: "string"; }; }; }; readonly then: { readonly required: readonly ["knowledgeBase", "query", "model"]; }; readonly else: {}; readonly additionalProperties: false; }; /** * Intentionally tighter than `FromSchema`'s resolution: encodes the schema's * `if/then/else` (when `query: string`, `model` is required) which * `json-schema-to-ts` ignores. The nightly drift type-test pins this * divergence by asserting one-way assignability rather than equality. */ export type ChunkRetrievalTaskInput = { filter?: { [x: string]: unknown; } | undefined; topK?: number | undefined; method?: "similarity" | "hybrid" | undefined; scoreThreshold?: number | undefined; vectorWeight?: number | undefined; returnVectors?: boolean | undefined; model: string | ModelConfig; query: string; knowledgeBase: unknown; } | { model?: string | ModelConfig | undefined; filter?: { [x: string]: unknown; } | undefined; topK?: number | undefined; method?: "similarity" | "hybrid" | undefined; scoreThreshold?: number | undefined; vectorWeight?: number | undefined; returnVectors?: boolean | undefined; query: TypedArray; knowledgeBase: unknown; }; export type ChunkRetrievalTaskOutput = { vectors?: TypedArray[] | undefined; metadata: { [x: string]: unknown; }[]; chunks: string[]; count: number; query: string | TypedArray; scores: number[]; chunk_ids: string[]; scoreType: "cosine" | "bm25" | "rrf" | "rerank"; }; export type ChunkRetrievalTaskConfig = TaskConfig; /** * End-to-end retrieval task that combines query embedding (if needed), vector * search, and optional hybrid full-text search in a single step. */ export declare class ChunkRetrievalTask extends Task { static type: string; /** Pure-compute retrieval task — uses storage, not a provider capability. */ static readonly requires: readonly Capability[]; static category: string; static title: string; static description: string; static cacheable: boolean; static inputSchema(): DataPortSchema; static outputSchema(): DataPortSchema; execute(input: ChunkRetrievalTaskInput, context: IExecuteContext): Promise; } export declare const chunkRetrieval: (input: ChunkRetrievalTaskInput, config?: ChunkRetrievalTaskConfig, runConfig?: Partial) => Promise; declare module "@workglow/task-graph" { interface Workflow { chunkRetrieval: CreateWorkflow; } } //# sourceMappingURL=ChunkRetrievalTask.d.ts.map