l10n->t('Nextcloud Assistant Slide Deck Generator'); } #[\Override] public function getTaskTypeId(): string { return SlideDeckGenerationTaskType::ID; } #[\Override] public function getExpectedRuntime(): int { return 120; } #[\Override] public function getInputShapeEnumValues(): array { return []; } #[\Override] public function getInputShapeDefaults(): array { return []; } #[\Override] public function getOptionalInputShape(): array { return []; } #[\Override] public function getOptionalInputShapeEnumValues(): array { return []; } #[\Override] public function getOptionalInputShapeDefaults(): array { return []; } #[\Override] public function getOutputShapeEnumValues(): array { return []; } #[\Override] public function getOptionalOutputShape(): array { return []; } #[\Override] public function getOptionalOutputShapeEnumValues(): array { return []; } /** * @inheritDoc */ #[\Override] public function process(?string $userId, array $input, callable $reportProgress, bool $includeWatermark = true): array { if ($userId === null) { throw new \RuntimeException('User ID is required to process the prompt.'); } if (!isset($input['text']) || !is_string($input['text'])) { throw new \RuntimeException('Invalid input, expected "text" key with string value'); } $response = $this->withRetry(function () use ($userId, $input, $includeWatermark) { return $this->slideDeckService->generateSlideDeck( $userId, $input['text'], $includeWatermark, ); }); return ['slide_deck' => $response]; } private function withRetry(callable $action, $maxAttempts = 2) { $attempt = 0; while ($attempt < $maxAttempts) { try { $attempt += 1; return $action(); } catch (\Exception $e) { if ($attempt === $maxAttempts) { throw $e; } } } } }