Skip to content

Commit c3a4357

Browse files
committed
feat: Add tool-use suggestions when agency is enabled
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 04e444c commit c3a4357

File tree

3 files changed

+43
-10
lines changed

3 files changed

+43
-10
lines changed

lib/Listener/BeforeTemplateRenderedListener.php

Lines changed: 5 additions & 1 deletion
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,7 +74,9 @@ 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);
75-
}
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);
79+
}
7680
if (class_exists(\OCA\Viewer\Event\LoadViewer::class)) {
7781
$this->eventDispatcher->dispatchTyped(new \OCA\Viewer\Event\LoadViewer());
7882
}

src/components/ChattyLLM/ChattyLLMInputForm.vue

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,18 @@
8686
<template #icon>
8787
<AssistantIcon />
8888
</template>
89-
<template #default>
90-
<NcButton @click="chatContent = 'What\'s the weather in berlin, right now?'" :aria-label="t('assisant', 'Ask assistant, what\'s the weather in berlin right now')" variant="secondary">
91-
{{ t('assistant', 'What\'s the weather in berlin, right now?') }}
92-
</NcButton>
93-
<NcButton @click="chatContent = 'Can you show me a map of Berlin?'" :aria-label="t('assisant', 'Ask assistant, to show you a map of Berlin')" variant="secondary">
94-
{{ t('assistant', 'Can you show me a map of Berlin?') }}
95-
</NcButton>
96-
</template>
89+
<template #action>
90+
<div v-if="agencyAvailable" class="session-area__agency-suggestions">
91+
<NcButton v-for="suggestion in agencySuggestions"
92+
:key="suggestion.message"
93+
class="session-area__agency-suggestion"
94+
:aria-label="suggestion.aria"
95+
variant="secondary"
96+
@click="chatContent = suggestion.message">
97+
{{ t('assistant', suggestion.message) }}
98+
</NcButton>
99+
</div>
100+
</template>
97101
</NoSession>
98102
<div v-else
99103
class="session-area__chat-area__active-session"
@@ -240,6 +244,7 @@ export default {
240244
},
241245
242246
data: () => {
247+
const agencyAvailable = loadState('assistant', 'agency_available', false)
243248
return {
244249
// { id: number, title: string, user_id: string, timestamp: number }
245250
active: null,
@@ -269,6 +274,21 @@ export default {
269274
pollTitleGenerationTimerId: null,
270275
autoplayAudioChat: loadState('assistant', 'autoplay_audio_chat', true),
271276
slowPickup: false,
277+
agencyAvailable,
278+
agencySuggestions: [
279+
{
280+
aria: t('assisant', 'Ask assistant, what\'s the weather in Berlin right now'),
281+
message: t('assisant', 'What\'s the weather in Berlin right now?'),
282+
},
283+
{
284+
aria: t('assisant', 'Ask assistant, to create a share link for a file'),
285+
message: t('assisant', 'Can you create a share link for the following file in my documents? welcome.txt'),
286+
},
287+
{
288+
aria: t('assisant', 'Ask assistant, which actions it can do for you'),
289+
message: t('assisant', 'Which actions can you do for me?'),
290+
},
291+
],
272292
}
273293
},
274294
@@ -1031,6 +1051,13 @@ export default {
10311051
position: sticky;
10321052
bottom: 0;
10331053
}
1054+
1055+
&__agency-suggestions {
1056+
display: flex;
1057+
flex-direction: column;
1058+
align-items: center;
1059+
gap: 10px;
1060+
}
10341061
}
10351062
}
10361063
</style>

src/components/ChattyLLM/NoSession.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
<template #icon>
88
<slot name="icon" />
99
</template>
10-
<slot name="default" />
10+
<template #action>
11+
<slot name="action" />
12+
</template>
1113
</NcEmptyContent>
1214
</template>
1315

0 commit comments

Comments
 (0)