Skip to content
Snippets Groups Projects
Commit 84a4d5fa authored by Marcus Johansson's avatar Marcus Johansson
Browse files

Issue #3484067: Add update hooks to take over from core

parent 29590938
No related branches found
No related tags found
1 merge request!1Issue #3484067: Add update hooks to take over from core
Pipeline #322926 passed
<?php
/**
* @file
* Install file for the OpenAI AI Provider.
*/
/**
* Implements hook_install().
*/
function ai_provider_openai() {
$config_factory = \Drupal::configFactory();
// Check if we have old configuration from the AI submodule.
$old_config = $config_factory->get('provider_openai.settings');
$old_data = $old_config->getRawData();
if (!empty($old_data['api_key'])) {
$new_config = $config_factory->getEditable('ai_provider_openai.settings');
// Bail if we already have data.
$new_data = $new_config->getRawData();
if (!empty($new_data['api_key'])) {
return;
}
// Copy the old configuration from the previous AI submodule into the new
// external module.
$new_config->setData($old_data);
$new_config->save();
}
// Uninstall the old submodule of AI core if it is still installed.
/** @var \Drupal\Core\Extension\ModuleHandlerInterface $handler */
$handler = \Drupal::service('module_handler');
if ($handler->moduleExists('ai_provider_openai')) {
/** @var \Drupal\Core\Extension\ModuleInstallerInterface $installer */
$installer = \Drupal::service('module_installer');
$installer->uninstall(['provider_openai']);
}
}
......@@ -430,7 +430,6 @@ class OpenAiProvider extends AiProviderClientBase implements
throw $e;
}
}
$response = $this->client->audio()->speech($payload);
$output = new AudioFile($response, 'audio/mpeg', 'openai.mp3');
// Return a normalized response.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment