Skip to content

Commit 8cd270b

Browse files
authored
Merge pull request #424 from nextcloud/feat/agency-indicator
feat: Add buttons to suggest agency tools
2 parents 32dfcde + d38420d commit 8cd270b

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

lib/Listener/BeforeTemplateRenderedListener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use OCP\IConfig;
2323
use OCP\IUser;
2424
use OCP\IUserSession;
25+
use OCP\TaskProcessing\IManager;
2526
use OCP\Util;
2627

2728
/**
@@ -37,6 +38,7 @@ public function __construct(
3738
private IEventDispatcher $eventDispatcher,
3839
private AssistantService $assistantService,
3940
private ?string $userId,
41+
private IManager $taskProcessingManager,
4042
) {
4143
}
4244

@@ -72,6 +74,8 @@ public function handle(Event $event): void {
7274
$this->initialStateService->provideInitialState('audio_chat_available', $this->assistantService->isAudioChatAvailable());
7375
$autoplayAudioChat = $this->config->getUserValue($this->userId, Application::APP_ID, 'autoplay_audio_chat', '1') === '1';
7476
$this->initialStateService->provideInitialState('autoplay_audio_chat', $autoplayAudioChat);
77+
$agencyAvailable = class_exists('OCP\\TaskProcessing\\TaskTypes\\ContextAgentInteraction') && array_key_exists(\OCP\TaskProcessing\TaskTypes\ContextAgentInteraction::ID, $this->taskProcessingManager->getAvailableTaskTypes());
78+
$this->initialStateService->provideInitialState('agency_available', $agencyAvailable);
7579
}
7680
if (class_exists(\OCA\Viewer\Event\LoadViewer::class)) {
7781
$this->eventDispatcher->dispatchTyped(new \OCA\Viewer\Event\LoadViewer());

src/components/ChattyLLM/ChattyLLMInputForm.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@
128128
<p class="session-area__disclaimer">
129129
{{ t('assistant', 'Output shown here is generated by AI. Make sure to always double-check.') }}
130130
</p>
131+
<div v-if="agencyAvailable && (messages == null || messages.length === 0)" class="session-area__agency-suggestions">
132+
<NcButton v-for="suggestion in agencySuggestions"
133+
:key="suggestion.message"
134+
class="session-area__agency-suggestion"
135+
:aria-label="suggestion.aria"
136+
variant="tertiary"
137+
:text="suggestion.message"
138+
@click="chatContent = suggestion.message" />
139+
</div>
131140
<p v-if="chatContent?.length > 64_000"
132141
class="session-area__disclaimer">
133142
{{ t('assistant', 'Messages should not be longer than {maxLength} characters (currently {length}).', { maxLength: 64_000, length: chatContent.length }) }}
@@ -261,6 +270,21 @@ export default {
261270
pollTitleGenerationTimerId: null,
262271
autoplayAudioChat: loadState('assistant', 'autoplay_audio_chat', true),
263272
slowPickup: false,
273+
agencyAvailable: loadState('assistant', 'agency_available', false),
274+
agencySuggestions: [
275+
{
276+
aria: t('assisant', 'Ask assistant, what\'s the weather today'),
277+
message: t('assisant', 'What\'s the weather today?'),
278+
},
279+
{
280+
aria: t('assisant', 'Ask assistant, to create a share link for a file'),
281+
message: t('assisant', 'Can you create a share link for me?'),
282+
},
283+
{
284+
aria: t('assisant', 'Ask assistant, which actions it can do for you'),
285+
message: t('assisant', 'Which actions can you do for me?'),
286+
},
287+
],
264288
}
265289
},
266290
@@ -1023,6 +1047,19 @@ export default {
10231047
position: sticky;
10241048
bottom: 0;
10251049
}
1050+
1051+
&__agency-suggestions {
1052+
display: flex;
1053+
flex-direction: row;
1054+
align-items: start;
1055+
gap: 10px;
1056+
flex-wrap: wrap;
1057+
justify-content: start;
1058+
padding: 0 1em;
1059+
}
1060+
&__agency-suggestion {
1061+
flex-shrink: 0;
1062+
}
10261063
}
10271064
}
10281065
</style>

src/components/ChattyLLM/NoSession.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<template #icon>
88
<slot name="icon" />
99
</template>
10+
<template #action>
11+
<slot name="action" />
12+
</template>
1013
</NcEmptyContent>
1114
</template>
1215

0 commit comments

Comments
 (0)