Skip to content

Commit 1142a63

Browse files
committed
improve displayed agency action names
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent b7ef307 commit 1142a63

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/Controller/ChattyLLMController.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
3333
class ChattyLLMController extends Controller {
34+
private array $agencyActionNames;
3435

3536
public function __construct(
3637
string $appName,
@@ -45,6 +46,22 @@ public function __construct(
4546
private ?string $userId,
4647
) {
4748
parent::__construct($appName, $request);
49+
$this->agencyActionNames = [
50+
'send_message_to_conversation' => $this->l10n->t('Send a message to a Talk conversation'),
51+
'list_talk_conversations' => $this->l10n->t('List Talk conversations'),
52+
'list_messages_in_conversation' => $this->l10n->t('List messages in a Talk conversation'),
53+
'schedule_event' => $this->l10n->t('Schedule a calendar event'),
54+
'list_calendars' => $this->l10n->t('List calendars'),
55+
];
56+
}
57+
58+
private function improveAgencyActionNames(array $actions): array {
59+
return array_map(function ($action) {
60+
if (isset($action->name) && isset($this->agencyActionNames[$action->name])) {
61+
$action->name = $this->agencyActionNames[$action->name];
62+
}
63+
return $action;
64+
}, $actions);
4865
}
4966

5067
/**
@@ -408,6 +425,7 @@ public function checkMessageGenerationTask(int $taskId, int $sessionId): JSONRes
408425
$jsonMessage['sessionAgencyPendingActions'] = $session->getAgencyPendingActions();
409426
if ($jsonMessage['sessionAgencyPendingActions'] !== null) {
410427
$jsonMessage['sessionAgencyPendingActions'] = json_decode($jsonMessage['sessionAgencyPendingActions']);
428+
$jsonMessage['sessionAgencyPendingActions'] = $this->improveAgencyActionNames($jsonMessage['sessionAgencyPendingActions']);
411429
}
412430
// do not insert here, it is done by the listener
413431
return new JSONResponse($jsonMessage);
@@ -462,6 +480,7 @@ public function checkSession(int $sessionId): JSONResponse {
462480
$pendingActions = $session->getAgencyPendingActions();
463481
if ($pendingActions !== null) {
464482
$pendingActions = json_decode($pendingActions);
483+
$pendingActions = $this->improveAgencyActionNames($pendingActions);
465484
}
466485
$responseData = [
467486
'messageTaskId' => null,

0 commit comments

Comments
 (0)