aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/settings/lib/Controller/AISettingsController.php2
-rw-r--r--apps/settings/lib/Settings/Admin/ArtificialIntelligence.php11
-rw-r--r--apps/settings/src/components/AdminAI.vue22
-rw-r--r--lib/private/TextToImage/Manager.php6
-rw-r--r--lib/public/TextToImage/IManager.php6
5 files changed, 46 insertions, 1 deletions
diff --git a/apps/settings/lib/Controller/AISettingsController.php b/apps/settings/lib/Controller/AISettingsController.php
index 7f016d79c25..8db8fa8b5bb 100644
--- a/apps/settings/lib/Controller/AISettingsController.php
+++ b/apps/settings/lib/Controller/AISettingsController.php
@@ -57,7 +57,7 @@ class AISettingsController extends Controller {
* @return DataResponse
*/
public function update($settings) {
- $keys = ['ai.stt_provider', 'ai.textprocessing_provider_preferences', 'ai.translation_provider_preferences'];
+ $keys = ['ai.stt_provider', 'ai.textprocessing_provider_preferences', 'ai.translation_provider_preferences', 'ai.text2image_provider'];
foreach ($keys as $key) {
if (!isset($settings[$key])) {
continue;
diff --git a/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php b/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php
index eb1983690a5..4556f8e0a9d 100644
--- a/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php
+++ b/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php
@@ -48,6 +48,7 @@ class ArtificialIntelligence implements IDelegatedSettings {
private ISpeechToTextManager $sttManager,
private IManager $textProcessingManager,
private ContainerInterface $container,
+ private \OCP\TextToImage\IManager $text2imageManager,
) {
}
@@ -101,15 +102,25 @@ class ArtificialIntelligence implements IDelegatedSettings {
];
}
+ $text2imageProviders = [];
+ foreach ($this->text2imageManager->getProviders() as $provider) {
+ $text2imageProviders[] = [
+ 'class' => $provider::class,
+ 'name' => $provider->getName(),
+ ];
+ }
+
$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);
$settings = [
'ai.stt_provider' => count($sttProviders) > 0 ? $sttProviders[0]['class'] : null,
'ai.textprocessing_provider_preferences' => $textProcessingSettings,
'ai.translation_provider_preferences' => $translationPreferences,
+ 'ai.text2image_provider' => count($text2imageProviders) > 0 ? $text2imageProviders[0]['class'] : null,
];
foreach ($settings as $key => $defaultValue) {
$value = $defaultValue;
diff --git a/apps/settings/src/components/AdminAI.vue b/apps/settings/src/components/AdminAI.vue
index 6a8b73d81f3..77755fdc0af 100644
--- a/apps/settings/src/components/AdminAI.vue
+++ b/apps/settings/src/components/AdminAI.vue
@@ -36,6 +36,24 @@
</NcCheckboxRadioSwitch>
</template>
</NcSettingsSection>
+ <NcSettingsSection :name="t('settings', 'Image generation')"
+ :description="t('settings', 'Image generation can be implemented by different apps. Here you can set which app should be used.')">
+ <template v-for="provider in text2imageProviders">
+ <NcCheckboxRadioSwitch :key="provider.class"
+ :checked.sync="settings['ai.text2image_provider']"
+ :value="provider.class"
+ name="text2image_provider"
+ type="radio"
+ @update:checked="saveChanges">
+ {{ provider.name }}
+ </NcCheckboxRadioSwitch>
+ </template>
+ <template v-if="!hasStt">
+ <NcCheckboxRadioSwitch disabled type="radio">
+ {{ t('settings', 'None of your currently installed apps provide image generation functionality') }}
+ </NcCheckboxRadioSwitch>
+ </template>
+ </NcSettingsSection>
<NcSettingsSection :name="t('settings', 'Text processing')"
:description="t('settings', 'Text processing tasks can be implemented by different apps. Here you can set which app should be used for which task.')">
<template v-for="type in tpTaskTypes">
@@ -100,6 +118,7 @@ export default {
translationProviders: loadState('settings', 'ai-translation-providers'),
textProcessingProviders: loadState('settings', 'ai-text-processing-providers'),
textProcessingTaskTypes: loadState('settings', 'ai-text-processing-task-types'),
+ text2imageProviders: loadState('settings', 'ai-text2image-providers'),
settings: loadState('settings', 'ai-settings'),
}
},
@@ -113,6 +132,9 @@ export default {
tpTaskTypes() {
return Object.keys(this.settings['ai.textprocessing_provider_preferences']).filter(type => !!this.getTaskType(type))
},
+ hasText2ImageProviders() {
+ return this.text2imageProviders.length > 0
+ }
},
methods: {
moveUp(i) {
diff --git a/lib/private/TextToImage/Manager.php b/lib/private/TextToImage/Manager.php
index 0b61d1af246..c05e6e6972c 100644
--- a/lib/private/TextToImage/Manager.php
+++ b/lib/private/TextToImage/Manager.php
@@ -64,6 +64,9 @@ class Manager implements IManager {
$this->appData = $this->appDataFactory->get('core');
}
+ /**
+ * @inerhitDocs
+ */
public function getProviders(): array {
$context = $this->coordinator->getRegistrationContext();
if ($context === null) {
@@ -90,6 +93,9 @@ class Manager implements IManager {
return $this->providers;
}
+ /**
+ * @inheritDoc
+ */
public function hasProviders(): bool {
$context = $this->coordinator->getRegistrationContext();
if ($context === null) {
diff --git a/lib/public/TextToImage/IManager.php b/lib/public/TextToImage/IManager.php
index 5afaecd37bc..cfe38e3ce7f 100644
--- a/lib/public/TextToImage/IManager.php
+++ b/lib/public/TextToImage/IManager.php
@@ -43,6 +43,12 @@ interface IManager {
public function hasProviders(): bool;
/**
+ * @since 28.0.0
+ * @return IProvider[]
+ */
+ public function getProviders(): array;
+
+ /**
* @param Task $task The task to run
* @throws PreConditionNotMetException If no or not the requested provider was registered but this method was still called
* @throws RuntimeException If something else failed