Download the PHP package sabir/chatgpt without Composer
On this page you can find all versions of the php package sabir/chatgpt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sabir/chatgpt
More information about sabir/chatgpt
Files in sabir/chatgpt
Informations about the package chatgpt
To integrate the ChatGPT package with PHP and Laravel, please follow these steps:
Install the package: Install the package via Composer by running the following command in your project directory:
composer require sabir/chatgpt:dev-master Publish configuration file: Run the following command to publish the package's configuration file:
php artisan vendor:publish --tag=chatgpt-config --ansi --force This command will create a configuration file named chatgpt.php in your Laravel project's config directory.
Set API key and model: Open the .env file in your project's root folder and set the values for the following environment variables:
CHAT_API=YOUR_CHAT_API_KEY CHAT_MODEL=YOUR_CHAT_MODEL_ID Replace YOUR_CHAT_API_KEY with your OpenAI Chat API key and YOUR_CHAT_MODEL_ID with the model ID you want to use (e.g., "davinci", "curie", "babbage", or "ada").
Create an instance and call the chat method: In your Laravel code, you can now create an instance of the ChatGPT class and call the chat method to interact with the ChatGPT model. Here's an example:
use Sabir\ChatGPT\Facades\ChatGPT;
// ...
$s = new ChatGPT(); $response = $s->chat('hi, how are you?'); dd($response);
The chat method accepts three parameters:
message (required): The message or prompt to send to the ChatGPT model. type (optional): The API type to use for the chat. If left blank or set to "devinci", "curie", "babbage", or "ada", it will use the OpenAI models. You can extend this functionality to include other types if needed. options (optional): An array of additional options for the API request, such as temperature, max_tokens, top_p, etc. The chat method will return the response from the ChatGPT model.
Note: The provided code snippet is a simplified example. You may need to adjust it based on your project structure and requirements.
Ensure that you have properly configured the API key, model ID, and other settings according to your OpenAI account and desired behavior.
All versions of chatgpt with dependencies
guzzlehttp/guzzle Version ^7.0.1
illuminate/support Version ^8.77|^9.27
symfony/console Version ^5.0|^6.0