laravel ask database
1.0.0
笔记
该软件包旨在成为迅速工程的学习资源,以及如何使用PHP/Laravel实现AI生成的查询产生。您可能不应该在生产中使用它
询问数据库允许您使用OpenAI的GPT-3来构建自然语言数据库查询。
DB :: ask ( ' How many users do we have on the "pro" plan? ' );您可以通过作曲家安装软件包:
composer require beyondcode/laravel-ask-database您可以使用以下方式发布配置文件
php artisan vendor:publish --tag= " ask-database-config "这是已发布的配置文件的内容:
return [
/**
* The database connection name to use. Depending on your
* use case, you might want to limit the database user
* to have read-only access to the database.
*/
' connection ' => env ( ' ASK_DATABASE_DB_CONNECTION ' , ' mysql ' ),
/**
* Strict mode will throw an exception when the query
* would perform a write/alter operation on the database.
*
* If you want to allow write operations - or if you are using a read-only
* database user - you may disable strict mode.
*/
' strict_mode ' => env ( ' ASK_DATABASE_STRICT_MODE ' , true ),
/**
* The maximum number of tables to use before performing an additional
* table name lookup call to OpenAI.
* If you have a lot of database tables and columns, they might not fit
* into a single request to OpenAI. In that case, we will perform a
* lookup call to OpenAI to get the matching table names for the
* provided question.
*/
' max_tables_before_performing_lookup ' => env ( ' ASK_DATABASE_MAXIMUM_TABLES ' , 15 ),
];首先,您需要在.env文件中配置OpenAI API密钥:
OPENAI_API_KEY = sk-...然后,您可以使用DB::ask()方法询问数据库:
$ response = DB :: ask ( ' How many users are there? ' );composer test 有关最近发生了变化的更多信息,请参见ChangElog。
请有关详细信息,请参阅贡献。
麻省理工学院许可证(麻省理工学院)。请参阅许可证文件以获取更多信息。