Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • issue/openai-3344603
  • issue/openai-3343862
  • issue/openai-3346005
  • issue/openai-3346007
  • project/openai
  • issue/openai-3330547
  • issue/openai-3345746
  • issue/openai-3337774
  • issue/openai-3338418
  • issue/openai-3338722
  • issue/openai-3337946
  • issue/openai-3339747
  • issue/openai-3339686
  • issue/openai-3342260
  • issue/openai-3342536
  • issue/openai-3346059
  • issue/openai-3346815
  • issue/openai-3346392
  • issue/openai-3347276
  • issue/openai-3347971
  • issue/openai-3348798
  • issue/openai-3348826
  • issue/openai-3348193
  • issue/openai-3349910
  • issue/openai-3352937
  • issue/openai-3339682
  • issue/openai-3352556
  • issue/openai-3350327
  • issue/openai-3350302
  • issue/openai-3350857
  • issue/openai-3352899
  • issue/openai-3353392
  • issue/openai-3354994
  • issue/openai-3354838
  • issue/openai-3350328
  • issue/openai-3355827
  • issue/openai-3359147
  • issue/openai-3359049
  • issue/openai-3361577
  • issue/openai-3356546
  • issue/openai-3361717
  • issue/openai-3358716
  • issue/openai-3362773
  • issue/openai-3304538
  • issue/openai-3363125
  • issue/openai-3364420
  • issue/openai-3364439
  • issue/openai-3364444
  • issue/openai-3364607
  • issue/openai-3366607
  • issue/openai-3350297
  • issue/openai-3370559
  • issue/openai-3400271
  • issue/openai-3403282
  • issue/openai-3397647
  • issue/openai-3403557
  • issue/openai-3401105
  • issue/openai-3403559
  • issue/openai-3400915
  • issue/openai-3402695
  • issue/openai-3400295
  • issue/openai-3403576
  • issue/openai-3404831
  • issue/openai-3399940
  • issue/openai-3404107
  • issue/openai-3402482
  • issue/openai-3400627
  • issue/openai-3404567
  • issue/openai-3402579
  • issue/openai-3386389
  • issue/openai-3376414
  • issue/openai-3399084
  • issue/openai-3411462
  • issue/openai-3411893
  • issue/openai-3411889
  • issue/openai-3413325
  • issue/openai-3413412
  • issue/openai-3412280
  • issue/openai-3417202
  • issue/openai-3417782
  • issue/openai-3418612
  • issue/openai-3404972
  • issue/openai-3422783
  • issue/openai-3427583
  • issue/openai-3427907
  • issue/openai-3446821
  • issue/openai-3419649
  • issue/openai-3443260
  • issue/openai-3446898
  • issue/openai-3439942
  • issue/openai-3421373
  • issue/openai-3446772
  • issue/openai-3444868
  • issue/openai-3431401
  • issue/openai-3433692
  • issue/openai-3446867
  • issue/openai-3450196
  • issue/openai-3450380
  • issue/openai-3453650
  • issue/openai-3452184
  • issue/openai-3457892
  • issue/openai-3462358
  • issue/openai-3464600
  • issue/openai-3437385
  • issue/openai-3465426
  • issue/openai-3493573
106 results
Show changes
Commits on Source (4)
......@@ -49,6 +49,3 @@ openai_embeddings.vector_client.pinecone_client:
hostname:
type: string
label: 'The hostname or base URI of the API.'
disable_namespace:
type: boolean
label: 'Disable namespace use if on the free starter plan'
......@@ -91,11 +91,8 @@ function openai_embeddings_schema() {
* Allow disabling of namespace, maintain status quo of false.
*/
function openai_embeddings_update_10001() {
$config = \Drupal::configFactory()->getEditable('openai_embeddings.pinecone_client');
if ($config->get('disable_namespace') === NULL) {
$config->set('disable_namespace', FALSE);
$config->save();
}
// Do nothing, we no longer need the disable namespace
// as per openai_embeddings_update_10003().
}
/**
......@@ -116,3 +113,21 @@ function openai_embeddings_update_10002() {
$pinecone_config->delete();
}
}
/**
* Allow disabling of namespace, maintain status quo of false.
*/
function openai_embeddings_update_10003() {
$config = \Drupal::configFactory()->getEditable('openai_embeddings.settings');
if ($config->get('vector_clients.pinecone.disable_namespace')) {
$config->clear('vector_clients.pinecone.disable_namespace');
$config->save();
}
}
/**
* Clear cache of models list given change to filters in #3417202.
*/
function openai_embeddings_update_10004() {
\Drupal::cache()->invalidate('openai_models');
}
......@@ -36,6 +36,13 @@ class SettingsForm extends ConfigFormBase {
*/
protected $pluginManager;
/**
* The Open AI API client.
*
* @var \Drupal\openai\OpenAIApi
*/
protected $api;
/**
* {@inheritdoc}
*/
......@@ -60,6 +67,7 @@ class SettingsForm extends ConfigFormBase {
$instance->entityTypeManager = $container->get('entity_type.manager');
$instance->entityTypeBundleInfo = $container->get('entity_type.bundle.info');
$instance->pluginManager = $container->get('plugin.manager.vector_client');
$instance->api = $container->get('openai.api');
return $instance;
}
......@@ -116,13 +124,14 @@ class SettingsForm extends ConfigFormBase {
'#description' => $this->t('Enter a comma delimited list of words to exclude from generating embedding values for.'),
];
$models = $this->api->filterModels(['text-embedding-']);
$selected_model = $this->config('openai_embeddings.settings')->get('model');
$form['model'] = [
'#type' => 'select',
'#title' => $this->t('Model to use'),
'#options' => [
'text-embedding-ada-002' => $this->t('text-embedding-ada-002'),
],
'#default_value' => $this->config('openai_embeddings.settings')->get('model'),
'#options' => $models,
'#required' => TRUE,
'#default_value' => $models[$selected_model] ?: '',
'#description' => $this->t('Select which model to use to analyze text. See the <a href=":link">model overview</a> for details about each model.', [':link' => 'https://platform.openai.com/docs/guides/embeddings/embedding-models']),
];
......@@ -180,12 +189,9 @@ class SettingsForm extends ConfigFormBase {
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
foreach ($this->pluginManager->getDefinitions() as $pid => $plugin) {
/** @var \Drupal\openai_embeddings\VectorClientPluginBase $plugin */
$plugin_instance = $this->pluginManager->createInstance($pid);
if (!method_exists($plugin_instance, 'validateConfigurationForm')) {
continue;
}
$pid = $form_state->getValue(['connections', 'vector_client_plugin']);
$plugin_instance = $this->pluginManager->createInstance($pid);
if (method_exists($plugin_instance, 'validateConfigurationForm')) {
$subform = &$form['connections'][$pid];
$subform_state = SubformState::createForSubform($form['connections'][$pid], $form, $form_state);
$plugin_instance->validateConfigurationForm($subform, $subform_state);
......
......@@ -152,10 +152,7 @@ final class EmbeddingQueueWorker extends QueueWorkerBase implements ContainerFac
$embeddings = $response->toArray();
$namespace = '';
if (!$this->config->get('vector_clients.' . $plugin_id . '.disable_namespace')) {
$namespace = $entity->getEntityTypeId();
}
$namespace = $entity->getEntityTypeId();
$vectors = [
'id' => $this->generateUniqueId($entity, $field->getName(), $delta),
......
......@@ -176,16 +176,6 @@ class Pinecone extends VectorClientPluginBase {
];
}
// If filter is provided, ensure that it is not free
// Pinecone.
if (!$payload['deleteAll'] && $this->getConfiguration()['disable_namespace']) {
throw new \Exception('Pinecone free starter plan does not support filters on deletion.');
}
elseif ($payload['deleteAll'] && $this->getConfiguration()['disable_namespace']) {
$this->messenger->addWarning('Pinecone free starter plan does not support Delete All. Please visit the Pinecone website to manually clear the index.');
throw new \Exception('Pinecone free starter plan does not support filters on deletion.');
}
// See description in ::query().
if (!empty($parameters['collection'])) {
$payload['namespace'] = $parameters['collection'];
......@@ -323,6 +313,10 @@ class Pinecone extends VectorClientPluginBase {
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
// Set the new configuration values for this instance before validating.
$this->setConfiguration($form_state->getValues());
// Attempt to validate the new configuration.
try {
$this->getClient()->post(
'/describe_index_stats',
......
......@@ -95,7 +95,7 @@ class OpenAIApi implements ContainerInjectionInterface {
}
// Skip unused. hidden, or deprecated models.
if (preg_match('/(search|similarity|edit|1p|instruct|embed)/i', $model['id'])) {
if (preg_match('/(search|similarity|edit|1p|instruct)/i', $model['id'])) {
continue;
}
......@@ -136,16 +136,6 @@ class OpenAIApi implements ContainerInjectionInterface {
return $models;
}
/**
* Get the latest embedding model.
*
* @return string
* The embedding model in OpenAI.
*/
public function embeddingModel(): string {
return 'text-embedding-ada-002';
}
/**
* Return a ready to use answer from the completion endpoint.
*
......