first commit
This commit is contained in:
commit
a66ce651f0
232
README.md
Normal file
232
README.md
Normal file
@ -0,0 +1,232 @@
|
|||||||
|
```
|
||||||
|
███████╗██╗ ██╗██████╗ ███████╗██████╗
|
||||||
|
██╔════╝██║ ██║██╔══██╗██╔════╝██╔══██╗
|
||||||
|
███████╗██║ ██║██████╔╝█████╗ ██████╔╝
|
||||||
|
╚════██║██║ ██║██╔═══╝ ██╔══╝ ██╔══██╗
|
||||||
|
███████║╚██████╔╝██║ ███████╗██║ ██║
|
||||||
|
╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝███████╗
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗╚════██║
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║███████║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝╚══════╝
|
||||||
|
```
|
||||||
|
|
||||||
|
### What is JCB Super Powers?
|
||||||
|
The Joomla Component Builder (JCB) Super Power features are designed to enhance JCB's functionality and streamline the development process. These Super Powers enable developers to efficiently manage and share their custom powers across multiple JCB instances through repositories hosted on [https://git.vdm.dev/[username]/[repository-name]](https://git.vdm.dev). JCB Super Powers are managed using a combination of layers, events, tasks, methods, switches, and algorithms, which work together to provide powerful customization and extensibility options. More details on JCB Super Powers can be found in the [Super Powers Documentation](https://git.vdm.dev/joomla/super-powers/wiki).
|
||||||
|
|
||||||
|
In summary, JCB Super Powers offer a flexible and efficient way to manage and share functionalities between JCB instances. By utilizing a sophisticated system of layers, events, tasks, methods, switches, and algorithms, developers can seamlessly integrate JCB core powers and their custom powers. For more information on how to work with JCB Super Powers, refer to the [Super Powers User Guide](https://git.vdm.dev/joomla/super-powers/wiki).
|
||||||
|
|
||||||
|
### What can I find here?
|
||||||
|
This repository contains an index (see below) of all the approved powers within the JCB GUI. During the compilation of a component, these powers are automatically added to the repository, ensuring a well-organized and accessible collection of functionalities.
|
||||||
|
|
||||||
|
# Index of powers
|
||||||
|
|
||||||
|
- **Namespace**: [VDM\Joomla\Openai](#vdm-joomla-openai)
|
||||||
|
|
||||||
|
- **abstract class Factory** | [Details](src/d78bee89-6f7e-42b6-917e-17f05b238490) | [Code](src/d78bee89-6f7e-42b6-917e-17f05b238490/code.php) | [Settings](src/d78bee89-6f7e-42b6-917e-17f05b238490/settings.json) | Super__d78bee89_6f7e_42b6_917e_17f05b238490__Power
|
||||||
|
- **class Audio** | [Details](src/d76b2e22-c8dd-44b1-86b5-822768b317a3) | [Code](src/d76b2e22-c8dd-44b1-86b5-822768b317a3/code.php) | [Settings](src/d76b2e22-c8dd-44b1-86b5-822768b317a3/settings.json) | Super__d76b2e22_c8dd_44b1_86b5_822768b317a3__Power
|
||||||
|
- **class Chat** | [Details](src/c54c92da-2dd7-4136-81c9-1785f2fa0af5) | [Code](src/c54c92da-2dd7-4136-81c9-1785f2fa0af5/code.php) | [Settings](src/c54c92da-2dd7-4136-81c9-1785f2fa0af5/settings.json) | Super__c54c92da_2dd7_4136_81c9_1785f2fa0af5__Power
|
||||||
|
- **class Completions** | [Details](src/796cca70-2577-4f8f-9a05-ac37db1f2f02) | [Code](src/796cca70-2577-4f8f-9a05-ac37db1f2f02/code.php) | [Settings](src/796cca70-2577-4f8f-9a05-ac37db1f2f02/settings.json) | Super__796cca70_2577_4f8f_9a05_ac37db1f2f02__Power
|
||||||
|
- **class Edits** | [Details](src/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8) | [Code](src/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8/code.php) | [Settings](src/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8/settings.json) | Super__98e59bdf_81a2_41ef_a3a6_6a88a7cc53c8__Power
|
||||||
|
- **class Embeddings** | [Details](src/df141f03-393f-4fa3-a568-8b65f7358b02) | [Code](src/df141f03-393f-4fa3-a568-8b65f7358b02/code.php) | [Settings](src/df141f03-393f-4fa3-a568-8b65f7358b02/settings.json) | Super__df141f03_393f_4fa3_a568_8b65f7358b02__Power
|
||||||
|
- **class Files** | [Details](src/65dd022b-8f3a-46be-8930-0cae74b9834b) | [Code](src/65dd022b-8f3a-46be-8930-0cae74b9834b/code.php) | [Settings](src/65dd022b-8f3a-46be-8930-0cae74b9834b/settings.json) | Super__65dd022b_8f3a_46be_8930_0cae74b9834b__Power
|
||||||
|
- **class FineTunes** | [Details](src/0e61da13-6429-426d-a6f9-f5723cd3b7b1) | [Code](src/0e61da13-6429-426d-a6f9-f5723cd3b7b1/code.php) | [Settings](src/0e61da13-6429-426d-a6f9-f5723cd3b7b1/settings.json) | Super__0e61da13_6429_426d_a6f9_f5723cd3b7b1__Power
|
||||||
|
- **class Images** | [Details](src/bb8973c1-261f-4b55-8f9b-9ee98843fced) | [Code](src/bb8973c1-261f-4b55-8f9b-9ee98843fced/code.php) | [Settings](src/bb8973c1-261f-4b55-8f9b-9ee98843fced/settings.json) | Super__bb8973c1_261f_4b55_8f9b_9ee98843fced__Power
|
||||||
|
- **class Models** | [Details](src/08abd2df-1406-4939-a1a6-94d2fce3f043) | [Code](src/08abd2df-1406-4939-a1a6-94d2fce3f043/code.php) | [Settings](src/08abd2df-1406-4939-a1a6-94d2fce3f043/settings.json) | Super__08abd2df_1406_4939_a1a6_94d2fce3f043__Power
|
||||||
|
- **class Moderate** | [Details](src/34f2c249-64a7-4229-9592-77e58f6e994f) | [Code](src/34f2c249-64a7-4229-9592-77e58f6e994f/code.php) | [Settings](src/34f2c249-64a7-4229-9592-77e58f6e994f/settings.json) | Super__34f2c249_64a7_4229_9592_77e58f6e994f__Power
|
||||||
|
- **Namespace**: [VDM\Joomla\Openai\Abstraction](#vdm-joomla-openai-abstraction)
|
||||||
|
|
||||||
|
- **abstract class Api** | [Details](src/585de711-2784-4f89-90bf-94a8a63366f1) | [Code](src/585de711-2784-4f89-90bf-94a8a63366f1/code.php) | [Settings](src/585de711-2784-4f89-90bf-94a8a63366f1/settings.json) | Super__585de711_2784_4f89_90bf_94a8a63366f1__Power
|
||||||
|
- **Namespace**: [VDM\Joomla\Openai\Service](#vdm-joomla-openai-service)
|
||||||
|
|
||||||
|
- **class Api** | [Details](src/ccf3141a-929d-4466-b122-9ace2eea8d70) | [Code](src/ccf3141a-929d-4466-b122-9ace2eea8d70/code.php) | [Settings](src/ccf3141a-929d-4466-b122-9ace2eea8d70/settings.json) | Super__ccf3141a_929d_4466_b122_9ace2eea8d70__Power
|
||||||
|
- **class Utilities** | [Details](src/07858e1f-5698-4227-8941-03dc93557938) | [Code](src/07858e1f-5698-4227-8941-03dc93557938/code.php) | [Settings](src/07858e1f-5698-4227-8941-03dc93557938/settings.json) | Super__07858e1f_5698_4227_8941_03dc93557938__Power
|
||||||
|
- **Namespace**: [VDM\Joomla\Openai\Utilities](#vdm-joomla-openai-utilities)
|
||||||
|
|
||||||
|
- **final class Http** | [Details](src/4c58b254-aea5-40aa-b54d-9586a1690451) | [Code](src/4c58b254-aea5-40aa-b54d-9586a1690451/code.php) | [Settings](src/4c58b254-aea5-40aa-b54d-9586a1690451/settings.json) | Super__4c58b254_aea5_40aa_b54d_9586a1690451__Power
|
||||||
|
- **final class Response** | [Details](src/c464393e-7606-406e-8463-a86774590966) | [Code](src/c464393e-7606-406e-8463-a86774590966/code.php) | [Settings](src/c464393e-7606-406e-8463-a86774590966/settings.json) | Super__c464393e_7606_406e_8463_a86774590966__Power
|
||||||
|
- **final class Uri** | [Details](src/13ef84f4-25b0-43dd-a9f6-0722abf220c1) | [Code](src/13ef84f4-25b0-43dd-a9f6-0722abf220c1/code.php) | [Settings](src/13ef84f4-25b0-43dd-a9f6-0722abf220c1/settings.json) | Super__13ef84f4_25b0_43dd_a9f6_0722abf220c1__Power
|
||||||
|
|
||||||
|
# Class Diagrams
|
||||||
|
|
||||||
|
## VDM Joomla Openai
|
||||||
|
> namespace VDM\Joomla\Openai
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Openai #DarkCyan {
|
||||||
|
|
||||||
|
|
||||||
|
abstract Factory #Orange {
|
||||||
|
# static $container
|
||||||
|
+ {static} _() : Mixed
|
||||||
|
+ {static} getContainer() : Container
|
||||||
|
# {static} createContainer() : Container
|
||||||
|
}
|
||||||
|
|
||||||
|
class Audio #Gold {
|
||||||
|
+ transcribe() : ?object
|
||||||
|
+ translation() : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
class Chat #Gold {
|
||||||
|
+ create() : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
class Completions #Gold {
|
||||||
|
+ create() : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
class Edits #Gold {
|
||||||
|
+ create() : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
class Embeddings #Gold {
|
||||||
|
+ create() : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
class Files #Gold {
|
||||||
|
+ list() : ?object
|
||||||
|
+ upload() : ?object
|
||||||
|
+ info() : ?object
|
||||||
|
+ content() : mixed
|
||||||
|
+ delete() : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
class FineTunes #Gold {
|
||||||
|
+ list() : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
class Images #Gold {
|
||||||
|
+ generate() : ?object
|
||||||
|
+ edit() : ?object
|
||||||
|
+ variation() : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
class Models #Gold {
|
||||||
|
+ list() : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
class Moderate #Gold {
|
||||||
|
+ text() : ?object
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
## VDM Joomla Openai Abstraction
|
||||||
|
> namespace VDM\Joomla\Openai\Abstraction
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Openai\Abstraction #Olive {
|
||||||
|
|
||||||
|
|
||||||
|
abstract Api #Orange {
|
||||||
|
# Http $http
|
||||||
|
# Uri $uri
|
||||||
|
# Response $response
|
||||||
|
+ __construct()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
## VDM Joomla Openai Service
|
||||||
|
> namespace VDM\Joomla\Openai\Service
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Openai\Service #Olive {
|
||||||
|
|
||||||
|
|
||||||
|
class Api #Gold {
|
||||||
|
+ register() : void
|
||||||
|
+ getAudio() : Audio
|
||||||
|
+ getChat() : Chat
|
||||||
|
+ getCompletions() : Completions
|
||||||
|
+ getEdits() : Edits
|
||||||
|
+ getEmbeddings() : Embeddings
|
||||||
|
+ getFiles() : Files
|
||||||
|
+ getFineTunes() : FineTunes
|
||||||
|
+ getImages() : Images
|
||||||
|
+ getModels() : Models
|
||||||
|
+ getModerate() : Moderate
|
||||||
|
}
|
||||||
|
|
||||||
|
class Utilities #Gold {
|
||||||
|
+ register() : void
|
||||||
|
+ getUri() : Uri
|
||||||
|
+ getResponse() : Response
|
||||||
|
+ getHttp() : Http
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
## VDM Joomla Openai Utilities
|
||||||
|
> namespace VDM\Joomla\Openai\Utilities
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Openai\Utilities #Olive {
|
||||||
|
|
||||||
|
|
||||||
|
class Http << (F,LightGreen) >> #Green {
|
||||||
|
+ __construct()
|
||||||
|
}
|
||||||
|
|
||||||
|
class Response << (F,LightGreen) >> #Green {
|
||||||
|
+ get() : mixed
|
||||||
|
+ get_() : mixed
|
||||||
|
# body() : mixed
|
||||||
|
# error() : string
|
||||||
|
}
|
||||||
|
|
||||||
|
class Uri << (F,LightGreen) >> #Green {
|
||||||
|
- string $version
|
||||||
|
- string $url
|
||||||
|
+ __construct()
|
||||||
|
+ get() : JoomlaUri
|
||||||
|
+ api() : string
|
||||||
|
- setUrl() : void
|
||||||
|
- setVersion() : void
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||||
|
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||||
|
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||||
|
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||||
|
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||||
|
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||||
|
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||||
|
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||||
|
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||||
|
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||||
|
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||||
|
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||||
|
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
|
||||||
|
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
|
||||||
|
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
|
||||||
|
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
|
||||||
|
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
61
src/07858e1f-5698-4227-8941-03dc93557938/README.md
Normal file
61
src/07858e1f-5698-4227-8941-03dc93557938/README.md
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class Utilities (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai\Service**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Utilities #Gold {
|
||||||
|
+ register(Container $container) : void
|
||||||
|
+ getUri(Container $container) : Uri
|
||||||
|
+ getResponse(Container $container) : Response
|
||||||
|
+ getHttp(Container $container) : Http
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Utilities::register
|
||||||
|
Registers the service provider with a DI container.
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Utilities::getUri
|
||||||
|
Get the Uri class
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Uri
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Utilities::getResponse
|
||||||
|
Get the Response class
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Response
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Utilities::getHttp
|
||||||
|
Get the Http class
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Http
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
92
src/07858e1f-5698-4227-8941-03dc93557938/code.php
Normal file
92
src/07858e1f-5698-4227-8941-03dc93557938/code.php
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai\Service;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\DI\Container;
|
||||||
|
use Joomla\DI\ServiceProviderInterface;
|
||||||
|
use VDM\Joomla\Openai\Utilities\Uri;
|
||||||
|
use VDM\Joomla\Openai\Utilities\Response;
|
||||||
|
use VDM\Joomla\Openai\Utilities\Http;
|
||||||
|
use VDM\Joomla\Utilities\Component\Helper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Utilities Service
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class Utilities 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(Uri::class, 'Openai.Utilities.Uri')
|
||||||
|
->share('Openai.Utilities.Uri', [$this, 'getUri'], true);
|
||||||
|
|
||||||
|
$container->alias(Response::class, 'Openai.Utilities.Response')
|
||||||
|
->share('Openai.Utilities.Response', [$this, 'getResponse'], true);
|
||||||
|
|
||||||
|
$container->alias(Http::class, 'Openai.Utilities.Http')
|
||||||
|
->share('Openai.Utilities.Http', [$this, 'getHttp'], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Uri class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Uri
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getUri(Container $container): Uri
|
||||||
|
{
|
||||||
|
return new Uri();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Response class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getResponse(Container $container): Response
|
||||||
|
{
|
||||||
|
return new Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Http class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Http
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getHttp(Container $container): Http
|
||||||
|
{
|
||||||
|
return new Http(
|
||||||
|
Helper::getParams()->get('openai_token')
|
||||||
|
Helper::getParams()->get('openai_org_token')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
61
src/07858e1f-5698-4227-8941-03dc93557938/code.power
Normal file
61
src/07858e1f-5698-4227-8941-03dc93557938/code.power
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* 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(Uri::class, 'Openai.Utilities.Uri')
|
||||||
|
->share('Openai.Utilities.Uri', [$this, 'getUri'], true);
|
||||||
|
|
||||||
|
$container->alias(Response::class, 'Openai.Utilities.Response')
|
||||||
|
->share('Openai.Utilities.Response', [$this, 'getResponse'], true);
|
||||||
|
|
||||||
|
$container->alias(Http::class, 'Openai.Utilities.Http')
|
||||||
|
->share('Openai.Utilities.Http', [$this, 'getHttp'], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Uri class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Uri
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getUri(Container $container): Uri
|
||||||
|
{
|
||||||
|
return new Uri();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Response class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getResponse(Container $container): Response
|
||||||
|
{
|
||||||
|
return new Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Http class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Http
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getHttp(Container $container): Http
|
||||||
|
{
|
||||||
|
return new Http(
|
||||||
|
Helper::getParams()->get('openai_token')
|
||||||
|
Helper::getParams()->get('openai_org_token')
|
||||||
|
);
|
||||||
|
}
|
38
src/07858e1f-5698-4227-8941-03dc93557938/settings.json
Normal file
38
src/07858e1f-5698-4227-8941-03dc93557938/settings.json
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"add_head": "1",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "0",
|
||||||
|
"guid": "07858e1f-5698-4227-8941-03dc93557938",
|
||||||
|
"implements": [
|
||||||
|
"-1"
|
||||||
|
],
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Utilities",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Service.Utilities",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": {
|
||||||
|
"use_selection0": {
|
||||||
|
"use": "13ef84f4-25b0-43dd-a9f6-0722abf220c1",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection1": {
|
||||||
|
"use": "c464393e-7606-406e-8463-a86774590966",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection2": {
|
||||||
|
"use": "4c58b254-aea5-40aa-b54d-9586a1690451",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection3": {
|
||||||
|
"use": "640b5352-fb09-425f-a26e-cd44eda03f15",
|
||||||
|
"as": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Service.Utilities",
|
||||||
|
"description": "The Openai Utilities Service\r\n\r\n@since 3.2.0",
|
||||||
|
"implements_custom": "ServiceProviderInterface",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": ""
|
||||||
|
}
|
37
src/08abd2df-1406-4939-a1a6-94d2fce3f043/README.md
Normal file
37
src/08abd2df-1406-4939-a1a6-94d2fce3f043/README.md
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class Models (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Models #Gold {
|
||||||
|
+ list() : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Models::list
|
||||||
|
List the available models from OpenAI API.
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
44
src/08abd2df-1406-4939-a1a6-94d2fce3f043/code.php
Normal file
44
src/08abd2df-1406-4939-a1a6-94d2fce3f043/code.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Openai\Abstraction\Api;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Models
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class Models extends Api
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* List the available models from OpenAI API.
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function list(): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/models";
|
||||||
|
|
||||||
|
// Send the get request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->get(
|
||||||
|
$this->uri->get($path)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
18
src/08abd2df-1406-4939-a1a6-94d2fce3f043/code.power
Normal file
18
src/08abd2df-1406-4939-a1a6-94d2fce3f043/code.power
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* List the available models from OpenAI API.
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function list(): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/models";
|
||||||
|
|
||||||
|
// Send the get request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->get(
|
||||||
|
$this->uri->get($path)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
18
src/08abd2df-1406-4939-a1a6-94d2fce3f043/settings.json
Normal file
18
src/08abd2df-1406-4939-a1a6-94d2fce3f043/settings.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "585de711-2784-4f89-90bf-94a8a63366f1",
|
||||||
|
"guid": "08abd2df-1406-4939-a1a6-94d2fce3f043",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Models",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Models",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": null,
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Models",
|
||||||
|
"description": "The Openai Models\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
38
src/0e61da13-6429-426d-a6f9-f5723cd3b7b1/README.md
Normal file
38
src/0e61da13-6429-426d-a6f9-f5723cd3b7b1/README.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class FineTunes (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class FineTunes #Gold {
|
||||||
|
+ list() : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of FineTunes::list
|
||||||
|
List your organization's fine-tuning jobs
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/fine-tunes/list
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
50
src/0e61da13-6429-426d-a6f9-f5723cd3b7b1/code.php
Normal file
50
src/0e61da13-6429-426d-a6f9-f5723cd3b7b1/code.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Openai\Abstraction\Api;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Fine Tunes
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class FineTunes extends Api
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* List your organization's fine-tuning jobs
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/fine-tunes/list
|
||||||
|
*
|
||||||
|
* @return object|null The response from the OpenAI API, or null if an error occurred.
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function list(): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/fine-tunes";
|
||||||
|
|
||||||
|
// Prepare the URI.
|
||||||
|
$uri = $this->uri->get($path);
|
||||||
|
|
||||||
|
// Send the GET request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->get($uri)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* More to follow: https://platform.openai.com/docs/api-reference/fine-tunes
|
||||||
|
**/
|
||||||
|
}
|
||||||
|
|
24
src/0e61da13-6429-426d-a6f9-f5723cd3b7b1/code.power
Normal file
24
src/0e61da13-6429-426d-a6f9-f5723cd3b7b1/code.power
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* List your organization's fine-tuning jobs
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/fine-tunes/list
|
||||||
|
*
|
||||||
|
* @return object|null The response from the OpenAI API, or null if an error occurred.
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function list(): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/fine-tunes";
|
||||||
|
|
||||||
|
// Prepare the URI.
|
||||||
|
$uri = $this->uri->get($path);
|
||||||
|
|
||||||
|
// Send the GET request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->get($uri)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* More to follow: https://platform.openai.com/docs/api-reference/fine-tunes
|
||||||
|
**/
|
18
src/0e61da13-6429-426d-a6f9-f5723cd3b7b1/settings.json
Normal file
18
src/0e61da13-6429-426d-a6f9-f5723cd3b7b1/settings.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "585de711-2784-4f89-90bf-94a8a63366f1",
|
||||||
|
"guid": "0e61da13-6429-426d-a6f9-f5723cd3b7b1",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "FineTunes",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.FineTunes",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": null,
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\FineTunes",
|
||||||
|
"description": "The Openai Fine Tunes\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
74
src/13ef84f4-25b0-43dd-a9f6-0722abf220c1/README.md
Normal file
74
src/13ef84f4-25b0-43dd-a9f6-0722abf220c1/README.md
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# final class Uri (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai\Utilities**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Uri << (F,LightGreen) >> #Green {
|
||||||
|
- string $version
|
||||||
|
- string $url
|
||||||
|
+ __construct(string $url = 'https://api.openai.com', string $version = 'v1')
|
||||||
|
+ get(string $path) : JoomlaUri
|
||||||
|
+ api() : string
|
||||||
|
- setUrl(string $url) : void
|
||||||
|
- setVersion(string $version) : void
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Uri::__construct
|
||||||
|
Constructor
|
||||||
|
example: https://api.openai.com
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Uri::get
|
||||||
|
Method to build and return a full request URL for the request. This method will
|
||||||
|
add appropriate pagination details if necessary and also prepend the API url
|
||||||
|
to have a complete URL for the request.
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: JoomlaUri
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Uri::api
|
||||||
|
Get the full API URL
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: string
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Uri::setUrl
|
||||||
|
Set the URL of the API
|
||||||
|
example: https://api.openai.com
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Uri::setVersion
|
||||||
|
Set the version of the API
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
115
src/13ef84f4-25b0-43dd-a9f6-0722abf220c1/code.php
Normal file
115
src/13ef84f4-25b0-43dd-a9f6-0722abf220c1/code.php
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai\Utilities;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\Uri\Uri as JoomlaUri;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Uri
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
final class Uri
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The api version
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
private string $version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The api URL
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
private string $url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param string $url URL to the openai system
|
||||||
|
* example: https://api.openai.com
|
||||||
|
* @param string $version Version to the openai system
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function __construct(
|
||||||
|
string $url = 'https://api.openai.com',
|
||||||
|
string $version = 'v1')
|
||||||
|
{
|
||||||
|
// set the API details
|
||||||
|
$this->setUrl($url);
|
||||||
|
$this->setVersion($version);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to build and return a full request URL for the request. This method will
|
||||||
|
* add appropriate pagination details if necessary and also prepend the API url
|
||||||
|
* to have a complete URL for the request.
|
||||||
|
*
|
||||||
|
* @param string $path URL to inflect
|
||||||
|
*
|
||||||
|
* @return JoomlaUri
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function get(string $path): JoomlaUri
|
||||||
|
{
|
||||||
|
// Get a new Uri object focusing the api url and given path.
|
||||||
|
$uri = new JoomlaUri($this->api() . $path);
|
||||||
|
|
||||||
|
return $uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the full API URL
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function api(): string
|
||||||
|
{
|
||||||
|
return $this->url . '/' . $this->version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the URL of the API
|
||||||
|
*
|
||||||
|
* @param string $url URL to your openai system
|
||||||
|
* example: https://api.openai.com
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
private function setUrl(string $url)
|
||||||
|
{
|
||||||
|
return $this->url = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the version of the API
|
||||||
|
*
|
||||||
|
* @param string $version version to your openai API
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
private function setVersion($version)
|
||||||
|
{
|
||||||
|
return $this->version = $version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
89
src/13ef84f4-25b0-43dd-a9f6-0722abf220c1/code.power
Normal file
89
src/13ef84f4-25b0-43dd-a9f6-0722abf220c1/code.power
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/**
|
||||||
|
* The api version
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
private string $version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The api URL
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
private string $url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param string $url URL to the openai system
|
||||||
|
* example: https://api.openai.com
|
||||||
|
* @param string $version Version to the openai system
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function __construct(
|
||||||
|
string $url = 'https://api.openai.com',
|
||||||
|
string $version = 'v1')
|
||||||
|
{
|
||||||
|
// set the API details
|
||||||
|
$this->setUrl($url);
|
||||||
|
$this->setVersion($version);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to build and return a full request URL for the request. This method will
|
||||||
|
* add appropriate pagination details if necessary and also prepend the API url
|
||||||
|
* to have a complete URL for the request.
|
||||||
|
*
|
||||||
|
* @param string $path URL to inflect
|
||||||
|
*
|
||||||
|
* @return JoomlaUri
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function get(string $path): JoomlaUri
|
||||||
|
{
|
||||||
|
// Get a new Uri object focusing the api url and given path.
|
||||||
|
$uri = new JoomlaUri($this->api() . $path);
|
||||||
|
|
||||||
|
return $uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the full API URL
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function api(): string
|
||||||
|
{
|
||||||
|
return $this->url . '/' . $this->version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the URL of the API
|
||||||
|
*
|
||||||
|
* @param string $url URL to your openai system
|
||||||
|
* example: https://api.openai.com
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
private function setUrl(string $url)
|
||||||
|
{
|
||||||
|
return $this->url = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the version of the API
|
||||||
|
*
|
||||||
|
* @param string $version version to your openai API
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
private function setVersion($version)
|
||||||
|
{
|
||||||
|
return $this->version = $version;
|
||||||
|
}
|
18
src/13ef84f4-25b0-43dd-a9f6-0722abf220c1/settings.json
Normal file
18
src/13ef84f4-25b0-43dd-a9f6-0722abf220c1/settings.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"add_head": "1",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "0",
|
||||||
|
"guid": "13ef84f4-25b0-43dd-a9f6-0722abf220c1",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Uri",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Utilities.Uri",
|
||||||
|
"type": "final class",
|
||||||
|
"use_selection": null,
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Utilities.Uri",
|
||||||
|
"description": "The Openai Uri\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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\\Uri\\Uri as JoomlaUri;",
|
||||||
|
"composer": ""
|
||||||
|
}
|
38
src/34f2c249-64a7-4229-9592-77e58f6e994f/README.md
Normal file
38
src/34f2c249-64a7-4229-9592-77e58f6e994f/README.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class Moderate (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Moderate #Gold {
|
||||||
|
+ text(string|array $input, ?string $model = null) : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Moderate::text
|
||||||
|
Classify if text violates OpenAI's Content Policy.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/moderations/create
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
60
src/34f2c249-64a7-4229-9592-77e58f6e994f/code.php
Normal file
60
src/34f2c249-64a7-4229-9592-77e58f6e994f/code.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Openai\Abstraction\Api;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Moderate
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class Moderate extends Api
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Classify if text violates OpenAI's Content Policy.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/moderations/create
|
||||||
|
*
|
||||||
|
* @param string|array $input The input text to classify.
|
||||||
|
* @param string|null $model The moderation model (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function text(
|
||||||
|
$input,
|
||||||
|
?string $model = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/moderations";
|
||||||
|
|
||||||
|
// Set the moderation data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->input = $input;
|
||||||
|
|
||||||
|
if ($model !== null)
|
||||||
|
{
|
||||||
|
$data->model = $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
34
src/34f2c249-64a7-4229-9592-77e58f6e994f/code.power
Normal file
34
src/34f2c249-64a7-4229-9592-77e58f6e994f/code.power
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* Classify if text violates OpenAI's Content Policy.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/moderations/create
|
||||||
|
*
|
||||||
|
* @param string|array $input The input text to classify.
|
||||||
|
* @param string|null $model The moderation model (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function text(
|
||||||
|
$input,
|
||||||
|
?string $model = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/moderations";
|
||||||
|
|
||||||
|
// Set the moderation data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->input = $input;
|
||||||
|
|
||||||
|
if ($model !== null)
|
||||||
|
{
|
||||||
|
$data->model = $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
18
src/34f2c249-64a7-4229-9592-77e58f6e994f/settings.json
Normal file
18
src/34f2c249-64a7-4229-9592-77e58f6e994f/settings.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "585de711-2784-4f89-90bf-94a8a63366f1",
|
||||||
|
"guid": "34f2c249-64a7-4229-9592-77e58f6e994f",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Moderate",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Moderate",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": null,
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Moderate",
|
||||||
|
"description": "The Openai Moderate\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
36
src/4c58b254-aea5-40aa-b54d-9586a1690451/README.md
Normal file
36
src/4c58b254-aea5-40aa-b54d-9586a1690451/README.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# final class Http (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai\Utilities**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Http << (F,LightGreen) >> #Green {
|
||||||
|
+ __construct(?string $token, ?string $org = null)
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Http::__construct
|
||||||
|
Constructor.
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
63
src/4c58b254-aea5-40aa-b54d-9586a1690451/code.php
Normal file
63
src/4c58b254-aea5-40aa-b54d-9586a1690451/code.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai\Utilities;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\CMS\Http\Http as JoomlaHttp;
|
||||||
|
use Joomla\Registry\Registry;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Http
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
final class Http extends JoomlaHttp
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string|null $token The Openai API token.
|
||||||
|
* @param string|null $org The Openai API Organization token.
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
**/
|
||||||
|
public function __construct(?string $token, ?string $org = null)
|
||||||
|
{
|
||||||
|
// setup config
|
||||||
|
$config = [
|
||||||
|
'userAgent' => 'JoomlaOpenai/3.0',
|
||||||
|
'headers' => [
|
||||||
|
'Content-Type' => 'application/json'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
// add the token if given
|
||||||
|
if (is_string($token))
|
||||||
|
{
|
||||||
|
$config['headers']['Authorization'] = 'Bearer ' . $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the organization token if given
|
||||||
|
if (is_string($org))
|
||||||
|
{
|
||||||
|
$config['headers']['OpenAI-Organization'] = $org;
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = new Registry($config);
|
||||||
|
|
||||||
|
// run parent constructor
|
||||||
|
parent::__construct($options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
36
src/4c58b254-aea5-40aa-b54d-9586a1690451/code.power
Normal file
36
src/4c58b254-aea5-40aa-b54d-9586a1690451/code.power
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string|null $token The Openai API token.
|
||||||
|
* @param string|null $org The Openai API Organization token.
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
**/
|
||||||
|
public function __construct(?string $token, ?string $org = null)
|
||||||
|
{
|
||||||
|
// setup config
|
||||||
|
$config = [
|
||||||
|
'userAgent' => 'JoomlaOpenai/3.0',
|
||||||
|
'headers' => [
|
||||||
|
'Content-Type' => 'application/json'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
// add the token if given
|
||||||
|
if (is_string($token))
|
||||||
|
{
|
||||||
|
$config['headers']['Authorization'] = 'Bearer ' . $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the organization token if given
|
||||||
|
if (is_string($org))
|
||||||
|
{
|
||||||
|
$config['headers']['OpenAI-Organization'] = $org;
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = new Registry($config);
|
||||||
|
|
||||||
|
// run parent constructor
|
||||||
|
parent::__construct($options);
|
||||||
|
}
|
19
src/4c58b254-aea5-40aa-b54d-9586a1690451/settings.json
Normal file
19
src/4c58b254-aea5-40aa-b54d-9586a1690451/settings.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"add_head": "1",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "-1",
|
||||||
|
"guid": "4c58b254-aea5-40aa-b54d-9586a1690451",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Http",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Utilities.Http",
|
||||||
|
"type": "final class",
|
||||||
|
"use_selection": null,
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Utilities.Http",
|
||||||
|
"description": "The Openai Http\r\n\r\n@since 3.2.0",
|
||||||
|
"extends_custom": "JoomlaHttp",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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\\CMS\\Http\\Http as JoomlaHttp;\r\nuse Joomla\\Registry\\Registry;",
|
||||||
|
"composer": ""
|
||||||
|
}
|
44
src/585de711-2784-4f89-90bf-94a8a63366f1/README.md
Normal file
44
src/585de711-2784-4f89-90bf-94a8a63366f1/README.md
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# abstract class Api (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai\Abstraction**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
abstract Api #Orange {
|
||||||
|
# Http $http
|
||||||
|
# Uri $uri
|
||||||
|
# Response $response
|
||||||
|
+ __construct(Http $http, Uri $uri, ...)
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Api::__construct
|
||||||
|
Constructor.
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
Http $http
|
||||||
|
Uri $uri
|
||||||
|
Response $response
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
67
src/585de711-2784-4f89-90bf-94a8a63366f1/code.php
Normal file
67
src/585de711-2784-4f89-90bf-94a8a63366f1/code.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai\Abstraction;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Openai\Utilities\Http;
|
||||||
|
use VDM\Joomla\Openai\Utilities\Uri;
|
||||||
|
use VDM\Joomla\Openai\Utilities\Response;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Api
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
abstract class Api
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Http class
|
||||||
|
*
|
||||||
|
* @var Http
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
protected Http $http;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Uri class
|
||||||
|
*
|
||||||
|
* @var Uri
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
protected Uri $uri;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Response class
|
||||||
|
*
|
||||||
|
* @var Response
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
protected Response $response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param Http $http The http class.
|
||||||
|
* @param Uri $uri The uri class.
|
||||||
|
* @param Response $response The response class.
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function __construct(Http $http, Uri $uri, Response $response)
|
||||||
|
{
|
||||||
|
$this->http = $http;
|
||||||
|
$this->uri = $uri;
|
||||||
|
$this->response = $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
39
src/585de711-2784-4f89-90bf-94a8a63366f1/code.power
Normal file
39
src/585de711-2784-4f89-90bf-94a8a63366f1/code.power
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* The Http class
|
||||||
|
*
|
||||||
|
* @var Http
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
protected Http $http;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Uri class
|
||||||
|
*
|
||||||
|
* @var Uri
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
protected Uri $uri;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Response class
|
||||||
|
*
|
||||||
|
* @var Response
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
protected Response $response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param Http $http The http class.
|
||||||
|
* @param Uri $uri The uri class.
|
||||||
|
* @param Response $response The response class.
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function __construct(Http $http, Uri $uri, Response $response)
|
||||||
|
{
|
||||||
|
$this->http = $http;
|
||||||
|
$this->uri = $uri;
|
||||||
|
$this->response = $response;
|
||||||
|
}
|
31
src/585de711-2784-4f89-90bf-94a8a63366f1/settings.json
Normal file
31
src/585de711-2784-4f89-90bf-94a8a63366f1/settings.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "0",
|
||||||
|
"guid": "585de711-2784-4f89-90bf-94a8a63366f1",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Api",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Abstraction.Api",
|
||||||
|
"type": "abstract class",
|
||||||
|
"use_selection": {
|
||||||
|
"use_selection0": {
|
||||||
|
"use": "4c58b254-aea5-40aa-b54d-9586a1690451",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection1": {
|
||||||
|
"use": "13ef84f4-25b0-43dd-a9f6-0722abf220c1",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection2": {
|
||||||
|
"use": "c464393e-7606-406e-8463-a86774590966",
|
||||||
|
"as": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Abstraction.Api",
|
||||||
|
"description": "The Openai Api\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
74
src/65dd022b-8f3a-46be-8930-0cae74b9834b/README.md
Normal file
74
src/65dd022b-8f3a-46be-8930-0cae74b9834b/README.md
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class Files (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Files #Gold {
|
||||||
|
+ list() : ?object
|
||||||
|
+ upload(string $file, string $purpose) : ?object
|
||||||
|
+ info(string $fileID) : ?object
|
||||||
|
+ content(string $fileID) : mixed
|
||||||
|
+ delete(string $fileID) : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Files::list
|
||||||
|
Fetches a list of files belonging to the user's organization.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/files/list
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Files::upload
|
||||||
|
Upload a file that contains document(s) to be used across various endpoints/features.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/files/upload
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Files::info
|
||||||
|
Returns information about a specific file.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/files/retrieve
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Files::content
|
||||||
|
Retrieve a specific file content.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/files/retrieve-content
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Files::delete
|
||||||
|
Delete a file.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/files/delete
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
140
src/65dd022b-8f3a-46be-8930-0cae74b9834b/code.php
Normal file
140
src/65dd022b-8f3a-46be-8930-0cae74b9834b/code.php
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Openai\Abstraction\Api;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Files
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class Files extends Api
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Fetches a list of files belonging to the user's organization.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/files/list
|
||||||
|
*
|
||||||
|
* @return object|null The response from the OpenAI API, or null if an error occurred.
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function list(): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/files";
|
||||||
|
|
||||||
|
// Prepare the URI.
|
||||||
|
$uri = $this->uri->get($path);
|
||||||
|
|
||||||
|
// Send the GET request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->get($uri)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload a file that contains document(s) to be used across various endpoints/features.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/files/upload
|
||||||
|
*
|
||||||
|
* @param string $file The file to upload.
|
||||||
|
* @param string $purpose The intended purpose of the uploaded documents.
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function upload(string $file, string $purpose): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/files";
|
||||||
|
|
||||||
|
// Set the request data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->file = $file;
|
||||||
|
$data->purpose = $purpose;
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns information about a specific file.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/files/retrieve
|
||||||
|
*
|
||||||
|
* @param string $fileID The file id to retrieve info
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function info(string $fileID): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/files/{$fileID}";
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->get(
|
||||||
|
$this->uri->get($path)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a specific file content.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/files/retrieve-content
|
||||||
|
*
|
||||||
|
* @param string $fileID The file id to retrieve content
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function content(string $fileID)
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/files/{$fileID}/content";
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->get(
|
||||||
|
$this->uri->get($path)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a file.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/files/delete
|
||||||
|
*
|
||||||
|
* @param string $fileID The file id to delete
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function delete(string $fileID): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/files/{$fileID}";
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->delete(
|
||||||
|
$this->uri->get($path)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
114
src/65dd022b-8f3a-46be-8930-0cae74b9834b/code.power
Normal file
114
src/65dd022b-8f3a-46be-8930-0cae74b9834b/code.power
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/**
|
||||||
|
* Fetches a list of files belonging to the user's organization.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/files/list
|
||||||
|
*
|
||||||
|
* @return object|null The response from the OpenAI API, or null if an error occurred.
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function list(): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/files";
|
||||||
|
|
||||||
|
// Prepare the URI.
|
||||||
|
$uri = $this->uri->get($path);
|
||||||
|
|
||||||
|
// Send the GET request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->get($uri)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload a file that contains document(s) to be used across various endpoints/features.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/files/upload
|
||||||
|
*
|
||||||
|
* @param string $file The file to upload.
|
||||||
|
* @param string $purpose The intended purpose of the uploaded documents.
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function upload(string $file, string $purpose): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/files";
|
||||||
|
|
||||||
|
// Set the request data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->file = $file;
|
||||||
|
$data->purpose = $purpose;
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns information about a specific file.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/files/retrieve
|
||||||
|
*
|
||||||
|
* @param string $fileID The file id to retrieve info
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function info(string $fileID): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/files/{$fileID}";
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->get(
|
||||||
|
$this->uri->get($path)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a specific file content.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/files/retrieve-content
|
||||||
|
*
|
||||||
|
* @param string $fileID The file id to retrieve content
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function content(string $fileID)
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/files/{$fileID}/content";
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->get(
|
||||||
|
$this->uri->get($path)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a file.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/files/delete
|
||||||
|
*
|
||||||
|
* @param string $fileID The file id to delete
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function delete(string $fileID): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/files/{$fileID}";
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->delete(
|
||||||
|
$this->uri->get($path)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
18
src/65dd022b-8f3a-46be-8930-0cae74b9834b/settings.json
Normal file
18
src/65dd022b-8f3a-46be-8930-0cae74b9834b/settings.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "585de711-2784-4f89-90bf-94a8a63366f1",
|
||||||
|
"guid": "65dd022b-8f3a-46be-8930-0cae74b9834b",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Files",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Files",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": null,
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Files",
|
||||||
|
"description": "The Openai Files\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
56
src/796cca70-2577-4f8f-9a05-ac37db1f2f02/README.md
Normal file
56
src/796cca70-2577-4f8f-9a05-ac37db1f2f02/README.md
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class Completions (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Completions #Gold {
|
||||||
|
+ create(string $model, string|array $prompt, ...) : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Completions::create
|
||||||
|
Create a completion using the OpenAI API.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/completions
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $model
|
||||||
|
string|array $prompt
|
||||||
|
?int $maxTokens = null
|
||||||
|
?string $suffix = null
|
||||||
|
?float $temperature = null
|
||||||
|
?float $topP = null
|
||||||
|
?int $n = null
|
||||||
|
?bool $stream = null
|
||||||
|
?int $logprobs = null
|
||||||
|
?bool $echo = null
|
||||||
|
string|null $stop = null
|
||||||
|
?float $presencePenalty = null
|
||||||
|
?float $frequencyPenalty = null
|
||||||
|
?int $bestOf = null
|
||||||
|
?array $logitBias = null
|
||||||
|
?string $user = null
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
158
src/796cca70-2577-4f8f-9a05-ac37db1f2f02/code.php
Normal file
158
src/796cca70-2577-4f8f-9a05-ac37db1f2f02/code.php
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Openai\Abstraction\Api;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Completions
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class Completions extends Api
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a completion using the OpenAI API.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/completions
|
||||||
|
*
|
||||||
|
* @param string $model The ID of the model to use.
|
||||||
|
* @param string|array $prompt The prompt(s) to generate completions for.
|
||||||
|
* @param int|null $maxTokens The maximum number of tokens to generate (optional).
|
||||||
|
* @param float|null $temperature The sampling temperature to use (optional).
|
||||||
|
* @param string $suffix The suffix that comes after a completion of inserted text. (optional).
|
||||||
|
* @param float|null $topP The top_p value for nucleus sampling (optional).
|
||||||
|
* @param int|null $n How many completions to generate (optional).
|
||||||
|
* @param bool|null $stream Whether to stream back partial progress (optional).
|
||||||
|
* @param int|null $logprobs Include the log probabilities on the most likely tokens (optional).
|
||||||
|
* @param bool|null $echo Echo back the prompt in addition to the completion (optional).
|
||||||
|
* @param string|null $stop Up to 4 sequences where the API will stop generating (optional).
|
||||||
|
* @param float|null $presencePenalty The presence penalty to use (optional).
|
||||||
|
* @param float|null $frequencyPenalty The frequency penalty to use (optional).
|
||||||
|
* @param int|null $bestOf Generates best_of completions server-side (optional).
|
||||||
|
* @param array|null $logitBias Modify the likelihood of specified tokens (optional).
|
||||||
|
* @param string|null $user A unique identifier representing your end-user (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function create(
|
||||||
|
string $model,
|
||||||
|
$prompt,
|
||||||
|
?int $maxTokens = null,
|
||||||
|
?string $suffix = null,
|
||||||
|
?float $temperature = null,
|
||||||
|
?float $topP = null,
|
||||||
|
?int $n = null,
|
||||||
|
?bool $stream = null,
|
||||||
|
?int $logprobs = null,
|
||||||
|
?bool $echo = null,
|
||||||
|
$stop = null,
|
||||||
|
?float $presencePenalty = null,
|
||||||
|
?float $frequencyPenalty = null,
|
||||||
|
?int $bestOf = null,
|
||||||
|
?array $logitBias = null,
|
||||||
|
?string $user = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/completions";
|
||||||
|
|
||||||
|
// Set the completion data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->model = $model;
|
||||||
|
$data->prompt = $prompt;
|
||||||
|
|
||||||
|
if ($maxTokens !== null)
|
||||||
|
{
|
||||||
|
$data->max_tokens = $maxTokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($temperature !== null)
|
||||||
|
{
|
||||||
|
$data->temperature = $temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($suffix !== null)
|
||||||
|
{
|
||||||
|
$data->suffix = $suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($topP !== null)
|
||||||
|
{
|
||||||
|
$data->top_p = $topP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n !== null)
|
||||||
|
{
|
||||||
|
$data->n = $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($stream !== null)
|
||||||
|
{
|
||||||
|
$data->stream = $stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($logprobs !== null)
|
||||||
|
{
|
||||||
|
$data->logprobs = $logprobs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($echo !== null)
|
||||||
|
{
|
||||||
|
$data->echo = $echo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($stop !== null)
|
||||||
|
{
|
||||||
|
$data->stop = $stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($presencePenalty !== null)
|
||||||
|
{
|
||||||
|
$data->presence_penalty = $presencePenalty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($frequencyPenalty !== null)
|
||||||
|
{
|
||||||
|
$data->frequency_penalty = $frequencyPenalty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($bestOf !== null)
|
||||||
|
{
|
||||||
|
$data->best_of = $bestOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($logitBias !== null)
|
||||||
|
{
|
||||||
|
$data->logit_bias = new \stdClass();
|
||||||
|
foreach ($logitBias as $key => $val)
|
||||||
|
{
|
||||||
|
$data->logit_bias->$key = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user !== null)
|
||||||
|
{
|
||||||
|
$data->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
132
src/796cca70-2577-4f8f-9a05-ac37db1f2f02/code.power
Normal file
132
src/796cca70-2577-4f8f-9a05-ac37db1f2f02/code.power
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/**
|
||||||
|
* Create a completion using the OpenAI API.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/completions
|
||||||
|
*
|
||||||
|
* @param string $model The ID of the model to use.
|
||||||
|
* @param string|array $prompt The prompt(s) to generate completions for.
|
||||||
|
* @param int|null $maxTokens The maximum number of tokens to generate (optional).
|
||||||
|
* @param float|null $temperature The sampling temperature to use (optional).
|
||||||
|
* @param string $suffix The suffix that comes after a completion of inserted text. (optional).
|
||||||
|
* @param float|null $topP The top_p value for nucleus sampling (optional).
|
||||||
|
* @param int|null $n How many completions to generate (optional).
|
||||||
|
* @param bool|null $stream Whether to stream back partial progress (optional).
|
||||||
|
* @param int|null $logprobs Include the log probabilities on the most likely tokens (optional).
|
||||||
|
* @param bool|null $echo Echo back the prompt in addition to the completion (optional).
|
||||||
|
* @param string|null $stop Up to 4 sequences where the API will stop generating (optional).
|
||||||
|
* @param float|null $presencePenalty The presence penalty to use (optional).
|
||||||
|
* @param float|null $frequencyPenalty The frequency penalty to use (optional).
|
||||||
|
* @param int|null $bestOf Generates best_of completions server-side (optional).
|
||||||
|
* @param array|null $logitBias Modify the likelihood of specified tokens (optional).
|
||||||
|
* @param string|null $user A unique identifier representing your end-user (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function create(
|
||||||
|
string $model,
|
||||||
|
$prompt,
|
||||||
|
?int $maxTokens = null,
|
||||||
|
?string $suffix = null,
|
||||||
|
?float $temperature = null,
|
||||||
|
?float $topP = null,
|
||||||
|
?int $n = null,
|
||||||
|
?bool $stream = null,
|
||||||
|
?int $logprobs = null,
|
||||||
|
?bool $echo = null,
|
||||||
|
$stop = null,
|
||||||
|
?float $presencePenalty = null,
|
||||||
|
?float $frequencyPenalty = null,
|
||||||
|
?int $bestOf = null,
|
||||||
|
?array $logitBias = null,
|
||||||
|
?string $user = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/completions";
|
||||||
|
|
||||||
|
// Set the completion data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->model = $model;
|
||||||
|
$data->prompt = $prompt;
|
||||||
|
|
||||||
|
if ($maxTokens !== null)
|
||||||
|
{
|
||||||
|
$data->max_tokens = $maxTokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($temperature !== null)
|
||||||
|
{
|
||||||
|
$data->temperature = $temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($suffix !== null)
|
||||||
|
{
|
||||||
|
$data->suffix = $suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($topP !== null)
|
||||||
|
{
|
||||||
|
$data->top_p = $topP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n !== null)
|
||||||
|
{
|
||||||
|
$data->n = $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($stream !== null)
|
||||||
|
{
|
||||||
|
$data->stream = $stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($logprobs !== null)
|
||||||
|
{
|
||||||
|
$data->logprobs = $logprobs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($echo !== null)
|
||||||
|
{
|
||||||
|
$data->echo = $echo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($stop !== null)
|
||||||
|
{
|
||||||
|
$data->stop = $stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($presencePenalty !== null)
|
||||||
|
{
|
||||||
|
$data->presence_penalty = $presencePenalty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($frequencyPenalty !== null)
|
||||||
|
{
|
||||||
|
$data->frequency_penalty = $frequencyPenalty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($bestOf !== null)
|
||||||
|
{
|
||||||
|
$data->best_of = $bestOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($logitBias !== null)
|
||||||
|
{
|
||||||
|
$data->logit_bias = new \stdClass();
|
||||||
|
foreach ($logitBias as $key => $val)
|
||||||
|
{
|
||||||
|
$data->logit_bias->$key = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user !== null)
|
||||||
|
{
|
||||||
|
$data->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
18
src/796cca70-2577-4f8f-9a05-ac37db1f2f02/settings.json
Normal file
18
src/796cca70-2577-4f8f-9a05-ac37db1f2f02/settings.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "585de711-2784-4f89-90bf-94a8a63366f1",
|
||||||
|
"guid": "796cca70-2577-4f8f-9a05-ac37db1f2f02",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Completions",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Completions",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": null,
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Completions",
|
||||||
|
"description": "The Openai Completions\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
46
src/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8/README.md
Normal file
46
src/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8/README.md
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class Edits (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Edits #Gold {
|
||||||
|
+ create(string $model, string $instruction, ...) : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Edits::create
|
||||||
|
Create a new edit using OpenAI Edit API.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/edits
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $model
|
||||||
|
string $instruction
|
||||||
|
?string $input = null
|
||||||
|
?int $n = null
|
||||||
|
?float $temperature = null
|
||||||
|
?float $topP = null
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
84
src/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8/code.php
Normal file
84
src/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8/code.php
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Openai\Abstraction\Api;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Edits
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class Edits extends Api
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new edit using OpenAI Edit API.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/edits
|
||||||
|
*
|
||||||
|
* @param string $model The model to use.
|
||||||
|
* @param string $instruction The instruction for the edit.
|
||||||
|
* @param string|null $input The input text (optional).
|
||||||
|
* @param int|null $n How many edits to generate (optional).
|
||||||
|
* @param float|null $temperature The sampling temperature (optional).
|
||||||
|
* @param float|null $topP Nucleus sampling parameter (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function create(
|
||||||
|
string $model,
|
||||||
|
string $instruction,
|
||||||
|
?string $input = null,
|
||||||
|
?int $n = null,
|
||||||
|
?float $temperature = null,
|
||||||
|
?float $topP = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/edits";
|
||||||
|
|
||||||
|
// Set the data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->model = $model;
|
||||||
|
$data->instruction = $instruction;
|
||||||
|
|
||||||
|
if ($input !== null)
|
||||||
|
{
|
||||||
|
$data->input = $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n !== null)
|
||||||
|
{
|
||||||
|
$data->n = $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($temperature !== null)
|
||||||
|
{
|
||||||
|
$data->temperature = $temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($topP !== null)
|
||||||
|
{
|
||||||
|
$data->top_p = $topP;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
58
src/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8/code.power
Normal file
58
src/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8/code.power
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/**
|
||||||
|
* Create a new edit using OpenAI Edit API.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/edits
|
||||||
|
*
|
||||||
|
* @param string $model The model to use.
|
||||||
|
* @param string $instruction The instruction for the edit.
|
||||||
|
* @param string|null $input The input text (optional).
|
||||||
|
* @param int|null $n How many edits to generate (optional).
|
||||||
|
* @param float|null $temperature The sampling temperature (optional).
|
||||||
|
* @param float|null $topP Nucleus sampling parameter (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function create(
|
||||||
|
string $model,
|
||||||
|
string $instruction,
|
||||||
|
?string $input = null,
|
||||||
|
?int $n = null,
|
||||||
|
?float $temperature = null,
|
||||||
|
?float $topP = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/edits";
|
||||||
|
|
||||||
|
// Set the data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->model = $model;
|
||||||
|
$data->instruction = $instruction;
|
||||||
|
|
||||||
|
if ($input !== null)
|
||||||
|
{
|
||||||
|
$data->input = $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n !== null)
|
||||||
|
{
|
||||||
|
$data->n = $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($temperature !== null)
|
||||||
|
{
|
||||||
|
$data->temperature = $temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($topP !== null)
|
||||||
|
{
|
||||||
|
$data->top_p = $topP;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
18
src/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8/settings.json
Normal file
18
src/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8/settings.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "585de711-2784-4f89-90bf-94a8a63366f1",
|
||||||
|
"guid": "98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Edits",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Edits",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": null,
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Edits",
|
||||||
|
"description": "The Openai Edits\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
79
src/bb8973c1-261f-4b55-8f9b-9ee98843fced/README.md
Normal file
79
src/bb8973c1-261f-4b55-8f9b-9ee98843fced/README.md
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class Images (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Images #Gold {
|
||||||
|
+ generate(string $prompt, ?string $size = null, ...) : ?object
|
||||||
|
+ edit(string $image, string $prompt, ...) : ?object
|
||||||
|
+ variation(string $image, ?string $size = null, ...) : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Images::generate
|
||||||
|
Generate an image given a text prompt.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/images/create
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $prompt
|
||||||
|
?string $size = null
|
||||||
|
?string $responseFormat = null
|
||||||
|
?int $n = null
|
||||||
|
?string $user = null
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Images::edit
|
||||||
|
Create an image edit with extended options.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/images/create-edit
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $image
|
||||||
|
string $prompt
|
||||||
|
?string $mask = null
|
||||||
|
?string $size = null
|
||||||
|
?string $responseFormat = null
|
||||||
|
?int $n = null
|
||||||
|
?string $user = null
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Images::variation
|
||||||
|
Create a variation of a given image.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/images/create-variation
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $image
|
||||||
|
?string $size = null
|
||||||
|
?string $responseFormat = null
|
||||||
|
?int $n = null
|
||||||
|
?string $user = null
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
203
src/bb8973c1-261f-4b55-8f9b-9ee98843fced/code.php
Normal file
203
src/bb8973c1-261f-4b55-8f9b-9ee98843fced/code.php
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Openai\Abstraction\Api;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Images
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class Images extends Api
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Generate an image given a text prompt.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/images/create
|
||||||
|
*
|
||||||
|
* @param string $prompt The text description of the desired image(s).
|
||||||
|
* @param string|null $size The size of the generated images (optional).
|
||||||
|
* @param string|null $responseFormat The format in which the images are returned (optional).
|
||||||
|
* @param int|null $n The number of images to generate (optional).
|
||||||
|
* @param string|null $user A unique identifier representing the end-user (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function generate(
|
||||||
|
string $prompt,
|
||||||
|
?string $size = null,
|
||||||
|
?string $responseFormat = null,
|
||||||
|
?int $n = null,
|
||||||
|
?string $user = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/images/generations";
|
||||||
|
|
||||||
|
// Set the request data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->prompt = $prompt;
|
||||||
|
|
||||||
|
if ($size !== null)
|
||||||
|
{
|
||||||
|
$data->size = $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($responseFormat !== null)
|
||||||
|
{
|
||||||
|
$data->response_format = $responseFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n !== null)
|
||||||
|
{
|
||||||
|
$data->n = $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user !== null)
|
||||||
|
{
|
||||||
|
$data->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an image edit with extended options.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/images/create-edit
|
||||||
|
*
|
||||||
|
* @param string $image The original image to edit. Must be a valid PNG file, less than 4MB, and square.
|
||||||
|
* @param string|null $mask An additional image for editing (optional).
|
||||||
|
* @param string $prompt A text description of the desired image(s).
|
||||||
|
* @param string|null $size The size of the generated images (optional).
|
||||||
|
* @param string|null $responseFormat The format in which the images are returned (optional).
|
||||||
|
* @param int|null $n The number of images to generate (optional).
|
||||||
|
* @param string|null $user A unique identifier representing your end-user (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function edit(
|
||||||
|
string $image,
|
||||||
|
string $prompt,
|
||||||
|
?string $mask = null,
|
||||||
|
?string $size = null,
|
||||||
|
?string $responseFormat = null,
|
||||||
|
?int $n = null,
|
||||||
|
?string $user = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/images/edits";
|
||||||
|
|
||||||
|
// Set the image edit data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->image = $image;
|
||||||
|
$data->prompt = $prompt;
|
||||||
|
|
||||||
|
if ($mask !== null)
|
||||||
|
{
|
||||||
|
$data->mask = $mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($size !== null)
|
||||||
|
{
|
||||||
|
$data->size = $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($responseFormat !== null)
|
||||||
|
{
|
||||||
|
$data->response_format = $responseFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n !== null)
|
||||||
|
{
|
||||||
|
$data->n = $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user !== null)
|
||||||
|
{
|
||||||
|
$data->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a variation of a given image.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/images/create-variation
|
||||||
|
*
|
||||||
|
* @param string $image The image to use as the basis for the variation(s).
|
||||||
|
* @param string|null $size The size of the generated images (optional).
|
||||||
|
* @param string|null $responseFormat The format in which the generated images are returned (optional).
|
||||||
|
* @param int|null $n The number of images to generate (optional).
|
||||||
|
* @param string|null $user A unique identifier representing your end-user (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function variation(
|
||||||
|
string $image,
|
||||||
|
?string $size = null,
|
||||||
|
?string $responseFormat = null,
|
||||||
|
?int $n = null,
|
||||||
|
?string $user = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/images/variations";
|
||||||
|
|
||||||
|
// Set the image variation data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->image = $image;
|
||||||
|
|
||||||
|
if ($size !== null)
|
||||||
|
{
|
||||||
|
$data->size = $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($responseFormat !== null)
|
||||||
|
{
|
||||||
|
$data->response_format = $responseFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n !== null)
|
||||||
|
{
|
||||||
|
$data->n = $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user !== null)
|
||||||
|
{
|
||||||
|
$data->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
177
src/bb8973c1-261f-4b55-8f9b-9ee98843fced/code.power
Normal file
177
src/bb8973c1-261f-4b55-8f9b-9ee98843fced/code.power
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
/**
|
||||||
|
* Generate an image given a text prompt.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/images/create
|
||||||
|
*
|
||||||
|
* @param string $prompt The text description of the desired image(s).
|
||||||
|
* @param string|null $size The size of the generated images (optional).
|
||||||
|
* @param string|null $responseFormat The format in which the images are returned (optional).
|
||||||
|
* @param int|null $n The number of images to generate (optional).
|
||||||
|
* @param string|null $user A unique identifier representing the end-user (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function generate(
|
||||||
|
string $prompt,
|
||||||
|
?string $size = null,
|
||||||
|
?string $responseFormat = null,
|
||||||
|
?int $n = null,
|
||||||
|
?string $user = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/images/generations";
|
||||||
|
|
||||||
|
// Set the request data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->prompt = $prompt;
|
||||||
|
|
||||||
|
if ($size !== null)
|
||||||
|
{
|
||||||
|
$data->size = $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($responseFormat !== null)
|
||||||
|
{
|
||||||
|
$data->response_format = $responseFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n !== null)
|
||||||
|
{
|
||||||
|
$data->n = $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user !== null)
|
||||||
|
{
|
||||||
|
$data->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an image edit with extended options.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/images/create-edit
|
||||||
|
*
|
||||||
|
* @param string $image The original image to edit. Must be a valid PNG file, less than 4MB, and square.
|
||||||
|
* @param string|null $mask An additional image for editing (optional).
|
||||||
|
* @param string $prompt A text description of the desired image(s).
|
||||||
|
* @param string|null $size The size of the generated images (optional).
|
||||||
|
* @param string|null $responseFormat The format in which the images are returned (optional).
|
||||||
|
* @param int|null $n The number of images to generate (optional).
|
||||||
|
* @param string|null $user A unique identifier representing your end-user (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function edit(
|
||||||
|
string $image,
|
||||||
|
string $prompt,
|
||||||
|
?string $mask = null,
|
||||||
|
?string $size = null,
|
||||||
|
?string $responseFormat = null,
|
||||||
|
?int $n = null,
|
||||||
|
?string $user = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/images/edits";
|
||||||
|
|
||||||
|
// Set the image edit data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->image = $image;
|
||||||
|
$data->prompt = $prompt;
|
||||||
|
|
||||||
|
if ($mask !== null)
|
||||||
|
{
|
||||||
|
$data->mask = $mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($size !== null)
|
||||||
|
{
|
||||||
|
$data->size = $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($responseFormat !== null)
|
||||||
|
{
|
||||||
|
$data->response_format = $responseFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n !== null)
|
||||||
|
{
|
||||||
|
$data->n = $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user !== null)
|
||||||
|
{
|
||||||
|
$data->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a variation of a given image.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/images/create-variation
|
||||||
|
*
|
||||||
|
* @param string $image The image to use as the basis for the variation(s).
|
||||||
|
* @param string|null $size The size of the generated images (optional).
|
||||||
|
* @param string|null $responseFormat The format in which the generated images are returned (optional).
|
||||||
|
* @param int|null $n The number of images to generate (optional).
|
||||||
|
* @param string|null $user A unique identifier representing your end-user (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function variation(
|
||||||
|
string $image,
|
||||||
|
?string $size = null,
|
||||||
|
?string $responseFormat = null,
|
||||||
|
?int $n = null,
|
||||||
|
?string $user = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/images/variations";
|
||||||
|
|
||||||
|
// Set the image variation data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->image = $image;
|
||||||
|
|
||||||
|
if ($size !== null)
|
||||||
|
{
|
||||||
|
$data->size = $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($responseFormat !== null)
|
||||||
|
{
|
||||||
|
$data->response_format = $responseFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n !== null)
|
||||||
|
{
|
||||||
|
$data->n = $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user !== null)
|
||||||
|
{
|
||||||
|
$data->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
18
src/bb8973c1-261f-4b55-8f9b-9ee98843fced/settings.json
Normal file
18
src/bb8973c1-261f-4b55-8f9b-9ee98843fced/settings.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "585de711-2784-4f89-90bf-94a8a63366f1",
|
||||||
|
"guid": "bb8973c1-261f-4b55-8f9b-9ee98843fced",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Images",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Images",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": null,
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Images",
|
||||||
|
"description": "The Openai Images\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
66
src/c464393e-7606-406e-8463-a86774590966/README.md
Normal file
66
src/c464393e-7606-406e-8463-a86774590966/README.md
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# final class Response (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai\Utilities**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Response << (F,LightGreen) >> #Green {
|
||||||
|
+ get(JoomlaResponse $response, int $expectedCode = 200, ...) : mixed
|
||||||
|
+ get_(JoomlaResponse $response, array $validate = [200 => null]) : mixed
|
||||||
|
# body(JoomlaResponse $response, mixed $default = null) : mixed
|
||||||
|
# error(JoomlaResponse $response) : string
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Response::get
|
||||||
|
Process the response and decode it.
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: mixed
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
JoomlaResponse $response
|
||||||
|
int $expectedCode = 200
|
||||||
|
mixed $default = null
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Response::get_
|
||||||
|
Process the response and decode it. (when we have multiple success codes)
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Response::body
|
||||||
|
Return the body from the response
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Response::error
|
||||||
|
Get the error message from the OpenAI API response
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: string
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
140
src/c464393e-7606-406e-8463-a86774590966/code.php
Normal file
140
src/c464393e-7606-406e-8463-a86774590966/code.php
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai\Utilities;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\CMS\Http\Response as JoomlaResponse;
|
||||||
|
use VDM\Joomla\Utilities\JsonHelper;
|
||||||
|
use VDM\Joomla\Utilities\StringHelper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Response
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
final class Response
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Process the response and decode it.
|
||||||
|
*
|
||||||
|
* @param JoomlaResponse $response The response.
|
||||||
|
* @param integer $expectedCode The expected "good" code.
|
||||||
|
* @param mixed $default The default if body not have length
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
* @throws \DomainException
|
||||||
|
**/
|
||||||
|
public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null)
|
||||||
|
{
|
||||||
|
// Validate the response code.
|
||||||
|
if ($response->code != $expectedCode)
|
||||||
|
{
|
||||||
|
// Decode the error response and throw an exception.
|
||||||
|
$message = $this->error($response);
|
||||||
|
|
||||||
|
// Throw an exception with the OpenAI error message and code.
|
||||||
|
throw new \DomainException($message, $response->code);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->body($response, $default);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the response and decode it. (when we have multiple success codes)
|
||||||
|
*
|
||||||
|
* @param JoomlaResponse $response The response.
|
||||||
|
* @param array [$expectedCode => $default] The expected "good" code. and The default if body not have length
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
* @throws \DomainException
|
||||||
|
**/
|
||||||
|
public function get_(JoomlaResponse $response, array $validate = [200 => null])
|
||||||
|
{
|
||||||
|
// Validate the response code.
|
||||||
|
if (!isset($validate[$response->code]))
|
||||||
|
{
|
||||||
|
// Decode the error response and throw an exception.
|
||||||
|
$message = $this->error($response);
|
||||||
|
|
||||||
|
// Throw an exception with the OpenAI error message and code.
|
||||||
|
throw new \DomainException($message, $response->code);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->body($response, $validate[$response->code]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the body from the response
|
||||||
|
*
|
||||||
|
* @param JoomlaResponse $response The response.
|
||||||
|
* @param mixed $default The default if body not have length
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
protected function body(JoomlaResponse $response, $default = null)
|
||||||
|
{
|
||||||
|
// check that we have a body and that its JSON
|
||||||
|
if (isset($response->body) && StringHelper::check($response->body))
|
||||||
|
{
|
||||||
|
if (JsonHelper::check($response->body))
|
||||||
|
{
|
||||||
|
return json_decode((string) $response->body);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->body;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the error message from the OpenAI API response
|
||||||
|
*
|
||||||
|
* @param JoomlaResponse $response The response.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
protected function error(JoomlaResponse $response): string
|
||||||
|
{
|
||||||
|
// do we have a json string
|
||||||
|
if (isset($response->body) && JsonHelper::check($response->body))
|
||||||
|
{
|
||||||
|
$error = json_decode($response->body);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 'Invalid or empty response body.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if OpenAI returned an error object
|
||||||
|
if (isset($error->error))
|
||||||
|
{
|
||||||
|
// error object found, extract message and code
|
||||||
|
$errorMessage = isset($error->error->message) ? $error->error->message : 'Unknown error.';
|
||||||
|
$errorCode = isset($error->error->code) ? $error->error->code : 'Unknown error code.';
|
||||||
|
|
||||||
|
// return formatted error message
|
||||||
|
return 'OpenAI Error: ' . $errorMessage . ' Code: ' . $errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'No error information found in response.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
112
src/c464393e-7606-406e-8463-a86774590966/code.power
Normal file
112
src/c464393e-7606-406e-8463-a86774590966/code.power
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/**
|
||||||
|
* Process the response and decode it.
|
||||||
|
*
|
||||||
|
* @param JoomlaResponse $response The response.
|
||||||
|
* @param integer $expectedCode The expected "good" code.
|
||||||
|
* @param mixed $default The default if body not have length
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
* @throws \DomainException
|
||||||
|
**/
|
||||||
|
public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null)
|
||||||
|
{
|
||||||
|
// Validate the response code.
|
||||||
|
if ($response->code != $expectedCode)
|
||||||
|
{
|
||||||
|
// Decode the error response and throw an exception.
|
||||||
|
$message = $this->error($response);
|
||||||
|
|
||||||
|
// Throw an exception with the OpenAI error message and code.
|
||||||
|
throw new \DomainException($message, $response->code);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->body($response, $default);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the response and decode it. (when we have multiple success codes)
|
||||||
|
*
|
||||||
|
* @param JoomlaResponse $response The response.
|
||||||
|
* @param array [$expectedCode => $default] The expected "good" code. and The default if body not have length
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
* @throws \DomainException
|
||||||
|
**/
|
||||||
|
public function get_(JoomlaResponse $response, array $validate = [200 => null])
|
||||||
|
{
|
||||||
|
// Validate the response code.
|
||||||
|
if (!isset($validate[$response->code]))
|
||||||
|
{
|
||||||
|
// Decode the error response and throw an exception.
|
||||||
|
$message = $this->error($response);
|
||||||
|
|
||||||
|
// Throw an exception with the OpenAI error message and code.
|
||||||
|
throw new \DomainException($message, $response->code);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->body($response, $validate[$response->code]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the body from the response
|
||||||
|
*
|
||||||
|
* @param JoomlaResponse $response The response.
|
||||||
|
* @param mixed $default The default if body not have length
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
protected function body(JoomlaResponse $response, $default = null)
|
||||||
|
{
|
||||||
|
// check that we have a body and that its JSON
|
||||||
|
if (isset($response->body) && StringHelper::check($response->body))
|
||||||
|
{
|
||||||
|
if (JsonHelper::check($response->body))
|
||||||
|
{
|
||||||
|
return json_decode((string) $response->body);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->body;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the error message from the OpenAI API response
|
||||||
|
*
|
||||||
|
* @param JoomlaResponse $response The response.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
protected function error(JoomlaResponse $response): string
|
||||||
|
{
|
||||||
|
// do we have a json string
|
||||||
|
if (isset($response->body) && JsonHelper::check($response->body))
|
||||||
|
{
|
||||||
|
$error = json_decode($response->body);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 'Invalid or empty response body.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if OpenAI returned an error object
|
||||||
|
if (isset($error->error))
|
||||||
|
{
|
||||||
|
// error object found, extract message and code
|
||||||
|
$errorMessage = isset($error->error->message) ? $error->error->message : 'Unknown error.';
|
||||||
|
$errorCode = isset($error->error->code) ? $error->error->code : 'Unknown error code.';
|
||||||
|
|
||||||
|
// return formatted error message
|
||||||
|
return 'OpenAI Error: ' . $errorMessage . ' Code: ' . $errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'No error information found in response.';
|
||||||
|
}
|
27
src/c464393e-7606-406e-8463-a86774590966/settings.json
Normal file
27
src/c464393e-7606-406e-8463-a86774590966/settings.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"add_head": "1",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "0",
|
||||||
|
"guid": "c464393e-7606-406e-8463-a86774590966",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Response",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Utilities.Response",
|
||||||
|
"type": "final class",
|
||||||
|
"use_selection": {
|
||||||
|
"use_selection0": {
|
||||||
|
"use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection1": {
|
||||||
|
"use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef",
|
||||||
|
"as": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Utilities.Response",
|
||||||
|
"description": "The Openai Response\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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\\CMS\\Http\\Response as JoomlaResponse;",
|
||||||
|
"composer": ""
|
||||||
|
}
|
62
src/c54c92da-2dd7-4136-81c9-1785f2fa0af5/README.md
Normal file
62
src/c54c92da-2dd7-4136-81c9-1785f2fa0af5/README.md
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class Chat (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Chat #Gold {
|
||||||
|
+ create(string $model, array $messages, ...) : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Chat::create
|
||||||
|
Create a chat completion with the OpenAI API.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/chat/create
|
||||||
|
Each item in the array is an object with the following:
|
||||||
|
- role (string) Required
|
||||||
|
The role of the author of this message.
|
||||||
|
One of system, user, or assistant.
|
||||||
|
- content (string) Required
|
||||||
|
The contents of the message.
|
||||||
|
- name (string) Optional
|
||||||
|
The name of the author of this message.
|
||||||
|
May contain a-z, A-Z, 0-9, and underscores,
|
||||||
|
with a maximum length of 64 characters.
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $model
|
||||||
|
array $messages
|
||||||
|
?int $maxTokens = null
|
||||||
|
?float $temperature = null
|
||||||
|
?float $topP = null
|
||||||
|
?int $n = null
|
||||||
|
?bool $stream = null
|
||||||
|
mixed|null $stop = null
|
||||||
|
?float $presencePenalty = null
|
||||||
|
?float $frequencyPenalty = null
|
||||||
|
?array $logitBias = null
|
||||||
|
?string $user = null
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
142
src/c54c92da-2dd7-4136-81c9-1785f2fa0af5/code.php
Normal file
142
src/c54c92da-2dd7-4136-81c9-1785f2fa0af5/code.php
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Openai\Abstraction\Api;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Chat
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class Chat extends Api
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a chat completion with the OpenAI API.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/chat/create
|
||||||
|
*
|
||||||
|
* @param string $model The model to use for completion.
|
||||||
|
* @param array $messages A list of messages describing the conversation so far.
|
||||||
|
*
|
||||||
|
* Each item in the array is an object with the following:
|
||||||
|
* - role (string) Required
|
||||||
|
* The role of the author of this message.
|
||||||
|
* One of system, user, or assistant.
|
||||||
|
* - content (string) Required
|
||||||
|
* The contents of the message.
|
||||||
|
* - name (string) Optional
|
||||||
|
* The name of the author of this message.
|
||||||
|
* May contain a-z, A-Z, 0-9, and underscores,
|
||||||
|
* with a maximum length of 64 characters.
|
||||||
|
*
|
||||||
|
* @param int|null $maxTokens Maximum number of tokens to generate (optional).
|
||||||
|
* @param float|null $temperature The sampling temperature to use (optional).
|
||||||
|
* @param float|null $topP The nucleus sampling parameter (optional).
|
||||||
|
* @param int|null $n The number of chat completion choices to generate (optional).
|
||||||
|
* @param bool|null $stream Partial message deltas (optional).
|
||||||
|
* @param mixed|null $stop Sequences where the API will stop generating tokens (optional).
|
||||||
|
* @param float|null $presencePenalty Penalty for new tokens based on whether they appear in the text (optional).
|
||||||
|
* @param float|null $frequencyPenalty Penalty for new tokens based on their frequency in the text (optional).
|
||||||
|
* @param array|null $logitBias Modify the likelihood of specified tokens appearing (optional).
|
||||||
|
* @param string|null $user A unique identifier representing the end-user (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function create(
|
||||||
|
string $model,
|
||||||
|
array $messages,
|
||||||
|
?int $maxTokens = null,
|
||||||
|
?float $temperature = null,
|
||||||
|
?float $topP = null,
|
||||||
|
?int $n = null,
|
||||||
|
?bool $stream = null,
|
||||||
|
$stop = null,
|
||||||
|
?float $presencePenalty = null,
|
||||||
|
?float $frequencyPenalty = null,
|
||||||
|
?array $logitBias = null,
|
||||||
|
?string $user = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/chat/completions";
|
||||||
|
|
||||||
|
// Set the request data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->model = $model;
|
||||||
|
$data->messages = $messages;
|
||||||
|
|
||||||
|
if ($maxTokens !== null)
|
||||||
|
{
|
||||||
|
$data->max_tokens = $maxTokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($temperature !== null)
|
||||||
|
{
|
||||||
|
$data->temperature = $temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($topP !== null)
|
||||||
|
{
|
||||||
|
$data->top_p = $topP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n !== null)
|
||||||
|
{
|
||||||
|
$data->n = $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($stream !== null)
|
||||||
|
{
|
||||||
|
$data->stream = $stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($stop !== null)
|
||||||
|
{
|
||||||
|
$data->stop = $stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($presencePenalty !== null)
|
||||||
|
{
|
||||||
|
$data->presence_penalty = $presencePenalty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($frequencyPenalty !== null)
|
||||||
|
{
|
||||||
|
$data->frequency_penalty = $frequencyPenalty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($logitBias !== null)
|
||||||
|
{
|
||||||
|
$data->logit_bias = new \stdClass();
|
||||||
|
foreach ($logitBias as $key => $val)
|
||||||
|
{
|
||||||
|
$data->logit_bias->$key = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user !== null)
|
||||||
|
{
|
||||||
|
$data->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
116
src/c54c92da-2dd7-4136-81c9-1785f2fa0af5/code.power
Normal file
116
src/c54c92da-2dd7-4136-81c9-1785f2fa0af5/code.power
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/**
|
||||||
|
* Create a chat completion with the OpenAI API.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/chat/create
|
||||||
|
*
|
||||||
|
* @param string $model The model to use for completion.
|
||||||
|
* @param array $messages A list of messages describing the conversation so far.
|
||||||
|
*
|
||||||
|
* Each item in the array is an object with the following:
|
||||||
|
* - role (string) Required
|
||||||
|
* The role of the author of this message.
|
||||||
|
* One of system, user, or assistant.
|
||||||
|
* - content (string) Required
|
||||||
|
* The contents of the message.
|
||||||
|
* - name (string) Optional
|
||||||
|
* The name of the author of this message.
|
||||||
|
* May contain a-z, A-Z, 0-9, and underscores,
|
||||||
|
* with a maximum length of 64 characters.
|
||||||
|
*
|
||||||
|
* @param int|null $maxTokens Maximum number of tokens to generate (optional).
|
||||||
|
* @param float|null $temperature The sampling temperature to use (optional).
|
||||||
|
* @param float|null $topP The nucleus sampling parameter (optional).
|
||||||
|
* @param int|null $n The number of chat completion choices to generate (optional).
|
||||||
|
* @param bool|null $stream Partial message deltas (optional).
|
||||||
|
* @param mixed|null $stop Sequences where the API will stop generating tokens (optional).
|
||||||
|
* @param float|null $presencePenalty Penalty for new tokens based on whether they appear in the text (optional).
|
||||||
|
* @param float|null $frequencyPenalty Penalty for new tokens based on their frequency in the text (optional).
|
||||||
|
* @param array|null $logitBias Modify the likelihood of specified tokens appearing (optional).
|
||||||
|
* @param string|null $user A unique identifier representing the end-user (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function create(
|
||||||
|
string $model,
|
||||||
|
array $messages,
|
||||||
|
?int $maxTokens = null,
|
||||||
|
?float $temperature = null,
|
||||||
|
?float $topP = null,
|
||||||
|
?int $n = null,
|
||||||
|
?bool $stream = null,
|
||||||
|
$stop = null,
|
||||||
|
?float $presencePenalty = null,
|
||||||
|
?float $frequencyPenalty = null,
|
||||||
|
?array $logitBias = null,
|
||||||
|
?string $user = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/chat/completions";
|
||||||
|
|
||||||
|
// Set the request data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->model = $model;
|
||||||
|
$data->messages = $messages;
|
||||||
|
|
||||||
|
if ($maxTokens !== null)
|
||||||
|
{
|
||||||
|
$data->max_tokens = $maxTokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($temperature !== null)
|
||||||
|
{
|
||||||
|
$data->temperature = $temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($topP !== null)
|
||||||
|
{
|
||||||
|
$data->top_p = $topP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($n !== null)
|
||||||
|
{
|
||||||
|
$data->n = $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($stream !== null)
|
||||||
|
{
|
||||||
|
$data->stream = $stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($stop !== null)
|
||||||
|
{
|
||||||
|
$data->stop = $stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($presencePenalty !== null)
|
||||||
|
{
|
||||||
|
$data->presence_penalty = $presencePenalty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($frequencyPenalty !== null)
|
||||||
|
{
|
||||||
|
$data->frequency_penalty = $frequencyPenalty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($logitBias !== null)
|
||||||
|
{
|
||||||
|
$data->logit_bias = new \stdClass();
|
||||||
|
foreach ($logitBias as $key => $val)
|
||||||
|
{
|
||||||
|
$data->logit_bias->$key = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user !== null)
|
||||||
|
{
|
||||||
|
$data->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
18
src/c54c92da-2dd7-4136-81c9-1785f2fa0af5/settings.json
Normal file
18
src/c54c92da-2dd7-4136-81c9-1785f2fa0af5/settings.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "585de711-2784-4f89-90bf-94a8a63366f1",
|
||||||
|
"guid": "c54c92da-2dd7-4136-81c9-1785f2fa0af5",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Chat",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Chat",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": null,
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Chat",
|
||||||
|
"description": "The Openai Chat\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
117
src/ccf3141a-929d-4466-b122-9ace2eea8d70/README.md
Normal file
117
src/ccf3141a-929d-4466-b122-9ace2eea8d70/README.md
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class Api (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai\Service**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Api #Gold {
|
||||||
|
+ register(Container $container) : void
|
||||||
|
+ getAudio(Container $container) : Audio
|
||||||
|
+ getChat(Container $container) : Chat
|
||||||
|
+ getCompletions(Container $container) : Completions
|
||||||
|
+ getEdits(Container $container) : Edits
|
||||||
|
+ getEmbeddings(Container $container) : Embeddings
|
||||||
|
+ getFiles(Container $container) : Files
|
||||||
|
+ getFineTunes(Container $container) : FineTunes
|
||||||
|
+ getImages(Container $container) : Images
|
||||||
|
+ getModels(Container $container) : Models
|
||||||
|
+ getModerate(Container $container) : Moderate
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Api::register
|
||||||
|
Registers the service provider with a DI container.
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Api::getAudio
|
||||||
|
Get the Audio class
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Audio
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Api::getChat
|
||||||
|
Get the Chat class
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Chat
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Api::getCompletions
|
||||||
|
Get the Completions class
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Completions
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Api::getEdits
|
||||||
|
Get the Edits class
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Edits
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Api::getEmbeddings
|
||||||
|
Get the Embeddings class
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Embeddings
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Api::getFiles
|
||||||
|
Get the Files class
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Files
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Api::getFineTunes
|
||||||
|
Get the FineTunes class
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: FineTunes
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Api::getImages
|
||||||
|
Get the Images class
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Images
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Api::getModels
|
||||||
|
Get the Models class
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Models
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Api::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)
|
||||||
|
|
247
src/ccf3141a-929d-4466-b122-9ace2eea8d70/code.php
Normal file
247
src/ccf3141a-929d-4466-b122-9ace2eea8d70/code.php
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai\Service;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\DI\Container;
|
||||||
|
use Joomla\DI\ServiceProviderInterface;
|
||||||
|
use VDM\Joomla\Openai\Audio;
|
||||||
|
use VDM\Joomla\Openai\Chat;
|
||||||
|
use VDM\Joomla\Openai\Completions;
|
||||||
|
use VDM\Joomla\Openai\Edits;
|
||||||
|
use VDM\Joomla\Openai\Embeddings;
|
||||||
|
use VDM\Joomla\Openai\Files;
|
||||||
|
use VDM\Joomla\Openai\FineTunes;
|
||||||
|
use VDM\Joomla\Openai\Images;
|
||||||
|
use VDM\Joomla\Openai\Models;
|
||||||
|
use VDM\Joomla\Openai\Moderate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Api Service
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class Api 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(Audio::class, 'Openai.Audio')
|
||||||
|
->share('Openai.Audio', [$this, 'getAudio'], true);
|
||||||
|
|
||||||
|
$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(Edits::class, 'Openai.Edits')
|
||||||
|
->share('Openai.Edits', [$this, 'getEdits'], true);
|
||||||
|
|
||||||
|
$container->alias(Embeddings::class, 'Openai.Embeddings')
|
||||||
|
->share('Openai.Embeddings', [$this, 'getEmbeddings'], true);
|
||||||
|
|
||||||
|
$container->alias(Files::class, 'Openai.Files')
|
||||||
|
->share('Openai.Files', [$this, 'getFiles'], true);
|
||||||
|
|
||||||
|
$container->alias(FineTunes::class, 'Openai.FineTunes')
|
||||||
|
->share('Openai.FineTunes', [$this, 'getFineTunes'], true);
|
||||||
|
|
||||||
|
$container->alias(Images::class, 'Openai.Images')
|
||||||
|
->share('Openai.Images', [$this, 'getImages'], 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 Audio class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Audio
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getAudio(Container $container): Audio
|
||||||
|
{
|
||||||
|
return new Audio(
|
||||||
|
$container->get('Openai.Utilities.Http'),
|
||||||
|
$container->get('Openai.Utilities.Uri'),
|
||||||
|
$container->get('Openai.Utilities.Response')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 Edits class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Edits
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getEdits(Container $container): Edits
|
||||||
|
{
|
||||||
|
return new Edits(
|
||||||
|
$container->get('Openai.Utilities.Http'),
|
||||||
|
$container->get('Openai.Utilities.Uri'),
|
||||||
|
$container->get('Openai.Utilities.Response')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Embeddings class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Embeddings
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getEmbeddings(Container $container): Embeddings
|
||||||
|
{
|
||||||
|
return new Embeddings(
|
||||||
|
$container->get('Openai.Utilities.Http'),
|
||||||
|
$container->get('Openai.Utilities.Uri'),
|
||||||
|
$container->get('Openai.Utilities.Response')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Files class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Files
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getFiles(Container $container): Files
|
||||||
|
{
|
||||||
|
return new Files(
|
||||||
|
$container->get('Openai.Utilities.Http'),
|
||||||
|
$container->get('Openai.Utilities.Uri'),
|
||||||
|
$container->get('Openai.Utilities.Response')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the FineTunes class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return FineTunes
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getFineTunes(Container $container): FineTunes
|
||||||
|
{
|
||||||
|
return new FineTunes(
|
||||||
|
$container->get('Openai.Utilities.Http'),
|
||||||
|
$container->get('Openai.Utilities.Uri'),
|
||||||
|
$container->get('Openai.Utilities.Response')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Images class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Images
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getImages(Container $container): Images
|
||||||
|
{
|
||||||
|
return new Images(
|
||||||
|
$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')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
210
src/ccf3141a-929d-4466-b122-9ace2eea8d70/code.power
Normal file
210
src/ccf3141a-929d-4466-b122-9ace2eea8d70/code.power
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
/**
|
||||||
|
* 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(Audio::class, 'Openai.Audio')
|
||||||
|
->share('Openai.Audio', [$this, 'getAudio'], true);
|
||||||
|
|
||||||
|
$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(Edits::class, 'Openai.Edits')
|
||||||
|
->share('Openai.Edits', [$this, 'getEdits'], true);
|
||||||
|
|
||||||
|
$container->alias(Embeddings::class, 'Openai.Embeddings')
|
||||||
|
->share('Openai.Embeddings', [$this, 'getEmbeddings'], true);
|
||||||
|
|
||||||
|
$container->alias(Files::class, 'Openai.Files')
|
||||||
|
->share('Openai.Files', [$this, 'getFiles'], true);
|
||||||
|
|
||||||
|
$container->alias(FineTunes::class, 'Openai.FineTunes')
|
||||||
|
->share('Openai.FineTunes', [$this, 'getFineTunes'], true);
|
||||||
|
|
||||||
|
$container->alias(Images::class, 'Openai.Images')
|
||||||
|
->share('Openai.Images', [$this, 'getImages'], 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 Audio class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Audio
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getAudio(Container $container): Audio
|
||||||
|
{
|
||||||
|
return new Audio(
|
||||||
|
$container->get('Openai.Utilities.Http'),
|
||||||
|
$container->get('Openai.Utilities.Uri'),
|
||||||
|
$container->get('Openai.Utilities.Response')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 Edits class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Edits
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getEdits(Container $container): Edits
|
||||||
|
{
|
||||||
|
return new Edits(
|
||||||
|
$container->get('Openai.Utilities.Http'),
|
||||||
|
$container->get('Openai.Utilities.Uri'),
|
||||||
|
$container->get('Openai.Utilities.Response')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Embeddings class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Embeddings
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getEmbeddings(Container $container): Embeddings
|
||||||
|
{
|
||||||
|
return new Embeddings(
|
||||||
|
$container->get('Openai.Utilities.Http'),
|
||||||
|
$container->get('Openai.Utilities.Uri'),
|
||||||
|
$container->get('Openai.Utilities.Response')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Files class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Files
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getFiles(Container $container): Files
|
||||||
|
{
|
||||||
|
return new Files(
|
||||||
|
$container->get('Openai.Utilities.Http'),
|
||||||
|
$container->get('Openai.Utilities.Uri'),
|
||||||
|
$container->get('Openai.Utilities.Response')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the FineTunes class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return FineTunes
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getFineTunes(Container $container): FineTunes
|
||||||
|
{
|
||||||
|
return new FineTunes(
|
||||||
|
$container->get('Openai.Utilities.Http'),
|
||||||
|
$container->get('Openai.Utilities.Uri'),
|
||||||
|
$container->get('Openai.Utilities.Response')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Images class
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Images
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function getImages(Container $container): Images
|
||||||
|
{
|
||||||
|
return new Images(
|
||||||
|
$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')
|
||||||
|
);
|
||||||
|
}
|
62
src/ccf3141a-929d-4466-b122-9ace2eea8d70/settings.json
Normal file
62
src/ccf3141a-929d-4466-b122-9ace2eea8d70/settings.json
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"add_head": "1",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "0",
|
||||||
|
"guid": "ccf3141a-929d-4466-b122-9ace2eea8d70",
|
||||||
|
"implements": [
|
||||||
|
"-1"
|
||||||
|
],
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Api",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Service.Api",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": {
|
||||||
|
"use_selection0": {
|
||||||
|
"use": "d76b2e22-c8dd-44b1-86b5-822768b317a3",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection1": {
|
||||||
|
"use": "c54c92da-2dd7-4136-81c9-1785f2fa0af5",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection2": {
|
||||||
|
"use": "796cca70-2577-4f8f-9a05-ac37db1f2f02",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection3": {
|
||||||
|
"use": "98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection4": {
|
||||||
|
"use": "df141f03-393f-4fa3-a568-8b65f7358b02",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection5": {
|
||||||
|
"use": "65dd022b-8f3a-46be-8930-0cae74b9834b",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection6": {
|
||||||
|
"use": "0e61da13-6429-426d-a6f9-f5723cd3b7b1",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection7": {
|
||||||
|
"use": "bb8973c1-261f-4b55-8f9b-9ee98843fced",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection8": {
|
||||||
|
"use": "08abd2df-1406-4939-a1a6-94d2fce3f043",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection9": {
|
||||||
|
"use": "34f2c249-64a7-4229-9592-77e58f6e994f",
|
||||||
|
"as": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Service.Api",
|
||||||
|
"description": "The Openai Api Service\r\n\r\n@since 3.2.0",
|
||||||
|
"implements_custom": "ServiceProviderInterface",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": ""
|
||||||
|
}
|
62
src/d76b2e22-c8dd-44b1-86b5-822768b317a3/README.md
Normal file
62
src/d76b2e22-c8dd-44b1-86b5-822768b317a3/README.md
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class Audio (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Audio #Gold {
|
||||||
|
+ transcribe(string $file, ?string $prompt = null, ...) : ?object
|
||||||
|
+ translation(string $file, ?string $prompt = null, ...) : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Audio::transcribe
|
||||||
|
Transcribes audio into the input language.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/audio/create
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $file
|
||||||
|
?string $prompt = null
|
||||||
|
?string $responseFormat = null
|
||||||
|
?float $temperature = null
|
||||||
|
?string $language = null
|
||||||
|
string $model = 'whisper-1'
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Audio::translation
|
||||||
|
Translate an audio file into English.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/audio/create
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $file
|
||||||
|
?string $prompt = null
|
||||||
|
?string $responseFormat = null
|
||||||
|
?float $temperature = null
|
||||||
|
string $model = 'whisper-1'
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
138
src/d76b2e22-c8dd-44b1-86b5-822768b317a3/code.php
Normal file
138
src/d76b2e22-c8dd-44b1-86b5-822768b317a3/code.php
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Openai\Abstraction\Api;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Audio
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class Audio extends Api
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transcribes audio into the input language.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/audio/create
|
||||||
|
*
|
||||||
|
* @param string $file The audio file to transcribe. Formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm (required).
|
||||||
|
* @param string|null $prompt An optional text to guide the model's style (optional).
|
||||||
|
* @param string|null $responseFormat The format of the transcript output. Options: json, text, srt, verbose_json, or vtt (optional).
|
||||||
|
* @param float|null $temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic (optional).
|
||||||
|
* @param string|null $language The language of the input audio (optional).
|
||||||
|
* @param string $model ID of the model to use. Only "whisper-1" is currently available.
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function transcribe(
|
||||||
|
string $file,
|
||||||
|
?string $prompt = null,
|
||||||
|
?string $responseFormat = null,
|
||||||
|
?float $temperature = null,
|
||||||
|
?string $language = null,
|
||||||
|
string $model = 'whisper-1'
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/audio/transcriptions";
|
||||||
|
|
||||||
|
// Set the request data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->file = $file;
|
||||||
|
|
||||||
|
if ($prompt !== null)
|
||||||
|
{
|
||||||
|
$data->prompt = $prompt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($responseFormat !== null)
|
||||||
|
{
|
||||||
|
$data->response_format = $responseFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($temperature !== null)
|
||||||
|
{
|
||||||
|
$data->temperature = $temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($language !== null)
|
||||||
|
{
|
||||||
|
$data->language = $language;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data->model = $model;
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data), ['Content-Type' => 'multipart/form-data']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translate an audio file into English.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/audio/create
|
||||||
|
*
|
||||||
|
* @param string $file The the audio file. Formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm (required).
|
||||||
|
* @param string|null $prompt An optional text to guide the model's style or continue a previous audio segment. The prompt should be in English (optional).
|
||||||
|
* @param string|null $responseFormat The format of the transcript output. Options: json, text, srt, verbose_json, or vtt (optional).
|
||||||
|
* @param float|null $temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic (optional).
|
||||||
|
* @param string $model ID of the model to use. Only "whisper-1" is currently available.
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function translation(
|
||||||
|
string $file,
|
||||||
|
?string $prompt = null,
|
||||||
|
?string $responseFormat = null,
|
||||||
|
?float $temperature = null,
|
||||||
|
string $model = 'whisper-1'
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/audio/translations";
|
||||||
|
|
||||||
|
// Set the data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->file = $file;
|
||||||
|
|
||||||
|
if ($prompt !== null)
|
||||||
|
{
|
||||||
|
$data->prompt = $prompt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($responseFormat !== null)
|
||||||
|
{
|
||||||
|
$data->response_format = $responseFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($temperature !== null)
|
||||||
|
{
|
||||||
|
$data->temperature = $temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data->model = $model;
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data), ['Content-Type' => 'multipart/form-data']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
112
src/d76b2e22-c8dd-44b1-86b5-822768b317a3/code.power
Normal file
112
src/d76b2e22-c8dd-44b1-86b5-822768b317a3/code.power
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/**
|
||||||
|
* Transcribes audio into the input language.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/audio/create
|
||||||
|
*
|
||||||
|
* @param string $file The audio file to transcribe. Formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm (required).
|
||||||
|
* @param string|null $prompt An optional text to guide the model's style (optional).
|
||||||
|
* @param string|null $responseFormat The format of the transcript output. Options: json, text, srt, verbose_json, or vtt (optional).
|
||||||
|
* @param float|null $temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic (optional).
|
||||||
|
* @param string|null $language The language of the input audio (optional).
|
||||||
|
* @param string $model ID of the model to use. Only "whisper-1" is currently available.
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function transcribe(
|
||||||
|
string $file,
|
||||||
|
?string $prompt = null,
|
||||||
|
?string $responseFormat = null,
|
||||||
|
?float $temperature = null,
|
||||||
|
?string $language = null,
|
||||||
|
string $model = 'whisper-1'
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/audio/transcriptions";
|
||||||
|
|
||||||
|
// Set the request data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->file = $file;
|
||||||
|
|
||||||
|
if ($prompt !== null)
|
||||||
|
{
|
||||||
|
$data->prompt = $prompt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($responseFormat !== null)
|
||||||
|
{
|
||||||
|
$data->response_format = $responseFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($temperature !== null)
|
||||||
|
{
|
||||||
|
$data->temperature = $temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($language !== null)
|
||||||
|
{
|
||||||
|
$data->language = $language;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data->model = $model;
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data), ['Content-Type' => 'multipart/form-data']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translate an audio file into English.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/audio/create
|
||||||
|
*
|
||||||
|
* @param string $file The the audio file. Formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm (required).
|
||||||
|
* @param string|null $prompt An optional text to guide the model's style or continue a previous audio segment. The prompt should be in English (optional).
|
||||||
|
* @param string|null $responseFormat The format of the transcript output. Options: json, text, srt, verbose_json, or vtt (optional).
|
||||||
|
* @param float|null $temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic (optional).
|
||||||
|
* @param string $model ID of the model to use. Only "whisper-1" is currently available.
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function translation(
|
||||||
|
string $file,
|
||||||
|
?string $prompt = null,
|
||||||
|
?string $responseFormat = null,
|
||||||
|
?float $temperature = null,
|
||||||
|
string $model = 'whisper-1'
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/audio/translations";
|
||||||
|
|
||||||
|
// Set the data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->file = $file;
|
||||||
|
|
||||||
|
if ($prompt !== null)
|
||||||
|
{
|
||||||
|
$data->prompt = $prompt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($responseFormat !== null)
|
||||||
|
{
|
||||||
|
$data->response_format = $responseFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($temperature !== null)
|
||||||
|
{
|
||||||
|
$data->temperature = $temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data->model = $model;
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data), ['Content-Type' => 'multipart/form-data']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
18
src/d76b2e22-c8dd-44b1-86b5-822768b317a3/settings.json
Normal file
18
src/d76b2e22-c8dd-44b1-86b5-822768b317a3/settings.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "585de711-2784-4f89-90bf-94a8a63366f1",
|
||||||
|
"guid": "d76b2e22-c8dd-44b1-86b5-822768b317a3",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Audio",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Audio",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": null,
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Audio",
|
||||||
|
"description": "The Openai Audio\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
54
src/d78bee89-6f7e-42b6-917e-17f05b238490/README.md
Normal file
54
src/d78bee89-6f7e-42b6-917e-17f05b238490/README.md
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# abstract class Factory (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
abstract Factory #Orange {
|
||||||
|
# static $container
|
||||||
|
+ {static} _(string $key) : Mixed
|
||||||
|
+ {static} getContainer() : Container
|
||||||
|
# {static} createContainer() : Container
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Factory::_
|
||||||
|
Get any class from the package container
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Factory::getContainer
|
||||||
|
Get the global package container
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: Container
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Factory::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)
|
||||||
|
|
78
src/d78bee89-6f7e-42b6-917e-17f05b238490/code.php
Normal file
78
src/d78bee89-6f7e-42b6-917e-17f05b238490/code.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\DI\Container;
|
||||||
|
use VDM\Joomla\Openai\Service\Api;
|
||||||
|
use VDM\Joomla\Openai\Service\Utilities;
|
||||||
|
use VDM\Joomla\Componentbuilder\Interfaces\FactoryInterface;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Openai Factory
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
abstract class Factory 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
49
src/d78bee89-6f7e-42b6-917e-17f05b238490/code.power
Normal file
49
src/d78bee89-6f7e-42b6-917e-17f05b238490/code.power
Normal file
@ -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());
|
||||||
|
}
|
29
src/d78bee89-6f7e-42b6-917e-17f05b238490/settings.json
Normal file
29
src/d78bee89-6f7e-42b6-917e-17f05b238490/settings.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"add_head": "1",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "0",
|
||||||
|
"guid": "d78bee89-6f7e-42b6-917e-17f05b238490",
|
||||||
|
"implements": [
|
||||||
|
"caf33c5d-858c-4f9a-894f-ab302ec5445a"
|
||||||
|
],
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Factory",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Openai.Factory",
|
||||||
|
"type": "abstract class",
|
||||||
|
"use_selection": {
|
||||||
|
"use_selection0": {
|
||||||
|
"use": "ccf3141a-929d-4466-b122-9ace2eea8d70",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection1": {
|
||||||
|
"use": "07858e1f-5698-4227-8941-03dc93557938",
|
||||||
|
"as": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Factory",
|
||||||
|
"description": "Openai Factory\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": ""
|
||||||
|
}
|
43
src/df141f03-393f-4fa3-a568-8b65f7358b02/README.md
Normal file
43
src/df141f03-393f-4fa3-a568-8b65f7358b02/README.md
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class Embeddings (Details)
|
||||||
|
> namespace: **VDM\Joomla\Openai**
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Embeddings #Gold {
|
||||||
|
+ create(string $model, mixed $input, ...) : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Embeddings::create
|
||||||
|
Create an embedding of a given input.
|
||||||
|
API Ref: https://platform.openai.com/docs/api-reference/embeddings
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: ?object
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $model
|
||||||
|
mixed $input
|
||||||
|
?string $user = null
|
||||||
|
end note
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
```
|
||||||
|
██╗ ██████╗██████╗
|
||||||
|
██║██╔════╝██╔══██╗
|
||||||
|
██║██║ ██████╔╝
|
||||||
|
██ ██║██║ ██╔══██╗
|
||||||
|
╚█████╔╝╚██████╗██████╔╝
|
||||||
|
╚════╝ ╚═════╝╚═════╝
|
||||||
|
```
|
||||||
|
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
|
|
63
src/df141f03-393f-4fa3-a568-8b65f7358b02/code.php
Normal file
63
src/df141f03-393f-4fa3-a568-8b65f7358b02/code.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @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\Openai;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Openai\Abstraction\Api;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Openai Embeddings
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class Embeddings extends Api
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create an embedding of a given input.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/embeddings
|
||||||
|
*
|
||||||
|
* @param string $model The ID of the model to use.
|
||||||
|
* @param mixed $input The input text to get embeddings for, encoded as a string or array of tokens.
|
||||||
|
* @param string|null $user A unique identifier representing your end-user (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function create(
|
||||||
|
string $model,
|
||||||
|
$input,
|
||||||
|
?string $user = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/embeddings";
|
||||||
|
|
||||||
|
// Set the request data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->model = $model;
|
||||||
|
$data->input = $input;
|
||||||
|
|
||||||
|
if ($user !== null)
|
||||||
|
{
|
||||||
|
$data->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
37
src/df141f03-393f-4fa3-a568-8b65f7358b02/code.power
Normal file
37
src/df141f03-393f-4fa3-a568-8b65f7358b02/code.power
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Create an embedding of a given input.
|
||||||
|
* API Ref: https://platform.openai.com/docs/api-reference/embeddings
|
||||||
|
*
|
||||||
|
* @param string $model The ID of the model to use.
|
||||||
|
* @param mixed $input The input text to get embeddings for, encoded as a string or array of tokens.
|
||||||
|
* @param string|null $user A unique identifier representing your end-user (optional).
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 3.2.0
|
||||||
|
**/
|
||||||
|
public function create(
|
||||||
|
string $model,
|
||||||
|
$input,
|
||||||
|
?string $user = null
|
||||||
|
): ?object
|
||||||
|
{
|
||||||
|
// Build the request path.
|
||||||
|
$path = "/embeddings";
|
||||||
|
|
||||||
|
// Set the request data.
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->model = $model;
|
||||||
|
$data->input = $input;
|
||||||
|
|
||||||
|
if ($user !== null)
|
||||||
|
{
|
||||||
|
$data->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the post request.
|
||||||
|
return $this->response->get(
|
||||||
|
$this->http->post(
|
||||||
|
$this->uri->get($path), json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
18
src/df141f03-393f-4fa3-a568-8b65f7358b02/settings.json
Normal file
18
src/df141f03-393f-4fa3-a568-8b65f7358b02/settings.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "585de711-2784-4f89-90bf-94a8a63366f1",
|
||||||
|
"guid": "df141f03-393f-4fa3-a568-8b65f7358b02",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Embeddings",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "Joomla.Openai.Embeddings",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": null,
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Embeddings",
|
||||||
|
"description": "The Openai Embeddings\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
189
super-powers.json
Normal file
189
super-powers.json
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
{
|
||||||
|
"4c58b254-aea5-40aa-b54d-9586a1690451": {
|
||||||
|
"name": "Http",
|
||||||
|
"type": "final class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Utilities",
|
||||||
|
"code": "src\/4c58b254-aea5-40aa-b54d-9586a1690451\/code.php",
|
||||||
|
"power": "src\/4c58b254-aea5-40aa-b54d-9586a1690451\/code.power",
|
||||||
|
"settings": "src\/4c58b254-aea5-40aa-b54d-9586a1690451\/settings.json",
|
||||||
|
"path": "src\/4c58b254-aea5-40aa-b54d-9586a1690451",
|
||||||
|
"spk": "Super__4c58b254_aea5_40aa_b54d_9586a1690451__Power",
|
||||||
|
"guid": "4c58b254-aea5-40aa-b54d-9586a1690451"
|
||||||
|
},
|
||||||
|
"13ef84f4-25b0-43dd-a9f6-0722abf220c1": {
|
||||||
|
"name": "Uri",
|
||||||
|
"type": "final class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Utilities",
|
||||||
|
"code": "src\/13ef84f4-25b0-43dd-a9f6-0722abf220c1\/code.php",
|
||||||
|
"power": "src\/13ef84f4-25b0-43dd-a9f6-0722abf220c1\/code.power",
|
||||||
|
"settings": "src\/13ef84f4-25b0-43dd-a9f6-0722abf220c1\/settings.json",
|
||||||
|
"path": "src\/13ef84f4-25b0-43dd-a9f6-0722abf220c1",
|
||||||
|
"spk": "Super__13ef84f4_25b0_43dd_a9f6_0722abf220c1__Power",
|
||||||
|
"guid": "13ef84f4-25b0-43dd-a9f6-0722abf220c1"
|
||||||
|
},
|
||||||
|
"c464393e-7606-406e-8463-a86774590966": {
|
||||||
|
"name": "Response",
|
||||||
|
"type": "final class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Utilities",
|
||||||
|
"code": "src\/c464393e-7606-406e-8463-a86774590966\/code.php",
|
||||||
|
"power": "src\/c464393e-7606-406e-8463-a86774590966\/code.power",
|
||||||
|
"settings": "src\/c464393e-7606-406e-8463-a86774590966\/settings.json",
|
||||||
|
"path": "src\/c464393e-7606-406e-8463-a86774590966",
|
||||||
|
"spk": "Super__c464393e_7606_406e_8463_a86774590966__Power",
|
||||||
|
"guid": "c464393e-7606-406e-8463-a86774590966"
|
||||||
|
},
|
||||||
|
"585de711-2784-4f89-90bf-94a8a63366f1": {
|
||||||
|
"name": "Api",
|
||||||
|
"type": "abstract class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Abstraction",
|
||||||
|
"code": "src\/585de711-2784-4f89-90bf-94a8a63366f1\/code.php",
|
||||||
|
"power": "src\/585de711-2784-4f89-90bf-94a8a63366f1\/code.power",
|
||||||
|
"settings": "src\/585de711-2784-4f89-90bf-94a8a63366f1\/settings.json",
|
||||||
|
"path": "src\/585de711-2784-4f89-90bf-94a8a63366f1",
|
||||||
|
"spk": "Super__585de711_2784_4f89_90bf_94a8a63366f1__Power",
|
||||||
|
"guid": "585de711-2784-4f89-90bf-94a8a63366f1"
|
||||||
|
},
|
||||||
|
"d76b2e22-c8dd-44b1-86b5-822768b317a3": {
|
||||||
|
"name": "Audio",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai",
|
||||||
|
"code": "src\/d76b2e22-c8dd-44b1-86b5-822768b317a3\/code.php",
|
||||||
|
"power": "src\/d76b2e22-c8dd-44b1-86b5-822768b317a3\/code.power",
|
||||||
|
"settings": "src\/d76b2e22-c8dd-44b1-86b5-822768b317a3\/settings.json",
|
||||||
|
"path": "src\/d76b2e22-c8dd-44b1-86b5-822768b317a3",
|
||||||
|
"spk": "Super__d76b2e22_c8dd_44b1_86b5_822768b317a3__Power",
|
||||||
|
"guid": "d76b2e22-c8dd-44b1-86b5-822768b317a3"
|
||||||
|
},
|
||||||
|
"c54c92da-2dd7-4136-81c9-1785f2fa0af5": {
|
||||||
|
"name": "Chat",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai",
|
||||||
|
"code": "src\/c54c92da-2dd7-4136-81c9-1785f2fa0af5\/code.php",
|
||||||
|
"power": "src\/c54c92da-2dd7-4136-81c9-1785f2fa0af5\/code.power",
|
||||||
|
"settings": "src\/c54c92da-2dd7-4136-81c9-1785f2fa0af5\/settings.json",
|
||||||
|
"path": "src\/c54c92da-2dd7-4136-81c9-1785f2fa0af5",
|
||||||
|
"spk": "Super__c54c92da_2dd7_4136_81c9_1785f2fa0af5__Power",
|
||||||
|
"guid": "c54c92da-2dd7-4136-81c9-1785f2fa0af5"
|
||||||
|
},
|
||||||
|
"796cca70-2577-4f8f-9a05-ac37db1f2f02": {
|
||||||
|
"name": "Completions",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai",
|
||||||
|
"code": "src\/796cca70-2577-4f8f-9a05-ac37db1f2f02\/code.php",
|
||||||
|
"power": "src\/796cca70-2577-4f8f-9a05-ac37db1f2f02\/code.power",
|
||||||
|
"settings": "src\/796cca70-2577-4f8f-9a05-ac37db1f2f02\/settings.json",
|
||||||
|
"path": "src\/796cca70-2577-4f8f-9a05-ac37db1f2f02",
|
||||||
|
"spk": "Super__796cca70_2577_4f8f_9a05_ac37db1f2f02__Power",
|
||||||
|
"guid": "796cca70-2577-4f8f-9a05-ac37db1f2f02"
|
||||||
|
},
|
||||||
|
"98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8": {
|
||||||
|
"name": "Edits",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai",
|
||||||
|
"code": "src\/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8\/code.php",
|
||||||
|
"power": "src\/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8\/code.power",
|
||||||
|
"settings": "src\/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8\/settings.json",
|
||||||
|
"path": "src\/98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8",
|
||||||
|
"spk": "Super__98e59bdf_81a2_41ef_a3a6_6a88a7cc53c8__Power",
|
||||||
|
"guid": "98e59bdf-81a2-41ef-a3a6-6a88a7cc53c8"
|
||||||
|
},
|
||||||
|
"df141f03-393f-4fa3-a568-8b65f7358b02": {
|
||||||
|
"name": "Embeddings",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai",
|
||||||
|
"code": "src\/df141f03-393f-4fa3-a568-8b65f7358b02\/code.php",
|
||||||
|
"power": "src\/df141f03-393f-4fa3-a568-8b65f7358b02\/code.power",
|
||||||
|
"settings": "src\/df141f03-393f-4fa3-a568-8b65f7358b02\/settings.json",
|
||||||
|
"path": "src\/df141f03-393f-4fa3-a568-8b65f7358b02",
|
||||||
|
"spk": "Super__df141f03_393f_4fa3_a568_8b65f7358b02__Power",
|
||||||
|
"guid": "df141f03-393f-4fa3-a568-8b65f7358b02"
|
||||||
|
},
|
||||||
|
"65dd022b-8f3a-46be-8930-0cae74b9834b": {
|
||||||
|
"name": "Files",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai",
|
||||||
|
"code": "src\/65dd022b-8f3a-46be-8930-0cae74b9834b\/code.php",
|
||||||
|
"power": "src\/65dd022b-8f3a-46be-8930-0cae74b9834b\/code.power",
|
||||||
|
"settings": "src\/65dd022b-8f3a-46be-8930-0cae74b9834b\/settings.json",
|
||||||
|
"path": "src\/65dd022b-8f3a-46be-8930-0cae74b9834b",
|
||||||
|
"spk": "Super__65dd022b_8f3a_46be_8930_0cae74b9834b__Power",
|
||||||
|
"guid": "65dd022b-8f3a-46be-8930-0cae74b9834b"
|
||||||
|
},
|
||||||
|
"0e61da13-6429-426d-a6f9-f5723cd3b7b1": {
|
||||||
|
"name": "FineTunes",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai",
|
||||||
|
"code": "src\/0e61da13-6429-426d-a6f9-f5723cd3b7b1\/code.php",
|
||||||
|
"power": "src\/0e61da13-6429-426d-a6f9-f5723cd3b7b1\/code.power",
|
||||||
|
"settings": "src\/0e61da13-6429-426d-a6f9-f5723cd3b7b1\/settings.json",
|
||||||
|
"path": "src\/0e61da13-6429-426d-a6f9-f5723cd3b7b1",
|
||||||
|
"spk": "Super__0e61da13_6429_426d_a6f9_f5723cd3b7b1__Power",
|
||||||
|
"guid": "0e61da13-6429-426d-a6f9-f5723cd3b7b1"
|
||||||
|
},
|
||||||
|
"bb8973c1-261f-4b55-8f9b-9ee98843fced": {
|
||||||
|
"name": "Images",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai",
|
||||||
|
"code": "src\/bb8973c1-261f-4b55-8f9b-9ee98843fced\/code.php",
|
||||||
|
"power": "src\/bb8973c1-261f-4b55-8f9b-9ee98843fced\/code.power",
|
||||||
|
"settings": "src\/bb8973c1-261f-4b55-8f9b-9ee98843fced\/settings.json",
|
||||||
|
"path": "src\/bb8973c1-261f-4b55-8f9b-9ee98843fced",
|
||||||
|
"spk": "Super__bb8973c1_261f_4b55_8f9b_9ee98843fced__Power",
|
||||||
|
"guid": "bb8973c1-261f-4b55-8f9b-9ee98843fced"
|
||||||
|
},
|
||||||
|
"08abd2df-1406-4939-a1a6-94d2fce3f043": {
|
||||||
|
"name": "Models",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai",
|
||||||
|
"code": "src\/08abd2df-1406-4939-a1a6-94d2fce3f043\/code.php",
|
||||||
|
"power": "src\/08abd2df-1406-4939-a1a6-94d2fce3f043\/code.power",
|
||||||
|
"settings": "src\/08abd2df-1406-4939-a1a6-94d2fce3f043\/settings.json",
|
||||||
|
"path": "src\/08abd2df-1406-4939-a1a6-94d2fce3f043",
|
||||||
|
"spk": "Super__08abd2df_1406_4939_a1a6_94d2fce3f043__Power",
|
||||||
|
"guid": "08abd2df-1406-4939-a1a6-94d2fce3f043"
|
||||||
|
},
|
||||||
|
"34f2c249-64a7-4229-9592-77e58f6e994f": {
|
||||||
|
"name": "Moderate",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai",
|
||||||
|
"code": "src\/34f2c249-64a7-4229-9592-77e58f6e994f\/code.php",
|
||||||
|
"power": "src\/34f2c249-64a7-4229-9592-77e58f6e994f\/code.power",
|
||||||
|
"settings": "src\/34f2c249-64a7-4229-9592-77e58f6e994f\/settings.json",
|
||||||
|
"path": "src\/34f2c249-64a7-4229-9592-77e58f6e994f",
|
||||||
|
"spk": "Super__34f2c249_64a7_4229_9592_77e58f6e994f__Power",
|
||||||
|
"guid": "34f2c249-64a7-4229-9592-77e58f6e994f"
|
||||||
|
},
|
||||||
|
"ccf3141a-929d-4466-b122-9ace2eea8d70": {
|
||||||
|
"name": "Api",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Service",
|
||||||
|
"code": "src\/ccf3141a-929d-4466-b122-9ace2eea8d70\/code.php",
|
||||||
|
"power": "src\/ccf3141a-929d-4466-b122-9ace2eea8d70\/code.power",
|
||||||
|
"settings": "src\/ccf3141a-929d-4466-b122-9ace2eea8d70\/settings.json",
|
||||||
|
"path": "src\/ccf3141a-929d-4466-b122-9ace2eea8d70",
|
||||||
|
"spk": "Super__ccf3141a_929d_4466_b122_9ace2eea8d70__Power",
|
||||||
|
"guid": "ccf3141a-929d-4466-b122-9ace2eea8d70"
|
||||||
|
},
|
||||||
|
"07858e1f-5698-4227-8941-03dc93557938": {
|
||||||
|
"name": "Utilities",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai\\Service",
|
||||||
|
"code": "src\/07858e1f-5698-4227-8941-03dc93557938\/code.php",
|
||||||
|
"power": "src\/07858e1f-5698-4227-8941-03dc93557938\/code.power",
|
||||||
|
"settings": "src\/07858e1f-5698-4227-8941-03dc93557938\/settings.json",
|
||||||
|
"path": "src\/07858e1f-5698-4227-8941-03dc93557938",
|
||||||
|
"spk": "Super__07858e1f_5698_4227_8941_03dc93557938__Power",
|
||||||
|
"guid": "07858e1f-5698-4227-8941-03dc93557938"
|
||||||
|
},
|
||||||
|
"d78bee89-6f7e-42b6-917e-17f05b238490": {
|
||||||
|
"name": "Factory",
|
||||||
|
"type": "abstract class",
|
||||||
|
"namespace": "VDM\\Joomla\\Openai",
|
||||||
|
"code": "src\/d78bee89-6f7e-42b6-917e-17f05b238490\/code.php",
|
||||||
|
"power": "src\/d78bee89-6f7e-42b6-917e-17f05b238490\/code.power",
|
||||||
|
"settings": "src\/d78bee89-6f7e-42b6-917e-17f05b238490\/settings.json",
|
||||||
|
"path": "src\/d78bee89-6f7e-42b6-917e-17f05b238490",
|
||||||
|
"spk": "Super__d78bee89_6f7e_42b6_917e_17f05b238490__Power",
|
||||||
|
"guid": "d78bee89-6f7e-42b6-917e-17f05b238490"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user