You can install the package via composer:
composer require elsayed85/copilot-ask-database "dev-master"
You can publish the config file with:
php artisan vendor:publish --tag="copilot-ask-database-config"
This is the contents of the published config file:
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
],
];
Optionally, you can publish the views using
php artisan vendor:publish --tag="copilot-ask-database-views"
Views Contains Prompts templates , you can customize it as you want.
- Authenticate with Github Copilot using code :
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
- Verify Github Copilot Authentication (After you login with your Github account and enter the code)
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.........................
- Add Github Copilot Token to your .env file
COPILOT_ASK_GITHUB_TOKEN=gho_6E8rRBDL.........................
use Illuminate\Support\Facades\DB;
$question = 'How many users are there?';
$query = DB::askCopilotForQuery($question);
Answer
SELECT COUNT(*) FROM users
use Illuminate\Support\Facades\DB;
$question = 'How many users are there?';
$query = DB::askCopilot($question);
Answer
There are 10 users.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.