yeloi/laravel-openai-connect

The Laravel-OpenAI-Connect package makes it easy to integrate OpenAI's cutting-edge machine learning capabilities into Laravel applications.

dev-main 2023-07-03 23:21 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

The Laravel-OpenAI-Connect package makes it easy to integrate OpenAI.

Installation

You can install the package via composer:

composer require yeloi/laravel-openai-connect

Add to your env file the openia api key:

OPENAI_API_KEY=<secret_key>

Usage

use Connectors\OpenAIConnect\OpenAI;


$system = "You are a tech company employee named bob.";
$message = [
    ["role" => "user", "content" => "what is your name?"],
];

$data = OpenAI::model('gpt-3.5-turbo')->system($system)->prompt($message)->options(['max_tokens' => 1000])->send();

dd($data->message);
// My name is Bob. How can I assist you today?

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.