| @@ -142,5 +142,38 @@ | ||
| 142 | 142 | |
| 143 | 143 | // output the result tags |
| 144 | 144 | VBOHttpDocument::getInstance($app)->json(['tags' => $tags]); |
| 145 | 145 | } |
| 146 | + | |
| 147 | + /** | |
| 148 | + * Task used to summarize the provided conversation for the administrator. | |
| 149 | + * | |
| 150 | + * @return void | |
| 151 | + * | |
| 152 | + * @since 1.18.8 (J) - 1.8.8 (WP) | |
| 153 | + */ | |
| 154 | + public function summarize() | |
| 155 | + { | |
| 156 | + $app = JFactory::getApplication(); | |
| 157 | + | |
| 158 | + $messages = $app->input->get('messages', [], 'array'); | |
| 159 | + | |
| 160 | + try { | |
| 161 | + if (!JSession::checkToken()) { | |
| 162 | + // missing CSRF-proof token | |
| 163 | + throw new Exception(JText::translate('JINVALID_TOKEN'), 403); | |
| 164 | + } | |
| 165 | + | |
| 166 | + // validate AI service capabilities | |
| 167 | + $this->auditServiceCapabilities(); | |
| 168 | + | |
| 169 | + $summary = (new VCMAiModelService)->summarizeThread($messages); | |
| 170 | + } catch (Exception $error) { | |
| 171 | + // something went wrong | |
| 172 | + VCMHttpDocument::getInstance($app)->close($error->getCode() ?: 500, $error->getMessage()); | |
| 173 | + } | |
| 174 | + | |
| 175 | + VCMHttpDocument::getInstance($app)->json([ | |
| 176 | + 'result' => $summary, | |
| 177 | + ]); | |
| 178 | + } | |
| 146 | 179 | } |