@@ -66,34 +66,39 @@ public function handle(Event $event): void {
66
66
$ isAgencyAudioChat = class_exists ('OCP \\TaskProcessing \\TaskTypes \\ContextAgentAudioInteraction ' )
67
67
&& $ taskTypeId === \OCP \TaskProcessing \TaskTypes \ContextAgentAudioInteraction::ID ;
68
68
69
+ $ taskOutput = $ task ->getOutput ();
70
+
69
71
$ message = new Message ();
70
72
$ message ->setSessionId ($ sessionId );
71
73
$ message ->setOcpTaskId ($ task ->getId ());
72
74
$ message ->setRole ('assistant ' );
73
75
$ message ->setTimestamp (time ());
74
- $ sources = json_encode ($ task -> getOutput () ['sources ' ] ?? []);
76
+ $ sources = json_encode ($ taskOutput ['sources ' ] ?? []);
75
77
$ message ->setSources ($ sources ?: '[] ' );
76
78
$ message ->setAttachments ('[] ' );
77
79
if ($ isAudioChat || $ isAgencyAudioChat ) {
78
- $ outputTranscript = trim ($ task -> getOutput () ['output_transcript ' ] ?? '' );
80
+ $ outputTranscript = trim ($ taskOutput ['output_transcript ' ] ?? '' );
79
81
$ message ->setContent ($ outputTranscript );
80
82
// agency might not return any output but just ask for confirmation
81
83
if ($ outputTranscript !== '' ) {
82
- $ attachment = ['type ' => 'Audio ' , 'file_id ' => $ task ->getOutput ()['output ' ]];
83
- if (isset ($ task ->getOutput ()['audio_id ' ])) {
84
- $ attachment ['remote_audio_id ' ] = $ task ->getOutput ()['audio_id ' ];
84
+ $ attachment = ['type ' => 'Audio ' , 'file_id ' => $ taskOutput ['output ' ]];
85
+ if (isset ($ taskOutput ['audio_id ' ])) {
86
+ $ attachment ['remote_audio_id ' ] = $ taskOutput ['audio_id ' ];
87
+ if (isset ($ taskOutput ['audio_expires_at ' ])) {
88
+ $ attachment ['remote_audio_expires_at ' ] = $ taskOutput ['audio_expires_at ' ];
89
+ }
85
90
}
86
91
$ message ->setAttachments (json_encode ([$ attachment ]));
87
92
}
88
93
// now we have the transcription of the user audio input
89
94
if (preg_match ('/^chatty-llm:\d+:(\d+)$/ ' , $ customId , $ matches )) {
90
95
$ queryMessageId = (int )$ matches [1 ];
91
96
$ queryMessage = $ this ->messageMapper ->getMessageById ($ queryMessageId );
92
- $ queryMessage ->setContent (trim ($ task -> getOutput () ['input_transcript ' ] ?? '' ));
97
+ $ queryMessage ->setContent (trim ($ taskOutput ['input_transcript ' ] ?? '' ));
93
98
$ this ->messageMapper ->update ($ queryMessage );
94
99
}
95
100
} else {
96
- $ content = trim ($ task -> getOutput () ['output ' ] ?? '' );
101
+ $ content = trim ($ taskOutput ['output ' ] ?? '' );
97
102
$ message ->setContent ($ content );
98
103
$ this ->runTtsIfNeeded ($ sessionId , $ message , $ taskTypeId , $ task ->getUserId ());
99
104
}
@@ -106,8 +111,8 @@ public function handle(Event $event): void {
106
111
// store the conversation token and the actions if we are using the agency feature
107
112
if ($ isAgency || $ isAgencyAudioChat ) {
108
113
$ session = $ this ->sessionMapper ->getUserSession ($ task ->getUserId (), $ sessionId );
109
- $ conversationToken = ($ task -> getOutput () ['conversation_token ' ] ?? null ) ?: null ;
110
- $ pendingActions = ($ task -> getOutput () ['actions ' ] ?? null ) ?: null ;
114
+ $ conversationToken = ($ taskOutput ['conversation_token ' ] ?? null ) ?: null ;
115
+ $ pendingActions = ($ taskOutput ['actions ' ] ?? null ) ?: null ;
111
116
$ session ->setAgencyConversationToken ($ conversationToken );
112
117
$ session ->setAgencyPendingActions ($ pendingActions );
113
118
$ this ->sessionMapper ->update ($ session );
0 commit comments