Skip to content

Pass context/metadata to VectorStore search #154

Answered by ilvalerione
rcwsr asked this question in Q&A
Discussion options

You must be logged in to vote

A built-in solution could be to accept an additional configuration "filters" when vector store instance is created, like this:

class MyChatBot extends RAG
{
    public function __construct(protected array $pineconeFilters = [])
    {
    }

    ...
    
    protected function vectorStore(): VectorStoreInterface
    {
        return (new PineconeVectoreStore(
            key: 'PINECONE_API_KEY',
            indexUrl: 'PINECONE_INDEX_URL'
        ))->withFitlers($this->pineconeFilters);
    }

    public function withPineconeFilters(array $filters): self
    {
        $this->pineconeFilters = $filters;
        return $this;
    }
}

With this implementation you have two ways to pass the filt…

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@rcwsr
Comment options

@ilvalerione
Comment options

Answer selected by rcwsr
@rcwsr
Comment options

@ilvalerione
Comment options

@rcwsr
Comment options

@ilvalerione
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants