[Python] how to pass additional query filters to a SelfQueryRetriever(langchain)

Discussão em 'Python' iniciado por Stack, Março 5, 2025.

  1. Stack

    Stack Membro Participativo

    We are implementing a SelfQueryRetriever using OpenSearch as vectorstore, in general it works fine generating the metadata filters from the user query but we need some way to append other filters to the query, and I cannot find how to do that in the documentation, the use case is to make some things such as:

    • The UI will have some filters that product owners want exposed as tradditional filters instead of filters to be extracted from user query.
    • There are roles and the space of possible search results for a query is restricted by the data available only for users of that role.

    A possible solution is to add those to the metadata fields of the SelfQueryRetriever and append a "system" component to the user query and let the self query retriever create the filters, but to me it does't sound so clean and intuitive.

    How can additional filters be added to the query?

    Continue reading...

Compartilhe esta Página