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。
请有关详细信息,请参阅贡献。
请查看我们有关如何报告安全漏洞的安全政策。
麻省理工学院许可证(麻省理工学院)。请参阅许可证文件以获取更多信息。