dolibarr 24.0.0-beta
Ai Class Reference

Class for AI feature. More...

Collaboration diagram for Ai:

Public Member Functions

 __construct ($db)
 Constructor.
 
 getApiService ()
 get API Service
 
 generateContent ($instructions, $model='auto', $function='textgeneration', $format='', $moreheaders=array(), $moreendpoint='')
 Generate the response of an AI prompt.
 

Detailed Description

Class for AI feature.

Definition at line 35 of file ai.class.php.

Constructor & Destructor Documentation

◆ __construct()

Ai::__construct ( $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 73 of file ai.class.php.

References getDolGlobalString().

Member Function Documentation

◆ generateContent()

Ai::generateContent ( $instructions,
$model = 'auto',
$function = 'textgeneration',
$format = '',
$moreheaders = array(),
$moreendpoint = '' )

Generate the response of an AI prompt.

Parameters
string|array<mixed,mixed>$instructions String instruction to generate content (or file path) or array of payload or ID of file with function threads
string$modelModel name ('gpt-4.1-turbo', 'gpt-4.1', 'dall-e-3', ...)
string$functionCode of the feature we want to use ('textgeneration', 'transcription', 'audiogeneration', 'imagegeneration', 'translation', 'docparsing')
string$formatFormat for output ('', 'html', ...)
array<string,string>$moreheaders More headers
string$moreendpointAdd a part to endpoint url
Returns
string|array{error:bool,message:string,code?:int,curl_error_no?:int,format?:string,service?:string,function?:string} $response Text or array if error

Definition at line 103 of file ai.class.php.

References dol_nl2br(), dol_now(), dol_print_date(), dol_syslog(), dol_textishtml(), dol_trunc(), dolChmod(), getDolGlobalString(), getListOfAIServices(), and getURLContent().

◆ getApiService()

Ai::getApiService ( )

get API Service

Returns
string API service

Definition at line 87 of file ai.class.php.


The documentation for this class was generated from the following file: