2023-07-24 06:12:06 -04:00
|
|
|
<?php
|
2023-07-25 08:27:20 -04:00
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2023-07-24 06:12:06 -04:00
|
|
|
/**
|
2024-06-03 04:23:34 -04:00
|
|
|
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2023-07-24 06:12:06 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCA\Settings\Controller;
|
|
|
|
|
|
2024-07-25 07:14:49 -04:00
|
|
|
use OCA\Settings\Settings\Admin\ArtificialIntelligence;
|
2023-07-24 06:12:06 -04:00
|
|
|
use OCP\AppFramework\Controller;
|
2024-07-25 07:14:49 -04:00
|
|
|
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
|
2023-07-24 06:12:06 -04:00
|
|
|
use OCP\AppFramework\Http\DataResponse;
|
|
|
|
|
use OCP\IConfig;
|
|
|
|
|
use OCP\IRequest;
|
|
|
|
|
|
|
|
|
|
class AISettingsController extends Controller {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $appName
|
|
|
|
|
* @param IRequest $request
|
|
|
|
|
* @param IConfig $config
|
|
|
|
|
*/
|
2023-07-24 08:47:15 -04:00
|
|
|
public function __construct(
|
|
|
|
|
$appName,
|
|
|
|
|
IRequest $request,
|
|
|
|
|
private IConfig $config,
|
|
|
|
|
) {
|
2023-07-24 06:12:06 -04:00
|
|
|
parent::__construct($appName, $request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the email settings
|
|
|
|
|
*
|
|
|
|
|
* @param array $settings
|
|
|
|
|
* @return DataResponse
|
|
|
|
|
*/
|
2024-07-25 07:14:49 -04:00
|
|
|
#[AuthorizedAdminSetting(settings: ArtificialIntelligence::class)]
|
2023-07-24 08:47:15 -04:00
|
|
|
public function update($settings) {
|
2024-07-13 09:07:22 -04:00
|
|
|
$keys = ['ai.stt_provider', 'ai.textprocessing_provider_preferences', 'ai.taskprocessing_provider_preferences', 'ai.translation_provider_preferences', 'ai.text2image_provider'];
|
2023-07-24 08:47:15 -04:00
|
|
|
foreach ($keys as $key) {
|
|
|
|
|
if (!isset($settings[$key])) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$this->config->setAppValue('core', $key, json_encode($settings[$key]));
|
2023-07-24 06:12:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new DataResponse();
|
|
|
|
|
}
|
|
|
|
|
}
|