From 0aefd9072c16cd4f401db7afc8b673ae3776e2ed Mon Sep 17 00:00:00 2001 From: Luciano Vergara Date: Sat, 13 May 2023 19:09:37 -0300 Subject: [PATCH] Fix PSR-4 conventions + Readme.MD fixes --- README.MD | 6 ++- composer.json | 48 +++++++++--------------- examples/ChatExample.php | 37 ------------------ examples/TextCompletions.php | 20 ---------- src/{LuGPT/LuGPT.php => Completions.php} | 6 +-- 5 files changed, 25 insertions(+), 92 deletions(-) delete mode 100644 examples/ChatExample.php delete mode 100644 examples/TextCompletions.php rename src/{LuGPT/LuGPT.php => Completions.php} (99%) diff --git a/README.MD b/README.MD index 69289cb..1dffb48 100644 --- a/README.MD +++ b/README.MD @@ -10,6 +10,8 @@ A PHP library for interacting with OpenAI's Completions and ChatCompletions API. - [Chat](#chat) - [Completion](#completion) - [Conversations](#conversations) +- [Todo](#todo) +- [Issues](#issues) - [Contributing](#contributing) - [License](#license) @@ -30,7 +32,7 @@ Initialize the `LuGPT` class with your OpenAI API key: ```php require_once 'vendor/autoload.php'; -use Sonichaos360\LuGPT\LuGPT; +use Sonichaos360\LuGPT\Completions; $apiKey = 'your_openai_api_key'; $model = 'gpt-3.5-turbo'; @@ -38,7 +40,7 @@ $maxTokens = '1500'; $temp = '1'; $conversationsPath = '../conversations'; //Optional, necessary only if you will manage conversation history using createConversation() -$luGPT = new LuGPT($apiKey, $model, $maxTokens, $temp, $conversationsPath); +$luGPT = new Completions($apiKey, $model, $maxTokens, $temp, $conversationsPath); ``` diff --git a/composer.json b/composer.json index 09544d2..04aedef 100644 --- a/composer.json +++ b/composer.json @@ -1,36 +1,24 @@ { - "name": "sonichaos360/lugpt", - "description": "A PHP library for interacting with OpenAI's Completions and ChatCompletions API.", - "keywords": ["openai", "gpt", "gpt-3.5-turbo", "chatbot", "ai"], - "license": "MIT", - "authors": [ + "name": "sonichaos360/lugpt", + "description": "A PHP library for interacting with OpenAI's Completions and ChatCompletions API.", + "keywords": ["openai", "gpt", "gpt-3.5-turbo", "chatbot", "ai"], + "license": "MIT", + "authors": [ { - "name": "Luciano Joan Vergara", - "email": "contacto@lucianovergara.com" + "name": "Luciano Joan Vergara", + "email": "contacto@lucianovergara.com" } - ], - "require": { - "php": ">=5.6", - "ext-curl": "*" - }, - "require-dev": { - "phpunit/phpunit": "^9.0" - }, - "autoload": { + ], + "type": "project", + "require": { + "php": ">=5.6" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "autoload": { "psr-4": { - "Sonichaos360\\LuGPT\\": "src/" + "Sonichaos360\\LuGPT\\": "src/" } - }, - "autoload-dev": { - "psr-4": { - "Sonichaos360\\LuGPT\\Tests\\": "tests/" - } - }, - "config": { - "platform": { - "php": "7.4" - } - }, - "minimum-stability": "stable" } - \ No newline at end of file +} \ No newline at end of file diff --git a/examples/ChatExample.php b/examples/ChatExample.php deleted file mode 100644 index 1b92215..0000000 --- a/examples/ChatExample.php +++ /dev/null @@ -1,37 +0,0 @@ -createConversation(); - -// Send messages within the conversation -$systemMessage = 'You are an assistant that translates between any languages.'; -$userMessage1 = 'Translate the following sentence from English to Spanish: "Hello, how are you?"'; -$response1 = $luGPT->Chat($systemMessage, $userMessage1, $conversationId); - -var_dump($response1); - - -$userMessage2 = 'Now, please translate this: "I am fine, thank you."'; -$response2 = $luGPT->Chat($systemMessage, $userMessage2, $conversationId); - -var_dump($response2); - -// echo $response2['choices'][0]['message']['content']." | "; \ No newline at end of file diff --git a/examples/TextCompletions.php b/examples/TextCompletions.php deleted file mode 100644 index 6b5ffee..0000000 --- a/examples/TextCompletions.php +++ /dev/null @@ -1,20 +0,0 @@ -Completion($prompt); - -var_dump($result); diff --git a/src/LuGPT/LuGPT.php b/src/Completions.php similarity index 99% rename from src/LuGPT/LuGPT.php rename to src/Completions.php index ff1d703..c467a85 100644 --- a/src/LuGPT/LuGPT.php +++ b/src/Completions.php @@ -6,7 +6,7 @@ * @package Sonichaos360/LuGPT * @author Luciano Joan Vergara * @license MIT License (https://opensource.org/licenses/MIT) - * @link https://github.com/Sonichaos360/OpenAi + * @link https://github.com/Sonichaos360/LuGPT * * MIT License * @@ -28,7 +28,7 @@ namespace Sonichaos360\LuGPT; -class LuGPT +class Completions { protected $apiKey; protected $model; @@ -38,7 +38,7 @@ class LuGPT protected $logPath; /** - * Constructor for LuGPT class + * Constructor for LuGpt class * * @param string $apiKey API key for OpenAI * @param string $model The model to use for OpenAI