elsayed85/ copilot-ask-database
使用您的Github Copilot来回答数据库问题
dev-master
2023-09-23 16:41 UTC
Requires
- php: ^8.1
- doctrine/dbal: ^3.6
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.14.0
- spatie/once: ^3.1
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-09-09 10:43:14 UTC
README
安装
您可以通过composer安装此包
composer require elsayed85/copilot-ask-database "dev-master"
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="copilot-ask-database-config"
这是已发布配置文件的内容
return [ 'github_token' => env('COPILOT_ASK_GITHUB_TOKEN'), /** * 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('COPILOT_ASK_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('COPILOT_ASK_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('COPILOT_ASK_MAXIMUM_TABLES', 15), 'copilot' => [ 'intent' => false, 'model' => 'copilot-chat', // Don't change this 'top_p' => 1, 'n' => 1, 'client_id' => '01ab8ac9400c4e429b23', // Don't change this 'user_agent' => 'GithubCopilot/3.99.99', // Don't change this ], ];
可选地,您可以使用以下命令发布视图
php artisan vendor:publish --tag="copilot-ask-database-views"
视图包含提示模板,您可以按需自定义。
设置Github Copilot
- 使用代码验证Github Copilot
php artisan copilot:github:auth
Please visit the following URL and login with your Github account:
https://github.com/login/device
Please enter the following code in the Github Device Activation page:
Your Github auth code is: 0EFA-6762
- 验证Github Copilot身份验证(在您使用您的Github账号登录并输入代码后)
php artisan copilot:github:verify
Your Github access token is: gho_6E8rRBDL.........................
Please add the following line to your .env file:
COPILOT_ASK_GITHUB_TOKEN=gho_6E8rRBDL.........................
- 将Github Copilot令牌添加到您的.env文件中
COPILOT_ASK_GITHUB_TOKEN=gho_6E8rRBDL.........................
用法
请求SQL查询
use Illuminate\Support\Facades\DB; $question = 'How many users are there?'; $query = DB::askCopilotForQuery($question);
答案
SELECT COUNT(*) FROM users
请求人类答案
use Illuminate\Support\Facades\DB; $question = 'How many users are there?'; $query = DB::askCopilot($question);
答案
There are 10 users.
测试
composer test
变更日志
请参阅变更日志以获取有关最近更改的更多信息。
贡献
请参阅贡献指南以获取详细信息。
安全漏洞
请参阅我们的安全策略了解如何报告安全漏洞。
鸣谢
许可协议
MIT许可协议(MIT)。请参阅许可文件以获取更多信息。