Skip to content

Commit 6543ae2

Browse files
committed
Print Azure errors in chat
1 parent 1c5604d commit 6543ae2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

classes/completion/azure.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,16 @@ private function make_api_call($history) {
9292
);
9393
$response = json_decode($response);
9494

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

0 commit comments

Comments
 (0)