trypost/app
Paulo Castellano 886fca3152 feat: use LLM to polish brand autofill when provider is configured
When config('trypost.ai.text_provider') points to a provider whose
API key is populated (services.gemini.api_key or
services.openai.api_key), the autofill action pipes the homepage
markdown through a BrandAnalyzer agent with structured output to
produce higher-quality values for:

- brand_description — 2-3 sentences summarizing the company based on
  the actual page content, not the raw meta description (which is
  often generic SEO boilerplate)
- brand_tone — classified into one of our seven enum values from the
  writing style on the page
- content_language — detected from the actual content (more reliable
  than <html lang> which is often wrong)
- brand_voice_notes — concrete writing guidelines inferred from the
  site's style, written in the detected language

When the LLM provider is NOT configured (open-source self-hosted
deploys without API keys), the action keeps the existing
deterministic meta-tag-only flow — no crash, no noise, no LLM cost.
When the LLM fails mid-request, we log a warning and fall back to
the meta-tag values so the user still gets something useful.

Stack additions:
- league/html-to-markdown ^5.1 converts the main body to clean
  markdown for the LLM input (truncated to 4000 chars).
- BrandAnalyzer agent (Agent + HasStructuredOutput) with schema
  enums matching our allowed tones and languages.
- resources/views/prompts/brand_analyzer.blade.php holds the
  instructions, including explicit enum lists and examples of good
  voice_notes.

Frontend: Brand.vue now also fills brand_tone and brand_voice_notes
from the response when present.

Tests (+3): LLM-configured happy path, no-credentials fallback
(asserts BrandAnalyzer is never prompted via preventStrayPrompts),
and LLM-exception fallback (meta tags win, brand_tone stays null).
2026-04-16 11:33:02 -03:00
..
Actions feat: use LLM to polish brand autofill when provider is configured 2026-04-16 11:33:02 -03:00
Ai feat: use LLM to polish brand autofill when provider is configured 2026-04-16 11:33:02 -03:00
Broadcasting feat: complete AI assistant with custom services and brand config 2026-04-16 09:25:08 -03:00
Concerns refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
Console/Commands fix: RecoverStuckPosts also recovers platforms stuck in Pending status 2026-04-01 13:12:55 -03:00
DataTransferObjects feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
Enums feat: add brand configuration step to onboarding 2026-04-16 11:00:16 -03:00
Events feat: complete AI assistant with custom services and brand config 2026-04-16 09:25:08 -03:00
Exceptions fix: Facebook/Instagram/Threads OAuthException type incorrectly treated as token error — now only code 190 triggers TokenExpiredException 2026-04-01 14:33:26 -03:00
Features feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
Helpers fix: correct Upload.php filename case for Linux CI 2026-03-31 12:01:48 -03:00
Http feat: add brand autofill from website URL in onboarding 2026-04-16 11:13:54 -03:00
Jobs feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
Listeners feat: redesign billing, onboarding, sidebar, and settings architecture 2026-04-15 00:33:38 -03:00
Mail feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
Mcp feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
Models feat: add workspace content_language setting for AI generation 2026-04-16 10:37:03 -03:00
Policies feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
Providers feat: add platform rules for all 12 supported social networks 2026-04-16 10:03:14 -03:00
Rules refactor: restructure to Actions, subdomain routes (app/api), API tokens 2026-03-29 19:24:28 -03:00
Services feat: add workspace content_language setting for AI generation 2026-04-16 10:37:03 -03:00
Socialite refactor: code review fixes — policies, enums, data_get, tests 2026-03-31 00:40:18 -03:00