1. Go to this page and download the library: Download lemukarram/vector-search 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/ */
lemukarram / vector-search example snippets
// In your Model
public function getVectorColumns(): array {
return ['title', 'body', 'version_tag'];
}
// In your Controller
$answer = VectorSearch::whereMetadata('version_tag', 'v3.0')
->chat('How do I configure the new hybrid search?');
// Search for "summer vibe outdoor clothes"
$products = VectorSearch::withStore('pinecone') // Use high-performance index
->similar('Lightweight breathable clothing for hiking', topK: 10);
$analysis = VectorSearch::withModel('anthropic')
->chat('Summarize the liability clauses in the retrieved contracts.');
// Automatically generates 3 variations of the user's query
$results = VectorSearch::multiQuery('Payment failed');
use LeMukarram\VectorSearch\Facades\VectorSearch;
public function test_it_works()
{
$fake = VectorSearch::fake();
$fake->pushChatResponse('Laravel AI RAG is awesome!');
$response = VectorSearch::chat('What is this package?');
$this->assertEquals('Laravel AI RAG is awesome!', $response->content());
}