Recommend this page to a friend! |
Laravel implementation of chatgpt, includes models listing and retrieving, completions prediction, chat completion from conversation, edits, images creation, image edit, image variations, audio translation and transcription.
You can install the package via composer:
composer require jumbaeric/laragpt
publish config file
php artisan vendor:publish
and select laragpt package to publish.
Add openai api key to your env variable
OPENAI_API_KEY=
All methods return Array
use Jumbaeric\Laragpt\Laragpt;
// Complete
// Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
$args = [
'prompt' => 'Brainstorm some ideas combining VR and fitness', //required
'model' => 'text-davinci-003', // required
];
Laragpt::complete($args);
// Chat
// Given a chat conversation, the model will return a chat completion response.
Laragpt::chat([
'model' => 'gpt-3.5-turbo', // required
'messages' => [ // required
[
"role" => "system",
"content" => "You are a helpful assistant."
],
[
"role" => "user",
"content" => "Who won the world series in 2020?"
],
[
"role" => "assistant",
"content" => "The Los Angeles Dodgers won the World Series in 2020."
],
[
"role" => "user",
"content" => "Where was it played?"
],
],
'temperature' => 1.0, // optional
'max_tokens' => 4000, // optional
'frequency_penalty' => 0, // optional
'presence_penalty' => 0, // optional
]);
// Audio
// trascribe: Transcribes audio into the input language.
// translate: Translates audio into into English.
$type = "transcript"; // string: Required : value can be transcript or translation
Laragpt::audio([
'model' => 'whisper-1', // required
'file' => "audio.mp3", // required
'prompt' => "", // optional
'response_format' => '', // optional
'temperature' => '', // optional
], $type);
// Edits
// Given a prompt and an instruction, the model will return an edited version of the prompt.
Laragpt::edits([
'model' => 'text-davinci-edit-001', // required
'input' => 'What day of the wek is it?',
'instruction' => 'Fix the spelling mistakes', // required
'n' => 1, // optional
'temperature' => 1, // optional
'top_p' => 1, // optional
]);
// Images
$createArr = [ // $type = create
'prompt' => 'A cute baby sea otter',
'size' => '1024x1024', // required
'n' => 1, // optional
] ;
$ceateEditArr = [ // $type = createEdit
'prompt' => 'A cute baby sea otter wearing a beret', // required
'image' => '@otter.png', //required
'mask' => '@mask.png',
'n' => 1,
'size' => '1024x1024',
];
$createVariationArr = [ // $type = variations
'image' => '@otter.png',
'n' => 2,
'size' => '1024x1024',
];
Laragpt::images($createArr, $type = 'create');
// Models
$model_id = null; // String : Optional : Lists all models when value is null, model set returns the model details
Laragpt::models($model_id);
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email jumbaeric@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
Classes of Eric Jumba | > | Laravel GPT | > | Download .zip .tar.gz | > | Support forum | > | Blog | > | Latest changes |
|
Groups | Applications | Files |
Groups |
PHP 5 | Classes using PHP 5 specific features | View top rated classes |
Graphics | Colors, images, charts and picture formats | View top rated classes |
Text processing | Manipulating and validating text data | View top rated classes |
Web services | Web data clipping, SOAP or XML-RPC clients and servers | View top rated classes |
Audio | Voice and music data generation and manipulation | View top rated classes |
Chat | Chating and instant messaging | View top rated classes |
Artificial intelligence | Automation of tasks using human-like intelligence | View top rated classes |
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.
Files |
File | Role | Description | ||
---|---|---|---|---|
.github (1 directory) | ||||
config (1 file) | ||||
src (3 files, 1 directory) | ||||
CHANGELOG.md | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
CONTRIBUTING.md | Data | Auxiliary data | ||
LICENSE.md | Lic. | License text | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
OpenAI (9 files) | ||||
Laragpt.php | Class | Class source | ||
LaragptFacade.php | Class | Class source | ||
LaragptServiceProvider.php | Class | Class source |
Files | / | src | / | OpenAI |
File | Role | Description |
---|---|---|
Audio.php | Class | Class source |
Chat.php | Class | Class source |
Completion.php | Class | Class source |
Edits.php | Class | Class source |
Embeddings.php | Class | Class source |
Files.php | Class | Class source |
Images.php | Class | Class source |
Models.php | Class | Class source |
OpenAI.php | Class | Class source |
Install with Composer - Download all files: laragpt.tar.gz laragpt.zip NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
|
Files |
File | Role | Description | ||
---|---|---|---|---|
.github (1 directory) | ||||
config (1 file) | ||||
src (3 files, 1 directory) | ||||
CHANGELOG.md | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
CONTRIBUTING.md | Data | Auxiliary data | ||
LICENSE.md | Lic. | License text | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
OpenAI (9 files) | ||||
Laragpt.php | Class | Class source | ||
LaragptFacade.php | Class | Class source | ||
LaragptServiceProvider.php | Class | Class source |
Files | / | src | / | OpenAI |
File | Role | Description |
---|---|---|
Audio.php | Class | Class source |
Chat.php | Class | Class source |
Completion.php | Class | Class source |
Edits.php | Class | Class source |
Embeddings.php | Class | Class source |
Files.php | Class | Class source |
Images.php | Class | Class source |
Models.php | Class | Class source |
OpenAI.php | Class | Class source |
Install with Composer - Download all files: laragpt.tar.gz laragpt.zip NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
|