Skip to content

Commit

Permalink
made comparison generic with a backwards compatible default
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-w-nick committed Dec 21, 2024
1 parent 6ff9229 commit 83a9db6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion langchain-core/src/structured_query/functional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class FunctionalTranslator extends BaseTranslator {
* @param comparison The comparison part of a structured query.
* @returns A function that takes a `Document` as an argument and returns a boolean based on the comparison.
*/
visitComparison(comparison: Comparison): this["VisitComparisonOutput"] {
visitComparison(comparison: Comparison<string | number | boolean>): this["VisitComparisonOutput"] {
const { comparator, attribute, value } = comparison;
const undefinedTrue = [Comparators.ne];
if (this.allowedComparators.includes(comparator)) {
Expand Down
4 changes: 2 additions & 2 deletions langchain-core/src/structured_query/ir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ export abstract class FilterDirective extends Expression {}
* Class representing a comparison filter directive. It extends the
* FilterDirective class.
*/
export class Comparison extends FilterDirective {
export class Comparison<ValueTypes = string | number> extends FilterDirective {
exprName = "Comparison" as const;

constructor(
public comparator: Comparator,
public attribute: string,
public value: string | number | boolean
public value: ValueTypes
) {
super();
}
Expand Down

0 comments on commit 83a9db6

Please sign in to comment.