Skip to content

Commit 59e4e5a

Browse files
authored
Update OpenAIDbLog.inc
1 parent c729d67 commit 59e4e5a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modules/openai_dblog/includes/OpenAIDbLog.inc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ class OpenAIDbLog {
66

77
public function __construct() {
88
$config = config_get('openai.settings');
9-
$this->api = new OpenAIApi($config['api_key']);
9+
10+
// Get the key value using the key module.
11+
$api_key = key_get_key_value($config['api_key']);
12+
13+
if (empty($api_key)) {
14+
throw new Exception(t('The OpenAI API key is not set or is invalid. Please configure it in the OpenAI settings.'));
15+
}
16+
17+
$this->api = new OpenAIApi($api_key);
1018
}
1119

1220
public function getOpenAIExplanation($dblog) {

0 commit comments

Comments
 (0)