Skip to content

Commit 42c2a90

Browse files
committed
feat: add api_version to the pinecone config
1 parent 6df9501 commit 42c2a90

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

core/components/modai/lexicon/en/default.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@
111111
$_lang['modai.admin.context_provider.pinecone.output_fields_desc'] = 'Comma separated list of fields (available from the pinecone) that will be included in the context. To better control the output, you can leave this empty and leverage Context Messages.';
112112
$_lang['modai.admin.context_provider.pinecone.context_messages'] = 'Context Messages';
113113
$_lang['modai.admin.context_provider.pinecone.context_messages_desc'] = 'Additional context messages that will be put in front of the data from DB. One message per line. Can contain {id} or any {field} (available from the pinecone) placeholder, you can also reference a system setting with using ++ as a prefix, for example {++site_url}.';
114+
$_lang['modai.admin.context_provider.pinecone.api_version'] = 'API Version';
115+
$_lang['modai.admin.context_provider.pinecone.api_version_desc'] = 'API version to use. Default: 2025-04';
114116

115117
$_lang['modai.admin.prompt_library.category'] = 'Category';
116118
$_lang['modai.admin.prompt_library.category'] = 'Category';

core/components/modai/src/ContextProviders/Pinecone.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function __construct(modX $modx, array $config = [])
2626

2727
$endpoint = Utils::getConfigValue($modx, 'endpoint', $config, '');
2828
$apiKey = Utils::getConfigValue($modx,'api_key', $config, '');
29+
$apiVersion = Utils::getConfigValue($modx,'api_version', $config, '2025-04');
2930
$this->namespace = Utils::getConfigValue($modx,'namespace', $config, '');
3031
$this->contextMessages = Utils::explodeAndClean(Utils::getConfigValue($modx,'context_messages', $config, ''), "\n");
3132
$this->fields = Utils::explodeAndClean(Utils::getConfigValue($modx,'fields', $config, ''));
@@ -54,7 +55,7 @@ public function __construct(modX $modx, array $config = [])
5455
'headers' => [
5556
'Api-Key' => $apiKey,
5657
'Content-Type' => 'application/json',
57-
'X-Pinecone-API-Version' => '2025-01',
58+
'X-Pinecone-API-Version' => $apiVersion,
5859
],
5960
]);
6061
}
@@ -275,6 +276,7 @@ public static function getConfig(modX $modx): array
275276
->addField('endpoint', function (FieldBuilder $fieldBuilder) use ($modx) {
276277
return $fieldBuilder->required();
277278
})
279+
->addField('api_version')
278280
->addField('namespace', function (FieldBuilder $fieldBuilder) use ($modx) {
279281
return $fieldBuilder->required();
280282
})

core/components/modai/src/Utils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function parseDataURL($dataURL)
4242

4343
public static function getConfigValue(modX $modx, $name, $config, $default)
4444
{
45-
$value = $modx->getOption($name, $config, '');
45+
$value = $modx->getOption($name, $config, $default);
4646
if (strncmp($value, 'ss:', 3) === 0) {
4747
$value = $modx->getOption(substr($value, 3), null, $default);
4848
}

0 commit comments

Comments
 (0)