From 87814d74f2d9b6f6e8d0d04a48e1f8199398eafb Mon Sep 17 00:00:00 2001 From: aB0t Date: Tue, 4 Jul 2023 06:26:00 +0200 Subject: [PATCH] update 2023-07-04 06:26:00 --- README.md | 2 + .../README.md | 69 ++++++++++ .../code.php | 122 ++++++++++++++++++ .../code.power | 91 +++++++++++++ .../settings.json | 38 ++++++ .../README.md | 54 ++++++++ .../code.php | 78 +++++++++++ .../code.power | 49 +++++++ .../settings.json | 29 +++++ super-powers.json | 22 ++++ 10 files changed, 554 insertions(+) create mode 100644 src/ac5c7679-dd6e-4817-8e48-489e521122f1/README.md create mode 100644 src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.php create mode 100644 src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.power create mode 100644 src/ac5c7679-dd6e-4817-8e48-489e521122f1/settings.json create mode 100644 src/f722bb8b-d377-4425-b1e4-2fe1734a3664/README.md create mode 100644 src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.php create mode 100644 src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.power create mode 100644 src/f722bb8b-d377-4425-b1e4-2fe1734a3664/settings.json diff --git a/README.md b/README.md index 12949a0..1d8b6e3 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ This repository contains an index (see below) of all the approved powers within - **Namespace**: [VDM\Joomla\GetBible](#vdm-joomla-getbible) - **abstract class Factory** | [Details](src/11892cfa-374e-4e3f-b0bc-531871c822d9) | [Code](src/11892cfa-374e-4e3f-b0bc-531871c822d9/code.php) | [Settings](src/11892cfa-374e-4e3f-b0bc-531871c822d9/settings.json) | Super__11892cfa_374e_4e3f_b0bc_531871c822d9__Power + - **abstract class Openai** | [Details](src/f722bb8b-d377-4425-b1e4-2fe1734a3664) | [Code](src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.php) | [Settings](src/f722bb8b-d377-4425-b1e4-2fe1734a3664/settings.json) | Super__f722bb8b_d377_4425_b1e4_2fe1734a3664__Power - **final class DailyScripture** | [Details](src/90f2ee7a-c041-4316-ad54-af4f97fa3003) | [Code](src/90f2ee7a-c041-4316-ad54-af4f97fa3003/code.php) | [Settings](src/90f2ee7a-c041-4316-ad54-af4f97fa3003/settings.json) | Super__90f2ee7a_c041_4316_ad54_af4f97fa3003__Power - **final class Search** | [Details](src/8336e3c4-f11b-41bc-a2b1-976f99442a84) | [Code](src/8336e3c4-f11b-41bc-a2b1-976f99442a84/code.php) | [Settings](src/8336e3c4-f11b-41bc-a2b1-976f99442a84/settings.json) | Super__8336e3c4_f11b_41bc_a2b1_976f99442a84__Power - **final class Watcher** | [Details](src/f815fb33-f721-48a5-a84e-53f1986e8881) | [Code](src/f815fb33-f721-48a5-a84e-53f1986e8881/code.php) | [Settings](src/f815fb33-f721-48a5-a84e-53f1986e8881/settings.json) | Super__f815fb33_f721_48a5_a84e_53f1986e8881__Power @@ -55,6 +56,7 @@ This repository contains an index (see below) of all the approved powers within - **class App** | [Details](src/56465044-94ed-4e00-b6db-160c67163df8) | [Code](src/56465044-94ed-4e00-b6db-160c67163df8/code.php) | [Settings](src/56465044-94ed-4e00-b6db-160c67163df8/settings.json) | Super__56465044_94ed_4e00_b6db_160c67163df8__Power - **class Database** | [Details](src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38) | [Code](src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/code.php) | [Settings](src/51bb0397-fa7c-4f7a-a4c5-1f95fdacad38/settings.json) | Super__51bb0397_fa7c_4f7a_a4c5_1f95fdacad38__Power - **class Model** | [Details](src/116eb429-bc51-4d14-b9aa-7145c86a29d1) | [Code](src/116eb429-bc51-4d14-b9aa-7145c86a29d1/code.php) | [Settings](src/116eb429-bc51-4d14-b9aa-7145c86a29d1/settings.json) | Super__116eb429_bc51_4d14_b9aa_7145c86a29d1__Power + - **class Openai** | [Details](src/ac5c7679-dd6e-4817-8e48-489e521122f1) | [Code](src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.php) | [Settings](src/ac5c7679-dd6e-4817-8e48-489e521122f1/settings.json) | Super__ac5c7679_dd6e_4817_8e48_489e521122f1__Power - **class Utilities** | [Details](src/b89d74ef-c71c-4a58-8455-5dbdfe94027a) | [Code](src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.php) | [Settings](src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/settings.json) | Super__b89d74ef_c71c_4a58_8455_5dbdfe94027a__Power - **Namespace**: [VDM\Joomla\GetBible\Utilities](#vdm-joomla-getbible-utilities) diff --git a/src/ac5c7679-dd6e-4817-8e48-489e521122f1/README.md b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/README.md new file mode 100644 index 0000000..9aed782 --- /dev/null +++ b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/README.md @@ -0,0 +1,69 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Openai (Details) +> namespace: **VDM\Joomla\GetBible\Service** +```uml +@startuml +class Openai #Gold { + + register(Container $container) : void + + getChat(Container $container) : Chat + + getCompletions(Container $container) : Completions + + getModels(Container $container) : Models + + getModerate(Container $container) : Moderate +} + +note right of Openai::register + Registers the service provider with a DI container. + + since: 3.2.0 + return: void +end note + +note right of Openai::getChat + Get the Chat class + + since: 3.2.0 + return: Chat +end note + +note right of Openai::getCompletions + Get the Completions class + + since: 3.2.0 + return: Completions +end note + +note right of Openai::getModels + Get the Models class + + since: 3.2.0 + return: Models +end note + +note right of Openai::getModerate + Get the Moderate class + + since: 3.2.0 + return: Moderate +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.php b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.php new file mode 100644 index 0000000..b77cfb1 --- /dev/null +++ b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.php @@ -0,0 +1,122 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Openai\Chat; +use VDM\Joomla\Openai\Completions; +use VDM\Joomla\Openai\Models; +use VDM\Joomla\Openai\Moderate; + + +/** + * The Openai Api Service + * + * @since 3.2.0 + */ +class Openai implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + + $container->alias(Chat::class, 'Openai.Chat') + ->share('Openai.Chat', [$this, 'getChat'], true); + + $container->alias(Completions::class, 'Openai.Completions') + ->share('Openai.Completions', [$this, 'getCompletions'], true); + + $container->alias(Models::class, 'Openai.Models') + ->share('Openai.Models', [$this, 'getModels'], true); + + $container->alias(Moderate::class, 'Openai.Moderate') + ->share('Openai.Moderate', [$this, 'getModerate'], true); + } + + /** + * Get the Chat class + * + * @param Container $container The DI container. + * + * @return Chat + * @since 3.2.0 + */ + public function getChat(Container $container): Chat + { + return new Chat( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Completions class + * + * @param Container $container The DI container. + * + * @return Completions + * @since 3.2.0 + */ + public function getCompletions(Container $container): Completions + { + return new Completions( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Models class + * + * @param Container $container The DI container. + * + * @return Models + * @since 3.2.0 + */ + public function getModels(Container $container): Models + { + return new Models( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Moderate class + * + * @param Container $container The DI container. + * + * @return Moderate + * @since 3.2.0 + */ + public function getModerate(Container $container): Moderate + { + return new Moderate( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } +} + diff --git a/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.power b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.power new file mode 100644 index 0000000..d4514ef --- /dev/null +++ b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/code.power @@ -0,0 +1,91 @@ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + + $container->alias(Chat::class, 'Openai.Chat') + ->share('Openai.Chat', [$this, 'getChat'], true); + + $container->alias(Completions::class, 'Openai.Completions') + ->share('Openai.Completions', [$this, 'getCompletions'], true); + + $container->alias(Models::class, 'Openai.Models') + ->share('Openai.Models', [$this, 'getModels'], true); + + $container->alias(Moderate::class, 'Openai.Moderate') + ->share('Openai.Moderate', [$this, 'getModerate'], true); + } + + /** + * Get the Chat class + * + * @param Container $container The DI container. + * + * @return Chat + * @since 3.2.0 + */ + public function getChat(Container $container): Chat + { + return new Chat( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Completions class + * + * @param Container $container The DI container. + * + * @return Completions + * @since 3.2.0 + */ + public function getCompletions(Container $container): Completions + { + return new Completions( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Models class + * + * @param Container $container The DI container. + * + * @return Models + * @since 3.2.0 + */ + public function getModels(Container $container): Models + { + return new Models( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Moderate class + * + * @param Container $container The DI container. + * + * @return Moderate + * @since 3.2.0 + */ + public function getModerate(Container $container): Moderate + { + return new Moderate( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } \ No newline at end of file diff --git a/src/ac5c7679-dd6e-4817-8e48-489e521122f1/settings.json b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/settings.json new file mode 100644 index 0000000..0c0aa37 --- /dev/null +++ b/src/ac5c7679-dd6e-4817-8e48-489e521122f1/settings.json @@ -0,0 +1,38 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "ac5c7679-dd6e-4817-8e48-489e521122f1", + "implements": [ + "-1" + ], + "load_selection": null, + "name": "Openai", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Service.Openai", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "c54c92da-2dd7-4136-81c9-1785f2fa0af5", + "as": "default" + }, + "use_selection1": { + "use": "796cca70-2577-4f8f-9a05-ac37db1f2f02", + "as": "default" + }, + "use_selection2": { + "use": "08abd2df-1406-4939-a1a6-94d2fce3f043", + "as": "default" + }, + "use_selection3": { + "use": "34f2c249-64a7-4229-9592-77e58f6e994f", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Service.Openai", + "description": "The Openai Api Service\r\n\r\n@since 3.2.0", + "implements_custom": "ServiceProviderInterface", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git GetBible \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\DI\\Container;\r\nuse Joomla\\DI\\ServiceProviderInterface;", + "composer": "" +} \ No newline at end of file diff --git a/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/README.md b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/README.md new file mode 100644 index 0000000..0396c67 --- /dev/null +++ b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/README.md @@ -0,0 +1,54 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# abstract class Openai (Details) +> namespace: **VDM\Joomla\GetBible** +```uml +@startuml +abstract Openai #Orange { + # static $container + + {static} _(string $key) : Mixed + + {static} getContainer() : Container + # {static} createContainer() : Container +} + +note right of Openai::_ + Get any class from the package container + + since: 3.2.0 + return: Mixed +end note + +note right of Openai::getContainer + Get the global package container + + since: 3.2.0 + return: Container +end note + +note right of Openai::createContainer + Create a container object + + since: 3.2.0 + return: Container +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.php b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.php new file mode 100644 index 0000000..184d643 --- /dev/null +++ b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.php @@ -0,0 +1,78 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use Joomla\DI\Container; +use VDM\Joomla\GetBible\Service\Openai as Api; +use VDM\Joomla\Openai\Service\Utilities; +use VDM\Joomla\Interfaces\FactoryInterface; + + +/** + * Openai Factory + * + * @since 3.2.0 + */ +abstract class Openai implements FactoryInterface +{ + /** + * Global Package Container + * + * @var Container + * @since 3.2.0 + **/ + protected static $container = null; + + /** + * Get any class from the package container + * + * @param string $key The container class key + * + * @return Mixed + * @since 3.2.0 + */ + public static function _($key) + { + return self::getContainer()->get($key); + } + + /** + * Get the global package container + * + * @return Container + * @since 3.2.0 + */ + public static function getContainer(): Container + { + if (!self::$container) + { + self::$container = self::createContainer(); + } + + return self::$container; + } + + /** + * Create a container object + * + * @return Container + * @since 3.2.0 + */ + protected static function createContainer(): Container + { + return (new Container()) + ->registerServiceProvider(new Utilities()) + ->registerServiceProvider(new Api()); + } +} + diff --git a/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.power b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.power new file mode 100644 index 0000000..0f717fc --- /dev/null +++ b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/code.power @@ -0,0 +1,49 @@ + /** + * Global Package Container + * + * @var Container + * @since 3.2.0 + **/ + protected static $container = null; + + /** + * Get any class from the package container + * + * @param string $key The container class key + * + * @return Mixed + * @since 3.2.0 + */ + public static function _($key) + { + return self::getContainer()->get($key); + } + + /** + * Get the global package container + * + * @return Container + * @since 3.2.0 + */ + public static function getContainer(): Container + { + if (!self::$container) + { + self::$container = self::createContainer(); + } + + return self::$container; + } + + /** + * Create a container object + * + * @return Container + * @since 3.2.0 + */ + protected static function createContainer(): Container + { + return (new Container()) + ->registerServiceProvider(new Utilities()) + ->registerServiceProvider(new Api()); + } \ No newline at end of file diff --git a/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/settings.json b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/settings.json new file mode 100644 index 0000000..0832178 --- /dev/null +++ b/src/f722bb8b-d377-4425-b1e4-2fe1734a3664/settings.json @@ -0,0 +1,29 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "f722bb8b-d377-4425-b1e4-2fe1734a3664", + "implements": [ + "caf33c5d-858c-4f9a-894f-ab302ec5445a" + ], + "load_selection": null, + "name": "Openai", + "power_version": "1.0.0", + "system_name": "GetBible.Openai", + "type": "abstract class", + "use_selection": { + "use_selection0": { + "use": "ac5c7679-dd6e-4817-8e48-489e521122f1", + "as": "Api" + }, + "use_selection1": { + "use": "07858e1f-5698-4227-8941-03dc93557938", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Openai", + "description": "Openai Factory\r\n\r\n@since 3.2.0", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git GetBible \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\DI\\Container;", + "composer": "" +} \ No newline at end of file diff --git a/super-powers.json b/super-powers.json index be88797..3391d46 100644 --- a/super-powers.json +++ b/super-powers.json @@ -131,6 +131,17 @@ "spk": "Super__a752e4b2_9b5e_4188_8d33_3799c46d5119__Power", "guid": "a752e4b2-9b5e-4188-8d33-3799c46d5119" }, + "ac5c7679-dd6e-4817-8e48-489e521122f1": { + "name": "Openai", + "type": "class", + "namespace": "VDM\\Joomla\\GetBible\\Service", + "code": "src\/ac5c7679-dd6e-4817-8e48-489e521122f1\/code.php", + "power": "src\/ac5c7679-dd6e-4817-8e48-489e521122f1\/code.power", + "settings": "src\/ac5c7679-dd6e-4817-8e48-489e521122f1\/settings.json", + "path": "src\/ac5c7679-dd6e-4817-8e48-489e521122f1", + "spk": "Super__ac5c7679_dd6e_4817_8e48_489e521122f1__Power", + "guid": "ac5c7679-dd6e-4817-8e48-489e521122f1" + }, "afa508bf-78f8-4616-97cc-f2809584c086": { "name": "Verses", "type": "final class", @@ -230,6 +241,17 @@ "spk": "Super__d7a5f0c6_de60_4d31_b3e4_5d668a8f7d2e__Power", "guid": "d7a5f0c6-de60-4d31-b3e4-5d668a8f7d2e" }, + "f722bb8b-d377-4425-b1e4-2fe1734a3664": { + "name": "Openai", + "type": "abstract class", + "namespace": "VDM\\Joomla\\GetBible", + "code": "src\/f722bb8b-d377-4425-b1e4-2fe1734a3664\/code.php", + "power": "src\/f722bb8b-d377-4425-b1e4-2fe1734a3664\/code.power", + "settings": "src\/f722bb8b-d377-4425-b1e4-2fe1734a3664\/settings.json", + "path": "src\/f722bb8b-d377-4425-b1e4-2fe1734a3664", + "spk": "Super__f722bb8b_d377_4425_b1e4_2fe1734a3664__Power", + "guid": "f722bb8b-d377-4425-b1e4-2fe1734a3664" + }, "f815fb33-f721-48a5-a84e-53f1986e8881": { "name": "Watcher", "type": "final class",