l->t('F7cloud Office text document generator'); } public function getTaskTypeId(): string { return TextToDocumentTaskType::ID; } public function getExpectedRuntime(): int { return 120; } public function getInputShapeEnumValues(): array { return []; } public function getInputShapeDefaults(): array { return []; } public function getOptionalInputShape(): array { return [ 'target_format' => new ShapeDescriptor( $this->l->t('Document format'), $this->l->t('The format of the generated document'), EShapeType::Enum ), ]; } public function getOptionalInputShapeEnumValues(): array { return [ 'target_format' => [ new ShapeEnumValue($this->l->t('OpenXML (docx)'), 'docx'), new ShapeEnumValue($this->l->t('OpenDocument (odt)'), 'odt'), new ShapeEnumValue($this->l->t('Portable Document Format (pdf)'), 'pdf'), ], ]; } public function getOptionalInputShapeDefaults(): array { return [ 'target_format' => self::DEFAULT_TARGET_FORMAT, ]; } public function getOutputShapeEnumValues(): array { return []; } public function getOptionalOutputShape(): array { return []; } public function getOptionalOutputShapeEnumValues(): array { return []; } /** * @inheritDoc */ public function process(?string $userId, array $input, callable $reportProgress): 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'); } $targetFormat = self::DEFAULT_TARGET_FORMAT; if (isset($input['target_format']) && is_string($input['target_format']) && in_array($input['target_format'], ['docx', 'odt', 'pdf'], true)) { $targetFormat = $input['target_format']; } $fileContent = $this->documentGenerationService->generateTextDocument( $userId, $input['text'], $targetFormat, ); return [ 'file' => $fileContent, ]; } }