Skip to content

Commit 18c9f12

Browse files
committed
enable sticker task only when sticker picker is enabled
Signed-off-by: Lukas Schaefer <lukas@lschaefer.xyz>
1 parent 1b2becd commit 18c9f12

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

lib/AppInfo/Application.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
use OCP\AppFramework\Bootstrap\IRegistrationContext;
4242
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
4343
use OCP\Collaboration\Reference\RenderReferenceEvent;
44+
use OCP\IAppConfig;
4445
use OCP\Security\CSP\AddContentSecurityPolicyEvent;
4546
use OCP\TaskProcessing\Events\TaskFailedEvent;
4647
use OCP\TaskProcessing\Events\TaskSuccessfulEvent;
@@ -54,8 +55,12 @@ class Application extends App implements IBootstrap {
5455
public const CHAT_USER_INSTRUCTIONS = 'This is a conversation in a specific language between the user and you, Nextcloud Assistant. You are a kind, polite and helpful AI that helps the user to the best of its abilities. If you do not understand something, you will ask for clarification. Detect the language that the user is using. Make sure to use the same language in your response. Do not mention the language explicitly.';
5556
public const CHAT_USER_INSTRUCTIONS_TITLE = 'Above is a chat session in a specific language between the user and you, Nextcloud Assistant. Generate a suitable title summarizing the conversation in the same language. Output only the title in plain text, nothing else.';
5657

58+
private IAppConfig $appConfig;
5759
public function __construct(array $urlParams = []) {
5860
parent::__construct(self::APP_ID, $urlParams);
61+
62+
$container = $this->getContainer();
63+
$this->appConfig = $container->get(IAppConfig::class);
5964
}
6065

6166
public function register(IRegistrationContext $context): void {
@@ -96,8 +101,10 @@ public function register(IRegistrationContext $context): void {
96101
if (class_exists('OCP\\TaskProcessing\\TaskTypes\\ContextAgentAudioInteraction')) {
97102
$context->registerTaskProcessingProvider(ContextAgentAudioInteractionProvider::class);
98103
}
99-
$context->registerTaskProcessingTaskType(TextToStickerTaskType::class);
100-
$context->registerTaskProcessingProvider(TextToStickerProvider::class);
104+
if ($this->appConfig->getValueString(Application::APP_ID, 'text_to_sticker_picker_enabled', '1') === '1') {
105+
$context->registerTaskProcessingTaskType(TextToStickerTaskType::class);
106+
$context->registerTaskProcessingProvider(TextToStickerProvider::class);
107+
}
101108
}
102109

103110
public function boot(IBootContext $context): void {

lib/Settings/Admin.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public function getForm(): TemplateResponse {
4343
$freePromptPickerEnabled = $this->appConfig->getValueString(Application::APP_ID, 'free_prompt_picker_enabled', '1') === '1';
4444
$textToImagePickerEnabled = $this->appConfig->getValueString(Application::APP_ID, 'text_to_image_picker_enabled', '1') === '1';
4545
$textToStickerPickerEnabled = $this->appConfig->getValueString(Application::APP_ID, 'text_to_sticker_picker_enabled', '1') === '1';
46+
if ($textToStickerPickerEnabled && !$textToImageAvailable) {
47+
$this->appConfig->setValueString(Application::APP_ID, 'text_to_sticker_picker_enabled', '0');
48+
$textToStickerPickerEnabled = false;
49+
}
4650

4751
$speechToTextEnabled = $this->appConfig->getValueString(Application::APP_ID, 'speech_to_text_picker_enabled', '1') === '1';
4852
$chattyLLMUserInstructions = $this->appConfig->getValueString(Application::APP_ID, 'chat_user_instructions', Application::CHAT_USER_INSTRUCTIONS) ?: Application::CHAT_USER_INSTRUCTIONS;

src/components/AssistantTextProcessingForm.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,9 @@ export default {
281281
return null
282282
},
283283
sortedTaskTypes() {
284-
let filteredTaskTypes = this.taskTypeIdList !== null
284+
const filteredTaskTypes = this.taskTypeIdList !== null
285285
? this.taskTypes.slice().filter(t => this.taskTypeIdList.find(tt => tt === t.id))
286286
: this.taskTypes.slice()
287-
const hasImageTaskType = filteredTaskTypes.find(tt => tt.id === 'core:text2image')
288-
if (!hasImageTaskType) {
289-
filteredTaskTypes = filteredTaskTypes.filter(tt => tt.id !== 'assistant:text2sticker')
290-
}
291287
292288
return filteredTaskTypes.sort((a, b) => {
293289
const prioA = a.priority

0 commit comments

Comments
 (0)