PHP code example of ogrre / laravel-chatgpt

1. Go to this page and download the library: Download ogrre/laravel-chatgpt library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ogrre / laravel-chatgpt example snippets


# config/app.php

'providers' => [
    // ...
    Ogrre\ChatGPT\ChatServiceProvider,
];

class User extends Authenticatable
{
    use HasFactory, HasChat;
    // ...
}

$optional_title = "Translate this word";
$optional_role = "You're a helpful assistant";

$user_chat = $user->newChat($optional_title, $optional_role);

$chat->gpt("say hello in French");

$user->chatgpt("say hello in French", $chat);
shell
php artisan vendor:publish --provider="Ogrre\ChatGPT\ChatServiceProvider"
shell
php artisan migrate