• Add a SelfQueryAdvisor that follows LangChain's SelfQueryRetriever: Specifically, given any natural language query, the retriever uses a query-constructing LLM chain to write a structured query and then applies that structured query to its underlying VectorStore.
  • The prompt is taken from here
  • To be able to extract query attributes, a list of AttributeInfo objects must be specified. This instructs the LLM to identify attributes in the given user query then query the vector store using the metadata attributes.
  • Example:
        var selfQueryAdvisor = SelfQueryAdvisor(
          listOf(
                AttributeInfo(
                name = "firstName",
                type = "string",
                description = "A person's first name"),
          ),
          vectorStore,
          SearchRequest.defaults(),
          chatModel,
        );

        var response = chatClient.prompt()
                         .advisors(selfQueryAdvisor)
                         .user("Return a list of persons whose first name is Kylian").chatResponse();

Comment From: tzolov

Hi @florind and thank you for the contribution. Interesting stuff! Let me dig a bit through the LangChain docs