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.

Example

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

  • BaseTranslator<T>
    • WeaviateTranslator

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: "eq" | "ne" | "lt" | "gt" | "lte" | "gte" | "and" | "or" | "not"

      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: undefined | WeaviateFilter

      The default filter to merge.

    • generatedFilter: undefined | WeaviateFilter

      The generated filter to merge.

    • mergeType: string = "and"

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

    Returns undefined | WeaviateFilter

    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 {}

    A WeaviateStructuredQueryResult.

    Generated using TypeDoc