Skip to content

Commit 4f8447f

Browse files
authored
Merge pull request #40 from Limekiller/release-2.0.1
Release 2.0.1
2 parents b4c0e9b + 0c18792 commit 4f8447f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

classes/completion/chat.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,16 @@ private function make_api_call($history) {
9393
$response = $curl->post("https://api.openai.com/v1/chat/completions", json_encode($curlbody));
9494
$response = json_decode($response);
9595

96+
$message = null;
97+
if (property_exists($response, 'error')) {
98+
$message = 'ERROR: ' . $response->error->message;
99+
} else {
100+
$message = $response->choices[0]->message->content;
101+
}
102+
96103
return [
97-
"id" => $response->id,
98-
"message" => $response->choices[0]->message->content
104+
"id" => property_exists($response, 'id') ? $response->id : 'error',
105+
"message" => $message
99106
];
100107
}
101108
}

version.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
defined('MOODLE_INTERNAL') || die();
2626

2727
$plugin->component = 'block_openai_chat';
28-
$plugin->version = 2024010300;
28+
$plugin->version = 2024012300;
2929
$plugin->requires = 2022041600;
3030
$plugin->maturity = MATURITY_STABLE;
31-
$plugin->release = '2.0.0';
31+
$plugin->release = '2.0.1';

0 commit comments

Comments
 (0)