UNPKG

mongodb-rag-core

Version:

Common elements used by MongoDB Chatbot Framework components.

43 lines (41 loc) 1.93 kB
import { Document } from "mongodb"; type MongoDbOutput = Document | number | Document[]; export interface FuzzyMatchExecutionResultsParams { mongoDbOutput: MongoDbOutput; expected: MongoDbOutput; /** If true, the order of elements in arrays matters. @default false */ orderMatters?: boolean; /** If true, the output is an aggregation operation. Handled differently in the following ways: 1. If MongoDB operation returns a scalar value, the truth must be a single object that contains that scalar value as the value of ones of its keys. 2. If MongoDB operation returns a single object or an array of objects, check that the scalar _values_ of objects are the same as the expected values. @default false */ isAggregation?: boolean; /** The allowed difference between numbers for fuzzy matching. @default 0.01 */ allowedNumberDifference?: number; } export declare const ERRORS: { EXPECTED_ARRAY: string; SINGLE_ITEM_ARRAY: string; }; export declare const fuzzyMatchSyntheticKey = "__output__"; export declare function fuzzyMatchExecutionResults({ mongoDbOutput, expected, orderMatters, isAggregation, allowedNumberDifference, }: FuzzyMatchExecutionResultsParams): boolean | null; export declare function fuzzyMatchAggregation(truthArray: Record<string, unknown>[], testInput: MongoDbOutput, nestedArrayOrderMatters: boolean, allowedNumberDifference?: number): boolean; /** Performs a fuzzy match between two arrays of objects. @param truthArray - The array of objects to match against @param testArray - The array of objects to test */ export declare function fuzzyMatchArrays(truthArray: Array<Record<string, unknown>>, testArray: Array<Record<string, unknown>>, orderMatters?: boolean, allowedNumberDifference?: number): boolean; export {}; //# sourceMappingURL=fuzzyMatchExecutionResults.d.ts.map