Release of v5.0.0-alpha8
Add power path override option on component level. Fix the sql build feature. #1032.
This commit is contained in:
60
libraries/vendor_jcb/VDM.Joomla.Openai/src/Moderate.php
Normal file
60
libraries/vendor_jcb/VDM.Joomla.Openai/src/Moderate.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)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user