FacturaScripts

OpenAi extends OpenAi
in package

Class created by Core/Base/PluginDeploy

Tags
author

FacturaScripts [email protected]

Table of Contents

AUDIO_SPEECH_URL  = 'https://api.openai.com/v1/audio/speech'
CHAT_URL  = 'https://api.openai.com/v1/chat/completions'
FILES_URL  = 'https://api.openai.com/v1/files'
IMAGES_URL  = 'https://api.openai.com/v1/images/generations'
THREADS_URL  = 'https://api.openai.com/v1/threads'
VECTOR_URL  = 'https://api.openai.com/v1/vector_stores'
$api_key  : string
$timeout  : int
$total_tokens  : int
__construct()  : mixed
audio()  : string
audioHD()  : string
chat()  : string
chatGpt35turbo()  : string
chatGpt4()  : string
chatGpt4o()  : string
chatGpt4turbo()  : string
dalle2()  : string
dalle3()  : string
fileDelete()  : bool
fileList()  : array<string|int, mixed>
fileRead()  : array<string|int, mixed>
fileUpload()  : array<string|int, mixed>
getTotalTokens()  : int
image()  : string
init()  : self
setSystemMessage()  : self
setTimeout()  : self
setUserMessage()  : self
threadCreate()  : array<string|int, mixed>
threadMessageCreate()  : array<string|int, mixed>
threadMessages()  : array<string|int, mixed>
threadRun()  : array<string|int, mixed>
threadRunRead()  : array<string|int, mixed>
vectorFile()  : array<string|int, mixed>
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'

FILES_URL

public mixed FILES_URL = 'https://api.openai.com/v1/files'

IMAGES_URL

public mixed IMAGES_URL = 'https://api.openai.com/v1/images/generations'

THREADS_URL

public mixed THREADS_URL = 'https://api.openai.com/v1/threads'

VECTOR_URL

public mixed VECTOR_URL = 'https://api.openai.com/v1/vector_stores'

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-4o-mini' ]) : string
Parameters
$messages : array<string|int, mixed>
$user : string = ''
$model : string = 'gpt-4o-mini'
Return values
string

chatGpt35turbo()

public chatGpt35turbo(array<string|int, mixed> $messages[, string $user = '' ]) : string
Parameters
$messages : array<string|int, mixed>
$user : string = ''
Tags
deprecated

since 2024.9 and replaced with chat()

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

chatGpt4o()

public chatGpt4o(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

fileDelete()

public fileDelete(string $id_file) : bool
Parameters
$id_file : string
Return values
bool

fileList()

public fileList() : array<string|int, mixed>
Return values
array<string|int, mixed>

fileRead()

public fileRead(string $id_file) : array<string|int, mixed>
Parameters
$id_file : string
Return values
array<string|int, mixed>

fileUpload()

public fileUpload(CURLFile $file[, string $purpose = 'assistants' ]) : array<string|int, mixed>
Parameters
$file : CURLFile
$purpose : string = 'assistants'
Return values
array<string|int, mixed>

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

threadCreate()

public threadCreate() : array<string|int, mixed>
Return values
array<string|int, mixed>

threadMessageCreate()

public threadMessageCreate(array<string|int, mixed> $message, string $id_thread) : array<string|int, mixed>
Parameters
$message : array<string|int, mixed>
$id_thread : string
Return values
array<string|int, mixed>

threadMessages()

public threadMessages(string $id_thread[, string $id_run = '' ]) : array<string|int, mixed>
Parameters
$id_thread : string
$id_run : string = ''
Return values
array<string|int, mixed>

threadRun()

public threadRun(string $id_thread, string $id_assistant) : array<string|int, mixed>
Parameters
$id_thread : string
$id_assistant : string
Return values
array<string|int, mixed>

threadRunRead()

public threadRunRead(string $id_thread, string $id_run) : array<string|int, mixed>
Parameters
$id_thread : string
$id_run : string
Return values
array<string|int, mixed>

vectorFile()

public vectorFile(string $id_vector, string $id_file) : array<string|int, mixed>
Parameters
$id_vector : string
$id_file : string
Return values
array<string|int, mixed>

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
Return values
string

Search results