We currently offer first-party support for the following vector store:
Memory Store
This is an implementation of a volatile vector store that keeps your embeddings into the machine memory for the current session. It's useful when you don't need to store the generated embeddings for long term use, but just during current interaction sessions (or for local use).
use NeuronAI\RAG\RAG;
use NeuronAI\RAG\VectorStore\MemoryVectoreStore;
use NeuronAI\RAG\VectorStore\VectorStoreInterface;
class MyChatBot extends RAG
{
...
protected function vectorStore(): VectorStoreInterface
{
return new MemoryVectoreStore();
}
}
Pinecone
Pinecone makes it easy to provide long-term memory for high-performance AI applications. It’s a managed, cloud-native vector database with a simple API and no infrastructure hassles. Pinecone serves fresh, filtered query results with low latency at the scale of billions of vectors.
Here is how to use Pinecone in your agent:
use NeuronAI\RAG\RAG;
use NeuronAI\RAG\VectorStore\PineconeVectoreStore;
use NeuronAI\RAG\VectorStore\VectorStoreInterface;
class MyChatBot extends RAG
{
...
protected function vectorStore(): VectorStoreInterface
{
return new PineconeVectoreStore(
key: 'PINECONE_API_KEY',
indexUrl: 'PINECONE_INDEX_URL'
);
}
}
Or you can set the vector store at runtime:
$agent = MyChatBot::make()
->setVectorStore(
new PineconeVectoreStore(
key: 'PINECONE_API_KEY',
indexUrl: 'PINECONE_INDEX_URL'
);
)->run(
new UserMessage('Hello!')
);
Elasticsearch
Elasticsearch's open source vector database offers an efficient way to create, store, and search vector embeddings. To use Elasticseach as a vector store in your agents implementation you have to import the official client:
composer require elasticsearch/elasticsearch
Here is how to create a RAG that uses Elasticsearch:
use NeuronAI\RAG\RAG;
use NeuronAI\RAG\VectorStore\ElasticsearchVectoreStore;
use NeuronAI\RAG\VectorStore\VectorStoreInterface;
class MyChatBot extends RAG
{
public function __construct(protected Client $elasticClient) {}
...
protected function vectorStore(): VectorStoreInterface
{
return new ElasticsearchVectoreStore(
client: $this->elasticClient,
index: 'neuron-ai'
);
}
}
Passing the elasticsearch client instance to the agent:
Once you have the official client installed in your app you can return an instance of the TypesenseVectorStore in your RAG agent:
use NeuronAI\RAG\RAG;
use NeuronAI\RAG\VectorStore\ElasticsearchVectoreStore;
use NeuronAI\RAG\VectorStore\TypesenseVectorStore;
class MyChatBot extends RAG
{
public function __construct(protected Client $typesenseClient) {}
...
protected function vectorStore(): VectorStoreInterface
{
return new TypesenseVectorStore(
client: $this->typesenseClient,
collection: 'neuron-ai',
vectorDimension: 1024
);
}
}
Passing the instance of the typesense client to the Agent:
Once you have the collection URL you can attach the Qdrant instance to your agent.
use NeuronAI\RAG\RAG;
use NeuronAI\RAG\VectorStore\Qdrant;
use NeuronAI\RAG\VectorStore\VectorStoreInterface;
class MyChatBot extends RAG
{
...
protected function vectorStore(): VectorStoreInterface
{
return new Qdrant(
collectionUrl: 'http://localhost:6333/collections/neuron-ai/',
key: 'QDRANT_API_KEY'
);
}
}
Implement a new Vector Store
If you want to create a new provider you have to implement the VectorStoreInterface interface:
namespace NeuronAI\RAG\VectorStore;
use NeuronAI\RAG\Document;
interface VectorStoreInterface
{
public function addDocument(Document $document): void;
/**
* @param array<Document> $documents
*/
public function addDocuments(array $documents): void;
/**
* Return docs most similar to the embedding.
*
* @param float[] $embedding
* @return array<Document>
*/
public function similaritySearch(array $embedding, int $k = 4): iterable;
}
There are two different methods for adding single document or a collection because many database provides different APIs for these use cases. If the database you want to communicate doesn't handle these requests differently you can implement addDocument() as a placeholder.
This is the basic template for a new AI provider implementation.
use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;
use NeuronAI\RAG\Document;
use NeuronAI\RAG\VectorStore\VectorStoreInterface;
class MyVectorStore implements VectorStoreInterface
{
protected Client $client;
public function __construct(
string $key,
protected string $index,
) {
$this->client = new Client([
'base_uri' => 'https://api.vector-store.com',
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => "Bearer {$key}",
]
]);
}
public function addDocument(Document $document): void
{
$this->addDocuments([$document]);
}
public function addDocuments(array $documents): void
{
$this->client->post("indexes/{$this->index}", [
RequestOptions::JSON => \array_map(function (Document $document) {
return [
'vector' => $document->embedding,
];
}, $documents)
]);
}
public function similaritySearch(array $embedding, int $k = 4): iterable
{
// perform similarity search and return an array of Document objects
}
}
After creating your own implementation you can use it in the agent:
namespace App\AI\Agents;
use NeuronAI\Agent;
use NeuronAI\RAG\VectorStore\VectorStoreInterface;
class MyAgent extends Agent
{
protected function vectorStore(): VectorStoreInterface
{
return new MyVectorStore (
key: 'VECTORSTORE_API_KEY',
index: 'neuron-ai',
);
}
}
Take a look at the Pinecone official documentation to better understand the configuration parameters:
is an open source alternative to the options above. To use Typesense in your agents you need to install its official client:
is an open source vector database with strong similarity search capabilities. To use Qdrant in your agents you have to provide a collectionUrl. This means you will first need to create a collection on Qdrant with its attributes like: name, similarity search algorithm, vector dimension, etc.
We strongly recommend you to submit new vector store implementations via PR on the official repository or using other support channels. The new implementation can receives an important boost in its advancement by the community.