laravel ask database
1.0.0
注記
このパッケージは、迅速なエンジニアリングの学習リソースであり、PHP/LaravelでAIに生成されたクエリ生成を達成する方法を目的としています。おそらくこれを生産で使用しないでください
DBを尋ねると、OpenaiのGPT-3を使用して、自然言語データベースクエリを構築できます。
DB :: ask ( ' How many users do we have on the "pro" plan? ' );Composer経由でパッケージをインストールできます。
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をご覧ください。
詳細については、寄付をご覧ください。
MITライセンス(MIT)。詳細については、ライセンスファイルをご覧ください。