claraleigh / gpt-helper-for-laravel
A Laravel package that generates templates using ChatGPT
Installs: 2 132
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.0.1
- illuminate/filesystem: *
- illuminate/support: ^9.0|^10.0
- illuminate/translation: ^9.0|^10.0
- nikic/php-parser: ^4.15
- openai-php/laravel: ^0.4.0
- phpdocumentor/reflection-docblock: ^5.3
- symfony/console: ^6.2
Requires (Dev)
- phpunit/phpunit: ^9.3.10
README
Please Note: This is a very early concept project. At this stage it is very limited.
Project Goal
The goal of this project is to create open source versions of AI tools for use in PHP applications. At this stage it can predict files that you either give it, or when using the make:xxx command namespace.
Installation
You can install the package via composer:
composer require ClaraLeigh/gpt-helper-for-laravel
The package will automatically register itself.
Configuration
You can publish the config file with:
php artisan vendor:publish --provider="GptHelperForLaravel\GptServiceProvider" --tag="config"
This will create a gpt-helper.php config file in your config directory. You can set your ChatGPT API key, model, GPT settings, and Domain-Driven Design starting directory in the configuration file.
Publish Language Files
You can publish the language files with:
php artisan vendor:publish --provider="GptHelperForLaravel\GptServiceProvider" --tag="lang"
This will create a resources/lang/vendor/gpt-helper directory, where you can store your language files.
Usage
Try to predict the contents of a file, with context and a prompt
php artisan gpt:predict {source : The file we wish to predict} {--prompt= : Add additonal text to give GPT context} {--files= : A comma separated list of classnames/files to use as context} {--summarizedFiles= : Same as files, but use a summary of instead to reduce the query}
Auto generate files during creation
For example, in your custom command:
php artisan make:model Books --prompt="This is a books model, with authors, genre's, publication dates and a relevant library"
This will create a Books model in your app directory, and the contents of the file will be modified using ChatGPT.
Available Templates
The following templates are available:
- Model
- Controller
- ... more coming soon
Available Settings
The following GPT settings are available:
- model
- max_tokens
- temperature
- n
- stop
Testing
composer test
License
I am considering changing this license, open a issue if you have any suggestions.
The MIT License (MIT). Please see License File for more information.