A class that translates or converts StructuredQuery to equivalent Qdrant filters.

Example

const selfQueryRetriever = new SelfQueryRetriever({
llm: new ChatOpenAI(),
vectorStore: new QdrantVectorStore(...),
documentContents: "Brief summary of a movie",
attributeInfo: [],
structuredQueryTranslator: new QdrantTranslator(),
});

const relevantDocuments = await selfQueryRetriever.getRelevantDocuments(
"Which movies are rated higher than 8.5?",
);

Type Parameters

Hierarchy (view full)

Constructors

Properties

VisitComparisonOutput: {}

Type declaration

    VisitOperationOutput: {}

    Type declaration

      allowedComparators: Comparator[] = ...
      allowedOperators: Operator[] = ...

      Methods

      • Merges two filters into one. If both filters are empty, returns undefined. If one filter is empty or the merge type is 'replace', returns the other filter. If the merge type is 'and' or 'or', returns a new filter with the merged results. Throws an error for unknown merge types.

        Parameters

        • defaultFilter: undefined | {}

          The default filter to merge.

        • generatedFilter: undefined | {}

          The generated filter to merge.

        • mergeType: string = "and"

          The type of merge to perform. Can be 'and', 'or', or 'replace'. Defaults to 'and'.

        • forceDefaultFilter: boolean = false

          If true, the default filter is always returned if the generated filter is empty. Defaults to false.

        Returns undefined | {}

        A merged QdrantFilter, or undefined if both filters are empty.

      • Visits a comparison and returns a QdrantCondition. The value is casted to the correct type. The attribute is prefixed with "metadata.", since metadata is nested in the Qdrant payload.

        Parameters

        • comparison: Comparison

          The comparison to visit.

        Returns {}

        A QdrantCondition.

        • Visits a structured query and returns a VisitStructuredQueryOutput. If the query has a filter, it is visited.

          Parameters

          • query: StructuredQuery

            The structured query to visit.

          Returns unknown

          An instance of VisitStructuredQueryOutput.

        Generated using TypeDoc