@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | // Parameters |
46 | 46 | $action = GETPOST('action', 'aZ09'); |
47 | 47 | $backtopage = GETPOST('backtopage', 'alpha'); |
48 | -$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php |
|
48 | +$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php |
|
49 | 49 | |
50 | 50 | if (empty($action)) { |
51 | 51 | $action = 'edit'; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | // List all available features |
73 | 73 | $arrayofaifeatures = getListOfAIFeatures(); |
74 | 74 | |
75 | -$item = $formSetup->newItem('AI_API_SERVICE'); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
75 | +$item = $formSetup->newItem('AI_API_SERVICE'); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
76 | 76 | $item->setAsSelect($arrayofai); |
77 | 77 | $item->cssClass = 'minwidth150'; |
78 | 78 | |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | $item->defaultFieldValue = ''; |
84 | 84 | $item->cssClass = 'minwidth500';*/ |
85 | 85 | |
86 | - $item = $formSetup->newItem('AI_API_'.strtoupper($ia).'_KEY')->setAsSecureKey(); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
86 | + $item = $formSetup->newItem('AI_API_'.strtoupper($ia).'_KEY')->setAsSecureKey(); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
87 | 87 | $item->nameText = $langs->trans("AI_API_KEY").' ('.$ialabel.')'; |
88 | 88 | $item->defaultFieldValue = ''; |
89 | 89 | $item->fieldParams['hideGenerateButton'] = 1; |
90 | 90 | $item->fieldParams['trClass'] = 'iaservice '.$ia; |
91 | 91 | $item->cssClass = 'minwidth500 text-security input'.$ia; |
92 | 92 | |
93 | - $item = $formSetup->newItem('AI_API_'.strtoupper($ia).'_URL'); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
93 | + $item = $formSetup->newItem('AI_API_'.strtoupper($ia).'_URL'); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
94 | 94 | $item->nameText = $langs->trans("AI_API_URL").' ('.$ialabel.')'; |
95 | 95 | $item->defaultFieldValue = ''; |
96 | 96 | $item->fieldParams['trClass'] = 'iaservice iaurl '.$ia; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $out = ''; |
211 | 211 | |
212 | 212 | //if ($functioncode) { |
213 | - $key = 'textgenerationother'; // The HTML ID of field to fill |
|
213 | + $key = 'textgenerationother'; // The HTML ID of field to fill |
|
214 | 214 | |
215 | 215 | $labeloffeature = empty($arrayofaifeatures[$key]['label']) ? 'Undefined' : $arrayofaifeatures[$key]['label']; |
216 | 216 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $formai = new FormAI($db); |
227 | 227 | $formmail = new FormMail($db); |
228 | 228 | |
229 | - $showlinktoai = $key; // 'textgeneration', 'imagegeneration', ... |
|
229 | + $showlinktoai = $key; // 'textgeneration', 'imagegeneration', ... |
|
230 | 230 | $showlinktoailabel = $langs->trans("AITestText"); |
231 | 231 | $showlinktolayout = 0; |
232 | 232 | $htmlname = $key; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | // Fill $out |
235 | 235 | include DOL_DOCUMENT_ROOT.'/core/tpl/formlayoutai.tpl.php'; |
236 | 236 | |
237 | - $out .= '<br><textarea id="'.$key.'" placeholder="Lore ipsum..." class="quatrevingtpercent" rows="5"></textarea>'; // The div |
|
237 | + $out .= '<br><textarea id="'.$key.'" placeholder="Lore ipsum..." class="quatrevingtpercent" rows="5"></textarea>'; // The div |
|
238 | 238 | //} |
239 | 239 | |
240 | 240 | /* |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $action = GETPOST('action', 'aZ09'); |
48 | 48 | $backtopage = GETPOST('backtopage', 'alpha'); |
49 | 49 | $cancel = GETPOST('cancel'); |
50 | -$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php |
|
50 | +$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php |
|
51 | 51 | |
52 | 52 | $functioncode = GETPOST('functioncode', 'alpha'); |
53 | 53 | $pre_prompt = GETPOST('prePrompt'); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | if (preg_match('/^text/', $key)) { |
86 | 86 | $newkey = 'textgeneration'; |
87 | 87 | } |
88 | - $item = $formSetup->newItem('AI_API_'.strtoupper($aiservice).'_MODEL_'.$val["function"]); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
88 | + $item = $formSetup->newItem('AI_API_'.strtoupper($aiservice).'_MODEL_'.$val["function"]); // Name of constant must end with _KEY so it is encrypted when saved into database. |
|
89 | 89 | if ($arrayofai[$aiservice][$newkey] != 'na') { |
90 | 90 | $item->nameText = $langs->trans("AI_API_MODEL_".$val["function"]).' <span class="opacitymedium">('.$langs->trans("Default").' = '.$arrayofai[$aiservice][$newkey].')</span>'; |
91 | 91 | } else { |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | $out .= '<br><br>'; |
402 | 402 | |
403 | 403 | include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
404 | - $showlinktoai = $key; // 'textgeneration', 'imagegeneration', ... |
|
404 | + $showlinktoai = $key; // 'textgeneration', 'imagegeneration', ... |
|
405 | 405 | $showlinktoailabel = $langs->trans("ToTest"); |
406 | 406 | $formmail = new FormMail($db); |
407 | 407 | $htmlname = $key; |
@@ -63,17 +63,17 @@ |
||
63 | 63 | 'chatgpt' => array( |
64 | 64 | 'label' => 'ChatGPT', |
65 | 65 | 'url' => 'https://api.openai.com/v1/', |
66 | - 'textgeneration' => 'gpt-3.5-turbo', // a lot of text transformation like: 'textgenerationemail', 'textgenerationwebpage', 'textgeneration', 'texttranslation', 'textsummarize' |
|
66 | + 'textgeneration' => 'gpt-3.5-turbo', // a lot of text transformation like: 'textgenerationemail', 'textgenerationwebpage', 'textgeneration', 'texttranslation', 'textsummarize' |
|
67 | 67 | 'imagegeneration' => 'dall-e-3', |
68 | 68 | 'audiogeneration' => 'tts-1', |
69 | 69 | 'videogeneration' => 'na', |
70 | - 'transcription' => 'whisper-1', // audio to text |
|
71 | - 'translation' => 'whisper-1', // audio to text into another language |
|
70 | + 'transcription' => 'whisper-1', // audio to text |
|
71 | + 'translation' => 'whisper-1', // audio to text into another language |
|
72 | 72 | ), |
73 | 73 | 'groq' => array( |
74 | 74 | 'label' => 'Groq', |
75 | 75 | 'url' => 'https://api.groq.com/openai/', |
76 | - 'textgeneration' => 'mixtral-8x7b-32768', // 'llama3-8b-8192', 'gemma-7b-it' |
|
76 | + 'textgeneration' => 'mixtral-8x7b-32768', // 'llama3-8b-8192', 'gemma-7b-it' |
|
77 | 77 | 'imagegeneration' => 'na', |
78 | 78 | 'audiogeneration' => 'na', |
79 | 79 | 'videogeneration' => 'na', |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | $payload = json_encode($arrayforpayload); |
207 | 207 | |
208 | 208 | $headers = array( |
209 | - 'Authorization: Bearer ' . $this->apiKey, |
|
209 | + 'Authorization: Bearer '.$this->apiKey, |
|
210 | 210 | 'Content-Type: application/json' |
211 | 211 | ); |
212 | 212 | |
213 | 213 | if (getDolGlobalString("AI_DEBUG")) { |
214 | 214 | if (@is_writable($dolibarr_main_data_root)) { // Avoid fatal error on fopen with open_basedir |
215 | 215 | $outputfile = $dolibarr_main_data_root."/dolibarr_ai.log"; |
216 | - $fp = fopen($outputfile, "w"); // overwrite |
|
216 | + $fp = fopen($outputfile, "w"); // overwrite |
|
217 | 217 | |
218 | 218 | if ($fp) { |
219 | 219 | fwrite($fp, var_export($headers, true)."\n"); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | - $localurl = 2; // Accept both local and external endpoints |
|
228 | + $localurl = 2; // Accept both local and external endpoints |
|
229 | 229 | $response = getURLContent($this->apiEndpoint, 'POST', $payload, 1, $headers, array('http', 'https'), $localurl); |
230 | 230 | |
231 | 231 | if (empty($response['http_code'])) { |