A specialized translator designed to work with Supabase, extending the BaseTranslator class. It translates structured queries into a format that can be understood by the Supabase database.

Example

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

const queryResult = await selfQueryRetriever.getRelevantDocuments(
"Which movies are directed by Greta Gerwig?",
);

Type Parameters

  • T extends VectorStore

Hierarchy

  • BaseTranslator<T>
    • SupabaseTranslator

Constructors

Properties

VisitComparisonOutput: any
VisitOperationOutput: any
allowedComparators: Comparator[] = ...
allowedOperators: Operator[] = ...

Methods

  • Builds a column name based on the attribute and value provided. The column name is used in filtering data in a Supabase database.

    Parameters

    • attr: string

      The attribute to be used in the column name.

    • value: string | number

      The value to be used in the column name.

    • includeType: boolean = true

      Whether to include the data type in the column name.

    Returns string

    The built column name.

  • Returns a function that applies the appropriate comparator operation on the attribute and value provided. The function returned is used to filter data in a Supabase database.

    Type Parameters

    • C extends Comparator

    Parameters

    • comparator: Comparator

      The comparator to be used in the operation.

    Returns ((attr, value) => any)

    A function that applies the comparator operation on the attribute and value provided.

      • (attr, value): any
      • Parameters

        • attr: string
        • value: ValueType[C]

        Returns any

  • Merges two filters into one. The merged filter can be used to filter data in a Supabase database.

    Parameters

    • defaultFilter: any

      The default filter to be merged.

    • generatedFilter: any

      The generated filter to be merged.

    • mergeType: string = "and"

      The type of merge to be performed. It can be 'and', 'or', or 'replace'.

    Returns any

    The merged filter.

  • Visits a comparison and returns a function that applies the comparison on a Supabase database. This is used in translating a structured query into a format that can be understood by Supabase.

    Parameters

    • comparison: Comparison

      The comparison to be visited.

    Returns any

    A function that applies the comparison on a Supabase database.

  • Visits a comparison and returns a string representation of it. This is used in translating a structured query into a format that can be understood by Supabase.

    Parameters

    • comparison: Comparison

      The comparison to be visited.

    Returns string

    A string representation of the comparison.

  • Visits an operation and returns a function that applies the operation on a Supabase database. This is used in translating a structured query into a format that can be understood by Supabase.

    Parameters

    • operation: Operation

      The operation to be visited.

    Returns any

    A function that applies the operation on a Supabase database.

  • Visits an operation and returns a string representation of it. This is used in translating a structured query into a format that can be understood by Supabase.

    Parameters

    • operation: Operation

      The operation to be visited.

    Returns string

    A string representation of the operation.

  • Visits a structured query and returns a function that applies the query on a Supabase database. This is used in translating a structured query into a format that can be understood by Supabase.

    Parameters

    • query: StructuredQuery

      The structured query to be visited.

    Returns {}

    A function that applies the query on a Supabase database.

    Generated using TypeDoc