crembelski/iacommunication

This package allows you to communicate with OpenAI via a simple interface.

1.2.0 2024-09-23 17:04 UTC

This package is auto-updated.

Last update: 2025-06-23 18:44:57 UTC


README

This package allows you to communicate with OpenAI via a simple interface.

Installation

  1. Install the Package
    Run the following command in your project root to install the package:

    composer require crembelski/iacommunication
  2. Add the Service Provider
    In your config/app.php, add the following line to the providers array:

    crembelski\iacommunication\IACommunicationServiceProvider::class,
  3. Publish the Configuration
    Run the following command to publish the configuration file:

    php artisan vendor:publish --tag=config --provider="crembelski\iacommunication\IACommunicationServiceProvider"
  4. Configure Your OpenAI
    Add your OpenAI API Key and the service name in the .env file of your Laravel application. Example:

    IA_API_KEY=your_openai_api_key_here
    IA_SERVICE=OpenAI

    Replace your_openai_api_key_here with your actual API key from OpenAI.

Usage

Once installed and configured, you can use the completions method to send a message to OpenAI.

use crembelski\iacommunication\IACommunication;

$iaComm = new IACommunication();
$response = $iaComm->completions("Hello AI!");

License

This package is open-sourced software licensed under the MIT license.