PHP code example of vormkracht10 / laravel-embeddings
1. Go to this page and download the library: Download vormkracht10/laravel-embeddings 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/ */
vormkracht10 / laravel-embeddings example snippets
return [
'enabled' => env('EMBEDDINGS_ENABLED', true),
'driver' => env('EMBEDDINGS_DRIVER', 'null'), // 'null' / 'openai'
'queue' => true,
'database' => [
'connection' => env('EMBEDDINGS_DATABASE_CONNECTION', 'pgsql'),
'table' => env('EMBEDDINGS_DB_TABLE', 'embeddings'),
],
'openai' => [
'key' => env('OPENAI_API_KEY'),
'model' => env('OPENAI_EMBEDDING_MODEL', 'text-embedding-ada-002')
],
/*
|--------------------------------------------------------------------------
| Chunk Sizes
|--------------------------------------------------------------------------
|
| These options allow you to control the maximum chunk size when you are
| mass importing data into the embed engine. This allows you to fine
| tune each of these chunk sizes based on the power of the servers.
|
*/
'chunk' => [
'embeddable' => 500,
'unembeddable' => 500,
],
];
// Add the Embeddable trait to your Model(s).
class MyModel {
use Embeddable {
\Laravel\Scout\Searchable::usesSoftDelete insteadof \Vormkracht10\Embedding\Embeddable;
}
}
// You can override the embeddable content
class MyModel {
// ...
public function toEmbeddableString()
{
return strip_tags(implode(', ', $this->toArray()));
}
}