Skip to content

Error while using Supabase self-query retriever when filters contain boolean value #7610

@ArmmGh

Description

@ArmmGh

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

const retriever = SelfQueryRetriever.fromLLM({
    llm: llm,
    vectorStore: vectorStore,
    documentContents: 'Detailed description of an apartment',
    attributeInfo: attributeInfo,
    structuredQueryTranslator: new SupabaseTranslator(),
    verbose: true,
  })

retriever.invoke("find apartments that have AC")

Error Message and Stack Trace (if applicable)

Error is Data type not supported

buildColumnName(attr: string, value: string | number, includeType = true) {
    let column = "";
    if (isString(value)) {
      column = `metadata->>${attr}`;
    } else if (isInt(value)) {
      column = `metadata->${attr}${includeType ? "::int" : ""}`;
    } else if (isFloat(value)) {
      column = `metadata->${attr}${includeType ? "::float" : ""}`;
    } else {
      throw new Error("Data type not supported");
    }

    return column;
  }

Description

  • I am trying to use langchain library to query my Supabase DB and return results by using selfQueryRetriever
  • I expect to get results based on query
  • I get error if filters generated by LLM contains boolean type

I created PR to solve the bug

System Info

Node Version: v20.18.0
Yarn Version: 1.22.22

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions