Skip to content

neuron-core/php-vector

Repository files navigation

Neuron AI Adapter for php-vector

PHPVector adapter for the Neuron AI framework. Implements NeuronAI\RAG\VectorStore\VectorStoreInterface on top of ezimuel/phpvector.

Dependencies

Installation

composer require neuron-core/php-vector

Usage

Inside 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,
);

Persistence

By default, this adapter auto-saves after every mutation (addDocument, addDocuments, deleteBy), batched to a single save() per call, so persistence "just works".

Deletion

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