PHP code example of semhoun / neuron-paradedb
1. Go to this page and download the library: Download semhoun/neuron-paradedb library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
semhoun / neuron-paradedb example snippets
use Semhoun\NeuronParadeDB\VectorStore\ParadeDBVectorStore;
$pdo = new PDO(
getenv('PARADEDB_DSN'),
getenv('PARADEDB_USER'),
getenv('PARADEDB_PASSWORD'),
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION],
);
$store = new ParadeDBVectorStore(
pdo: $pdo,
dimensions: 1536,
tableName: 'rag_documents',
topK: 4,
rrfK: 60,
collectionId: null,
);
$store->setupDatabase();
use NeuronAI\Chat\Messages\UserMessage;
use NeuronAI\RAG\Document;
use NeuronAI\RAG\Embeddings\OpenAIEmbeddingsProvider;
use NeuronAI\RAG\VectorStore\SearchRequest;
use Semhoun\NeuronParadeDB\Retrieval\HybridRetrieval;
$embeddings = new OpenAIEmbeddingsProvider(
key: getenv('OPENAI_API_KEY'),
model: 'text-embedding-3-small',
dimensions: 1536,
);
$text = 'ZXQ-991 is a compact industrial sensor.';
$document = (new Document($text))
->setId('sensor-1')
->setSourceType('manual')
->setSourceName('sensor-guide')
->setEmbedding($embeddings->embedText($text));
$store->addDocument($document);
$retrieval = new HybridRetrieval($store, $embeddings);
$documents = $retrieval->retrieve(new UserMessage('ZXQ-991 sensor'));
// Vector-only search; topK overrides the default for this call.
$documents = $store->search(new SearchRequest(
embedding: $embeddings->embedText('compact sensor'),
topK: 8,
));
$agent->setVectorStore($store);
$agent->setEmbeddingsProvider($embeddings);
$agent->setRetrieval(new HybridRetrieval($store, $embeddings));
$agent->addDocuments([new Document('Maintenance guide for the ZXQ-991 sensor.')]);
$teamStore = $store->forCollection('team-a');
$otherTeam = $store->forCollection('team-b');
$uncollected = $store->forCollection(null);
$query = 'ZXQ-991 sensor';
$documents = $teamStore->hybridSearch($query, $embeddings->embedText($query));
use NeuronAI\RAG\Schema\DocumentField;
use NeuronAI\RAG\Schema\DocumentSchema;
use NeuronAI\RAG\VectorStore\Filter\Filter;
$typedStore = new ParadeDBVectorStore(
pdo: $pdo,
dimensions: 1536,
collectionId: 'team-a',
schema: DocumentSchema::of(
DocumentField::string('tenant')->hanOrEqual('year', 2025);
$documents = $typedStore->hybridSearch($query, $embeddings->embedText($query), $filters, 4);
$retrieval = new HybridRetrieval($typedStore, $embeddings, filters: $filters);
$documents = $retrieval->retrieve(new UserMessage($query), Filter::containsAny('tags', ['sensor']));
$typedStore->delete(Filter::where('sourceType', 'manual')->where('sourceName', 'sensor-guide'));
ParadeDBVectorStore::upgradeToV11(pdo: $pdo, dimensions: 1536, tableName: 'rag_documents');
sql
GRANT USAGE ON SCHEMA public TO neuron_app;
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE public.rag_documents TO neuron_app;