/** * @license * Copyright 2026 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import type { TaskConfig } from "@workglow/task-graph"; import { CreateWorkflow } from "@workglow/task-graph"; import type { DataPortSchema } from "@workglow/util/schema"; import type { ModelConfig } from "../model/ModelSchema"; import { AiTask } from "./base/AiTask"; export type TextRerankerTaskInput = { topK?: number | undefined; model: string | ModelConfig; query: string; documents: string[]; }; export type TextRerankerTaskOutput = { scores: number[]; indices: number[]; }; export type TextRerankerTaskConfig = TaskConfig; /** * Thrown by reranker provider run-fns when the underlying ML pipeline * returns output that doesn't match the expected `{ label, score }` * shape (or array thereof when `top_k > 1`). Co-located with the task * definition so callers can `instanceof`-test against a single import * regardless of which provider is installed. * * `actualShape` is a truncated, JSON-stringified snippet of the offending * entry — enough to point an operator at the misconfigured model without * dumping arbitrary tensors into logs. */ export declare class KbRerankerOutputError extends Error { readonly actualShape: unknown; constructor(message: string, actualShape: unknown); } /** * AiTask for cross-encoder reranking. Providers register a run-fn for this * task type (e.g. HuggingFace Transformers using a `text-classification` * cross-encoder pipeline on `[query, doc]` pairs). `createStandardKbStrategy` * invokes this task as the rerank stage of `kb.search()` when the KB is * configured with `searchMode: "rerank"` and has a `rerankerModel` set. */ export declare class TextRerankerTask extends AiTask { static type: string; static category: string; static title: string; static description: string; static readonly requires: ["text.reranking"]; static inputSchema(): DataPortSchema; static outputSchema(): DataPortSchema; } export declare const textReranker: (input: TextRerankerTaskInput, config?: TextRerankerTaskConfig) => Promise; declare module "@workglow/task-graph" { interface Workflow { textReranker: CreateWorkflow; } } //# sourceMappingURL=TextRerankerTask.d.ts.map