PHP code example of adrianmtanase / laravel-vector-store

1. Go to this page and download the library: Download adrianmtanase/laravel-vector-store 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/ */

    

adrianmtanase / laravel-vector-store example snippets


VectorStore::instance()
           ->namespace('general')
           ->upsert(
               PineconeUpsertRequest::build()
                   ->id('1')
                   ->values([
                       -0.002739503,
                       -0.01970483,
                       -0.011307885,
                       -0.011125952,
                       -0.023119587,
                       0.0016207852,
                       -0.003981551,
                       -0.029249357,
                       0.00983842,
                       -0.023721369
                   ])
                   ->metadata([
                       'text' => 'Vector store is lit!'
                   ])
           );

VectorStore::provider(VectorStoreProviderType::WEAVIATE)
           ->instance()
           ->namespace('general')
           ->query(
               WeaviateQueryRequest::build()
                   ->vector([
                       -0.002739503,
                       -0.01970483,
                       -0.011307885,
                       -0.011125952,
                       -0.023119587,
                       0.0016207852,
                       -0.003981551,
                       -0.029249357,
                       0.00983842,
                       -0.023721369
                   ])
                   ->properties(['text'])
                   ->withId()
                   ->withParameters(WeaviateQueryParameters::build()->group('type: closest, force: 1'))
           );

VectorStore::provider(VectorStoreProviderType::WEAVIATE)
           ->instance()
           ->namespace('general')
           ->rawQuery('
               {
                Get {
                  General(nearVector: {
                    vector: [
                        -0.002739503,
                       -0.01970483,
                       -0.011307885,
                       -0.011125952,
                       -0.023119587,
                       0.0016207852,
                       -0.003981551,
                       -0.029249357,
                       0.00983842,
                       -0.023721369
                    ]  
                  }) {
                    text
                  }
                }
            }
           ');

VectorStore::provider(VectorStoreProviderType::WEAVIATE)
           ->instance()
           ->client()
           ->batchDelete('general') 
bash
php artisan vendor:publish