Add generate_page_content functionality for structured page content generation

- Introduced a new AI function `generate_page_content` to create structured content for website pages using JSON blocks.
- Updated `AIEngine` to handle the new function and return appropriate messages for content generation.
- Enhanced `PageGenerationService` to utilize the new AI function for generating page content based on blueprints.
- Modified `prompts.py` to include detailed content generation requirements for the new function.
- Updated site rendering logic to accommodate structured content blocks in various layouts.
This commit is contained in:
IGNY8 VPS (Salman)
2025-11-18 23:30:20 +00:00
parent 6c6133a683
commit e4e7ddfdf3
13 changed files with 1283 additions and 100 deletions

View File

@@ -0,0 +1,65 @@
# Site Builder Workflow - Explanation & Fix
## The Problem (FIXED)
You were experiencing confusion because there were **TWO separate systems** that weren't properly connected:
1. **Page Blueprint** (`PageBlueprint.blocks_json`) - Contains placeholder/sample blocks from AI structure generation
2. **Writer Content** (`Content` model) - Contains actual generated content from Writer tasks
**The disconnect**: When deploying a site, it only used `PageBlueprint.blocks_json` (placeholders), NOT the actual `Content` from Writer.
## Current Workflow (How It Works Now)
### Step 1: Structure Generation
- AI generates site structure → Creates `SiteBlueprint` with `PageBlueprint` pages
- Each `PageBlueprint` has `blocks_json` with **placeholder/sample blocks**
### Step 2: Content Generation
- Pages are sent to Writer as `Tasks` (title pattern: `[Site Builder] {Page Title}`)
- Writer generates actual content → Creates `Content` records
- `Content` has `html_content` and `json_blocks` with **real content**
### Step 3: Publishing Status
- **Page Blueprint Status** (`PageBlueprint.status`): Set to `'published'` in Page Manager
- Controls if page appears in navigation and is accessible
- **Content Status** (`Content.status`): Set to `'publish'` in Content Manager
- Controls if actual written content is used (vs placeholders)
### Step 4: Deployment (FIXED)
- When you deploy, `SitesRendererAdapter._build_site_definition()` now:
1. For each page, finds the associated Writer Task (by title pattern)
2. Finds the Content record for that task
3. **If Content exists and status is 'publish'**, uses `Content.json_blocks` instead of `PageBlueprint.blocks_json`
4. If Content has `html_content` but no `json_blocks`, converts it to a text block
5. Uses the merged/actual content blocks for deployment
## URLs
- **Public Site URL**: `https://sites.igny8.com/{siteSlug}`
- Shows deployed site with actual content (if Content is published)
- Falls back to blueprint placeholders if Content not published
- **Individual Pages**: `https://sites.igny8.com/{siteSlug}/{pageSlug}`
- Example: `https://sites.igny8.com/auto-g8/products`
## How To Use It Now
1. **Generate Structure**: Create site blueprint with pages (has placeholder blocks)
2. **Generate Content**: Pages → Tasks → Content (Writer generates real content)
3. **Publish Content**: In Content Manager, set Content status to `'publish'`
4. **Publish Pages**: In Page Manager, set Page status to `'published'` (for navigation)
5. **Deploy Site**: Deploy the blueprint - it will automatically use published Content
## What Changed
**Fixed**: `SitesRendererAdapter._build_site_definition()` now merges published Content into PageBlueprint blocks during deployment
**Result**: When you deploy, the site shows actual written content, not placeholders
## Important Notes
- **Two Statuses**: Page status controls visibility, Content status controls which content is used
- **Deployment Required**: After publishing Content, you need to **redeploy** the site for changes to appear
- **Content Takes Precedence**: If Content is published, it replaces blueprint placeholders
- **Fallback**: If Content not published, blueprint placeholders are used