Skip to content

Commit

Permalink
Add a log
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 11, 2024
1 parent 7226c7c commit 56a4dd4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion htdocs/ai/ajax/generate_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
$generatedContent = $ai->generateContent($instructions, 'auto', $function);

if (is_array($generatedContent) && $generatedContent['error']) {
print "Error : " . $generatedContent['message'];
print "Error returned by API call: " . $generatedContent['message'];
} else {
print $generatedContent;
}
6 changes: 6 additions & 0 deletions htdocs/ai/class/ai.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public function __construct($db)
*/
public function generateContent($instructions, $model = 'auto', $function = 'textgeneration')
{
if (empty($this->apiKey)) {
return array('error' => true, 'message' => 'API key is no defined');

This comment has been minimized.

Copy link
@mdeweerd

mdeweerd Mar 11, 2024

Contributor

no -> not.

}

if (empty($this->apiEndpoint)) {
if ($function == 'textgeneration') {
$this->apiEndpoint = 'https://api.openai.com/v1/chat/completions';
Expand Down Expand Up @@ -97,6 +101,8 @@ public function generateContent($instructions, $model = 'auto', $function = 'tex
}
}

dol_syslog("Call API for apiEndpoint=".$this->apiEndpoint." apiKey=".substr($this->apiKey, 0, 3).'***********, model='.$model);

try {
$configurationsJson = getDolGlobalString('AI_CONFIGURATIONS_PROMPT');
$configurations = json_decode($configurationsJson, true);
Expand Down

0 comments on commit 56a4dd4

Please sign in to comment.