From ebd9a2ac0f356ef643443111ec71939f5ed269fb Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Wed, 17 Jun 2026 17:03:42 -0300 Subject: [PATCH] feat(ai-templates): content template contract + value objects --- app/Ai/Templates/AiContentTemplate.php | 60 ++++++++++++++++++++++++++ app/Ai/Templates/GeneratedPost.php | 23 ++++++++++ app/Ai/Templates/TemplateContext.php | 21 +++++++++ 3 files changed, 104 insertions(+) create mode 100644 app/Ai/Templates/AiContentTemplate.php create mode 100644 app/Ai/Templates/GeneratedPost.php create mode 100644 app/Ai/Templates/TemplateContext.php diff --git a/app/Ai/Templates/AiContentTemplate.php b/app/Ai/Templates/AiContentTemplate.php new file mode 100644 index 00000000..8ec3d62a --- /dev/null +++ b/app/Ai/Templates/AiContentTemplate.php @@ -0,0 +1,60 @@ + + */ + public function supportedFormats(): array; + + /** The 'format' string passed to the generator agent (e.g. 'single'). */ + public function generatorFormat(): string; + + /** The Blade view path for the generator prompt. */ + public function promptView(): string; + + /** + * The structured-output schema for the generator. + * + * @return array + */ + public function schema(JsonSchema $schema, TemplateContext $context): array; + + /** + * Text fields (by structured-output key) the humanizer should rewrite. + * Empty = skip humanization. + * + * @return array + */ + public function humanizableFields(): array; + + /** + * Build the post from the (humanized) structured output. + * + * @param array $structured + */ + public function assemble(array $structured, TemplateContext $context): GeneratedPost; +} diff --git a/app/Ai/Templates/GeneratedPost.php b/app/Ai/Templates/GeneratedPost.php new file mode 100644 index 00000000..690807e6 --- /dev/null +++ b/app/Ai/Templates/GeneratedPost.php @@ -0,0 +1,23 @@ +> $media + */ + public function __construct( + public string $content, + public array $media, + public ?ContentType $contentType, + ) {} +} diff --git a/app/Ai/Templates/TemplateContext.php b/app/Ai/Templates/TemplateContext.php new file mode 100644 index 00000000..9a0cb16b --- /dev/null +++ b/app/Ai/Templates/TemplateContext.php @@ -0,0 +1,21 @@ +