Notiz
Dieses Paket soll eine Lernressource für ein schnelles Engineering und die Erreichung der Erzeugung von A-generierten Abfragen mit PHP/Laravel sein. Sie sollten dies wahrscheinlich nicht in der Produktion verwenden
Mit Fragen Sie DB können Sie die GPT-3 von OpenAI verwenden, um Abfragen für natürliche Sprachdatenbank zu erstellen.
DB :: ask ( ' How many users do we have on the "pro" plan? ' );Sie können das Paket über Komponist installieren:
composer require beyondcode/laravel-ask-databaseSie können die Konfigurationsdatei mit:
php artisan vendor:publish --tag= " ask-database-config "Dies ist der Inhalt der veröffentlichten Konfigurationsdatei:
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 ),
]; Zunächst müssen Sie Ihren OpenAI -API -Schlüssel in Ihrer .env -Datei konfigurieren:
OPENAI_API_KEY = sk-... Anschließend können Sie die DB::ask() -Methode verwenden, um die Datenbank zu fragen:
$ response = DB :: ask ( ' How many users are there? ' );composer test Weitere Informationen zu dem, was sich in letzter Zeit geändert hat, finden Sie in ChangeLog.
Weitere Informationen finden Sie unter Beitrag.
Die MIT -Lizenz (MIT). Weitere Informationen finden Sie unter Lizenzdatei.