import { Document, Genkit, z } from "genkit"; import { GenkitPlugin } from "genkit/plugin"; import { FGAClientParams } from "@auth0/ai"; import { ClientBatchCheckItem, ConsistencyPreference } from "@openfga/sdk"; export type FGARerankerCheckerFn = (doc: Document) => ClientBatchCheckItem; export type FGARerankerConstructorArgs = { buildQuery: FGARerankerCheckerFn; consistency?: ConsistencyPreference; }; export type FGARerankerArgs = FGARerankerConstructorArgs & { ai: Genkit; }; /** * A Reranker that allows filtering documents based on access control checks * using OpenFGA. This class performs batch checks on retrieved documents, returning only the ones that pass the * specified access criteria. ALl filtered docs have maximum score of 1. * * * @remarks * The FGAReranker requires a buildQuery function to specify how access checks * are formed for each document, the checks are executed via an OpenFGA client * or equivalent mechanism. The checks are then mapped back to their corresponding * documents to filter out those for which access is denied. * * @example * ```ts * const reranker = FGAReranker.create({ * ai, * buildQuery: (doc) => ({ * user: `user:${user}`, * object: `doc:${doc.metadata.id}`, * relation: "viewer", * }), * }); * ``` */ export declare class FGAReranker { lc_namespace: string[]; static lc_name(): string; private fgaFilter; private constructor(); /** * Creates a new FGAReranker instance using the given arguments and optional OpenFgaClient. * * @param args - @FGARerankerArgs * @param args.ai - A Genkit Instance. * @param args.buildQuery - A function to generate access check requests for each document. * @param fgaClientParams - Optional - OpenFgaClient configuration to execute checks against. * @returns A Reranker instance instance configured with the provided arguments. */ static create({ ai, buildQuery }: FGARerankerArgs, fgaClientParams?: FGAClientParams): import("genkit").RerankerAction; }, "strip", z.ZodTypeAny, { k?: number | undefined; }, { k?: number | undefined; }>>; /** * Retrieves a filtered list of documents based on permission checks. * * @param documents - An array of documents to be checked for permissions. * @returns A promise that resolves to an array of documents that have passed the permission checks. */ private filter; } export declare function auth0(): GenkitPlugin; //# sourceMappingURL=fga-reranker.d.ts.map