diff options
author | Marcel Klehr <mklehr@gmx.net> | 2024-07-13 15:07:22 +0200 |
---|---|---|
committer | Julien Veyssier <julien-nc@posteo.net> | 2024-07-17 15:24:19 +0200 |
commit | 9dca5ae0e0b484e2dba360f47fa76d6f366d689a (patch) | |
tree | 35ebabd3c20f8087fb94ed1676b7158e79bbfc8d /apps/settings/lib/Settings/Admin/ArtificialIntelligence.php | |
parent | e4368f6a9f37985ab4f5911b4ca50dba8109827e (diff) | |
download | nextcloud-server-9dca5ae0e0b484e2dba360f47fa76d6f366d689a.tar.gz nextcloud-server-9dca5ae0e0b484e2dba360f47fa76d6f366d689a.zip |
feat(settings/admin/ai): Add Task Processing API settings
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'apps/settings/lib/Settings/Admin/ArtificialIntelligence.php')
-rw-r--r-- | apps/settings/lib/Settings/Admin/ArtificialIntelligence.php | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php b/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php index ac4badc2434..9a291243949 100644 --- a/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php +++ b/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php @@ -35,6 +35,7 @@ class ArtificialIntelligence implements IDelegatedSettings { private IManager $textProcessingManager, private ContainerInterface $container, private \OCP\TextToImage\IManager $text2imageManager, + private \OCP\TaskProcessing\IManager $taskProcessingManager, ) { } @@ -98,17 +99,42 @@ class ArtificialIntelligence implements IDelegatedSettings { ]; } + $taskProcessingProviders = []; + /** @var array<class-string<ITaskType>, string|class-string<IProvider>> $taskProcessingSettings */ + $taskProcessingSettings = []; + foreach ($this->taskProcessingManager->getProviders() as $provider) { + $taskProcessingProviders[] = [ + 'id' => $provider->getId(), + 'name' => $provider->getName(), + 'taskType' => $provider->getTaskTypeId(), + ]; + if (!isset($taskProcessingSettings[$provider->getTaskTypeId()])) { + $taskProcessingSettings[$provider->getTaskTypeId()] = $provider->getId(); + } + } + $taskProcessingTaskTypes = []; + foreach ($this->taskProcessingManager->getAvailableTaskTypes() as $taskTypeId => $taskTypeDefinition) { + $taskProcessingTaskTypes[] = [ + 'id' => $taskTypeId, + 'name' => $taskTypeDefinition['name'], + 'description' => $taskTypeDefinition['description'], + ]; + } + $this->initialState->provideInitialState('ai-stt-providers', $sttProviders); $this->initialState->provideInitialState('ai-translation-providers', $translationProviders); $this->initialState->provideInitialState('ai-text-processing-providers', $textProcessingProviders); $this->initialState->provideInitialState('ai-text-processing-task-types', $textProcessingTaskTypes); $this->initialState->provideInitialState('ai-text2image-providers', $text2imageProviders); + $this->initialState->provideInitialState('ai-task-processing-providers', $taskProcessingProviders); + $this->initialState->provideInitialState('ai-task-processing-task-types', $taskProcessingTaskTypes); $settings = [ 'ai.stt_provider' => count($sttProviders) > 0 ? $sttProviders[0]['class'] : null, - 'ai.textprocessing_provider_preferences' => $textProcessingSettings, 'ai.translation_provider_preferences' => $translationPreferences, + 'ai.textprocessing_provider_preferences' => $textProcessingSettings, 'ai.text2image_provider' => count($text2imageProviders) > 0 ? $text2imageProviders[0]['id'] : null, + 'ai.taskprocessing_provider_preferences' => $taskProcessingSettings, ]; foreach ($settings as $key => $defaultValue) { $value = $defaultValue; @@ -116,6 +142,7 @@ class ArtificialIntelligence implements IDelegatedSettings { if ($json !== '') { $value = json_decode($json, true); switch($key) { + case 'ai.taskprocessing_provider_preferences': case 'ai.textprocessing_provider_preferences': // fill $value with $defaultValue values $value = array_merge($defaultValue, $value); |