Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ public function prepare(INotification $notification, string $languageCode): INot
// Catch the custom copywriter task type built on top of the FreePrompt task type.
$taskTypeName = $l->t('AI context writer');
$taskInput = $l->t('Writing style: %1$s; Source material: %2$s', [$params['inputs']['writingStyle'], $params['inputs']['sourceMaterial']]);
} elseif (
$params['taskTypeId'] === 'context_chat:context_chat'
|| $params['taskTypeId'] === 'legacy:TextProcessing:OCA\ContextChat\TextProcessing\ContextChatTaskType'
) {
$taskInput = $params['inputs']['prompt'] ?? null;
$taskTypeName = $l->t('Context Chat');
} else {
$availableTaskTypes = $this->taskProcessingManager->getAvailableTaskTypes();
if (isset($availableTaskTypes[$params['taskTypeId']])) {
Expand Down
52 changes: 0 additions & 52 deletions lib/Service/AssistantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,58 +509,6 @@ public function getOutputFilePreviewFile(string $userId, int $taskId, int $fileI
return $this->previewService->getFilePreviewFile($taskOutputFile, $x, $y, $realMime ?: null);
}

/**
* Sanitize inputs for storage based on the input type
*
* @param string $type
* @param array $inputs
* @return array
* @throws \Exception
*/
private function sanitizeInputs(string $type, array $inputs): array {
switch ($type) {
case 'copywriter':
{
// Sanitize the input array based on the allowed keys and making sure all inputs are strings:
$inputs = array_filter($inputs, function ($value, $key) {
return in_array($key, ['writingStyle', 'sourceMaterial']) && is_string($value);
}, ARRAY_FILTER_USE_BOTH);

if (count($inputs) !== 2) {
throw new \Exception('Invalid input(s)');
}
break;
}
case 'OCA\\ContextChat\\TextProcessing\\ContextChatTaskType':
{
if ((count($inputs) !== 1 && count($inputs) !== 4)
|| !isset($inputs['prompt'])
|| !is_string($inputs['prompt'])
) {
throw new \Exception('Invalid input(s)');
}

if (count($inputs) === 4) {
if (!isset($inputs['scopeType']) || !is_string($inputs['scopeType'])
|| !isset($inputs['scopeList']) || !is_array($inputs['scopeList'])
|| !isset($inputs['scopeListMeta']) || !is_array($inputs['scopeListMeta'])) {
throw new \Exception('Invalid input(s)');
}
}

break;
}
default:
{
if (!is_string($inputs['prompt']) || count($inputs) !== 1) {
throw new \Exception('Invalid input(s)');
}
break;
}
}
return $inputs;
}

/**
* Parse text from file (if parsing the file type is supported)
* @param string $userId
Expand Down