OpenAi
extends OpenAi
in package
Class created by Core/Base/PluginDeploy
Tags
Table of Contents
- AUDIO_SPEECH_URL = 'https://api.openai.com/v1/audio/speech'
- CHAT_URL = 'https://api.openai.com/v1/chat/completions'
- IMAGES_URL = 'https://api.openai.com/v1/images/generations'
- $api_key : string
- $timeout : int
- $total_tokens : int
- __construct() : mixed
- audio() : string
- audioHD() : string
- chat() : string
- chatGpt35turbo() : string
- chatGpt4() : string
- chatGpt4turbo() : string
- dalle2() : string
- dalle3() : string
- getTotalTokens() : int
- image() : string
- init() : self
- setSystemMessage() : self
- setTimeout() : self
- setUserMessage() : self
- getDalleSize() : string
- imageResize() : string
Constants
AUDIO_SPEECH_URL
public
mixed
AUDIO_SPEECH_URL
= 'https://api.openai.com/v1/audio/speech'
CHAT_URL
public
mixed
CHAT_URL
= 'https://api.openai.com/v1/chat/completions'
IMAGES_URL
public
mixed
IMAGES_URL
= 'https://api.openai.com/v1/images/generations'
Properties
$api_key
protected
string
$api_key
$timeout
protected
int
$timeout
= 60
$total_tokens
protected
int
$total_tokens
= 0
Methods
__construct()
public
__construct(string $api_key) : mixed
Parameters
- $api_key : string
Return values
mixed —audio()
public
audio(string $input[, string $voice = 'alloy' ][, string $format = 'mp3' ][, string $model = 'tts-1' ]) : string
Parameters
- $input : string
- $voice : string = 'alloy'
- $format : string = 'mp3'
- $model : string = 'tts-1'
Return values
string —audioHD()
public
audioHD(string $input[, string $voice = 'alloy' ][, string $format = 'mp3' ]) : string
Parameters
- $input : string
- $voice : string = 'alloy'
- $format : string = 'mp3'
Return values
string —chat()
public
chat(array<string|int, mixed> $messages[, string $user = '' ][, string $model = 'gpt-3.5-turbo' ]) : string
Parameters
- $messages : array<string|int, mixed>
- $user : string = ''
- $model : string = 'gpt-3.5-turbo'
Return values
string —chatGpt35turbo()
public
chatGpt35turbo(array<string|int, mixed> $messages[, string $user = '' ]) : string
Parameters
- $messages : array<string|int, mixed>
- $user : string = ''
Return values
string —chatGpt4()
public
chatGpt4(array<string|int, mixed> $messages[, string $user = '' ]) : string
Parameters
- $messages : array<string|int, mixed>
- $user : string = ''
Return values
string —chatGpt4turbo()
public
chatGpt4turbo(array<string|int, mixed> $messages[, string $user = '' ]) : string
Parameters
- $messages : array<string|int, mixed>
- $user : string = ''
Return values
string —dalle2()
public
dalle2(string $prompt[, int $width = 256 ][, int $height = 256 ][, mixed $count = 1 ]) : string
Parameters
- $prompt : string
- $width : int = 256
- $height : int = 256
- $count : mixed = 1
Return values
string —dalle3()
public
dalle3(string $prompt[, int $width = 1024 ][, int $height = 1024 ][, mixed $count = 1 ]) : string
Parameters
- $prompt : string
- $width : int = 1024
- $height : int = 1024
- $count : mixed = 1
Return values
string —getTotalTokens()
public
getTotalTokens() : int
Return values
int —image()
public
image(string $prompt[, int $width = 256 ][, int $height = 256 ][, mixed $count = 1 ][, string $model = 'dall-e-2' ]) : string
Parameters
- $prompt : string
- $width : int = 256
- $height : int = 256
- $count : mixed = 1
- $model : string = 'dall-e-2'
Return values
string —init()
public
static init(string $api_key) : self
Parameters
- $api_key : string
Return values
self —setSystemMessage()
public
setSystemMessage(array<string|int, mixed> &$messages, string $message) : self
Parameters
- $messages : array<string|int, mixed>
- $message : string
Return values
self —setTimeout()
public
setTimeout(int $timeout) : self
Parameters
- $timeout : int
Return values
self —setUserMessage()
public
setUserMessage(array<string|int, mixed> &$messages, string $message) : self
Parameters
- $messages : array<string|int, mixed>
- $message : string
Return values
self —getDalleSize()
private
getDalleSize(bool &$resize, string $model, int $width, int $height) : string
Parameters
- $resize : bool
- $model : string
- $width : int
- $height : int
Return values
string —imageResize()
private
imageResize(string $filePath, int $width, int $height) : string
Parameters
- $filePath : string
- $width : int
- $height : int