alnutile / laravel-chatgpt
Some base client work to talk to the api
Installs: 2 849
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 3
Open Issues: 1
Requires
- php: ^8.1
- alnutile/fixtures: ^0.0
- guzzlehttp/guzzle: ^7.5
- http-interop/http-factory-guzzle: ^1.2
- illuminate/contracts: ^9.0|^10.0
- spatie/data-transfer-object: ^3.9
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
README
Going to build some basic Driver like clients to talk to different AI service but like with Laravel Storage it will treat them all the same.
- ChatGPT for text
- Jasper when ChatGPT is down :(
- Dall-2
- OpenAI Moderator
- Midjourney - when it gets an api
Installation
You can install the package via composer:
composer require alnutile/laravel-chatgpt
You can then set your .env:
AI_CLIENT=sk-key
AI_MOCK=false
If you set AI_MOCK to true it will just return some fixture data so if you are working in your UI for example it will just show that data.
Usage
Here is an example of
- Call Moderation to see if the text is ok
- TextClientFacade to do a text search with adding a prefix to the request
- SearchResults Event to just let the system know and react to it like make a local copy of the data
- ModerationFailed Event so you can react to that
$moderationOk = ModerationClientFacade::checkOk(request()->search); if ($moderationOk == false) { ModerationFailed::dispatch(request()); } else { $results = TextClientFacade::addPrefix('can you give me tl;dr terms of service for')->text($search); SearchResults::dispatch($results); }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.