laravel embeddings
1.0.0
Openai的文本嵌入量衡量文本字符串的相關性。使用此軟件包,您可以在PostgreSQL Vector數據庫中自動保存為您的雄辯模型保存嵌入。要使用AI請求中的OpenAI API端點中的嵌入。
您可以通過作曲家安裝軟件包:
composer require vormkracht10/laravel-embeddings您可以通過以下方式發布並運行遷移。
php artisan vendor:publish --tag= " laravel-embeddings-migrations "
php artisan migrate您可以使用以下方式發布配置文件
php artisan vendor:publish --tag= " laravel-embeddings-config "這是已發布的配置文件的內容:
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 ,
],
];填寫以下ENV變量
EMBEDDINGS_DRIVER = openai
OPENAI_API_KEY = // 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 ()));
}
}composer test 有關最近發生了變化的更多信息,請參見ChangElog。
請有關詳細信息,請參閱貢獻。
請查看我們有關如何報告安全漏洞的安全政策。
麻省理工學院許可證(麻省理工學院)。請參閱許可證文件以獲取更多信息。