PHPVector adapter for the Neuron AI framework. Implements
NeuronAI\RAG\VectorStore\VectorStoreInterface on top of ezimuel/phpvector.
- PHP ^8.2
- ezimuel/phpvector ^0.3.0
- Neuron AI ^3.0
composer require neuron-core/php-vectorInside a Neuron RAG class:
class MyRAG extends RAG
{
...
protected function vectorStore(): VectorStoreInterface
{
return new PHPVector(
path: '/var/data/mydb',
topK: 5,
);
}
}Use it as a standalone component:
use NeuronAI\PHPVector\PHPVector;
use PHPVector\VectorDatabase;
// Persistent database: pass a path to enable on-disk storage.
$store = new PHPVector(
path: '/var/data/mydb',
topK: 5,
);By default, this adapter auto-saves after every mutation (addDocument, addDocuments,
deleteBy), batched to a single save() per call, so persistence "just works".
deleteBy() removes documents by Neuron's sourceType / sourceName, which this adapter
stores as PHPVector metadata:
$store->deleteBy('pdf'); // all documents from sourceType "pdf"
$store->deleteBy('pdf', 'manual.pdf'); // only that exact source