laravel ask database
1.0.0
บันทึก
แพ็คเกจนี้มีไว้เพื่อเป็นแหล่งเรียนรู้สำหรับวิศวกรรมที่รวดเร็วและวิธีการสร้างแบบสอบถาม Ai-Generated ด้วย PHP/Laravel คุณไม่ควรใช้สิ่งนี้ในการผลิต
ถาม DB ช่วยให้คุณใช้ GPT-3 ของ OpenAI เพื่อสร้างแบบสอบถามฐานข้อมูลภาษาธรรมชาติ
DB :: ask ( ' How many users do we have on the "pro" plan? ' );คุณสามารถติดตั้งแพ็คเกจผ่านนักแต่งเพลง:
composer require beyondcode/laravel-ask-databaseคุณสามารถเผยแพร่ไฟล์ config ด้วย:
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 ),
]; ก่อนอื่นคุณต้องกำหนดค่าคีย์ OpenAI API ของคุณในไฟล์ .env ของคุณ:
OPENAI_API_KEY = sk-... จากนั้นคุณสามารถใช้เมธอด DB::ask() เพื่อถามฐานข้อมูล:
$ response = DB :: ask ( ' How many users are there? ' );composer test โปรดดู Changelog สำหรับข้อมูลเพิ่มเติมเกี่ยวกับสิ่งที่เปลี่ยนแปลงไปเมื่อเร็ว ๆ นี้
โปรดดูรายละเอียดที่มีส่วนร่วม
ใบอนุญาต MIT (MIT) โปรดดูไฟล์ใบอนุญาตสำหรับข้อมูลเพิ่มเติม