A class that translates or converts data into a format that can be used with Weaviate, a vector search engine. It extends the BaseTranslator class and provides specific implementation for Weaviate.

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

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

Type Parameters

Hierarchy (view full)

Constructors

Properties

VisitComparisonOutput: WeaviateComparisonResult
VisitOperationOutput: WeaviateOperationResult
allowedComparators: Comparator[] = ...
allowedOperators: Operator[] = ...

Methods

  • Formats the given function into a string representation. Throws an error if the function is not a known comparator or operator, or if it is not allowed.

    Parameters

    • func: any

      The function to format, which can be an Operator or Comparator.

    Returns string

    A string representation of the function.

  • 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: any

      The default filter to merge.

    • generatedFilter: any

      The generated filter to merge.

    • mergeType: string = "and"

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

    Returns any

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

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

    Parameters

    • query: StructuredQuery

      The structured query to visit.

    Returns unknown

    A WeaviateStructuredQueryResult.

""