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

@@ -36,6 +36,8 @@ class AIEngine:
return f"{count} task{'s' if count != 1 else ''}"
elif function_name == 'generate_site_structure':
return "1 site blueprint"
elif function_name == 'generate_page_content':
return f"{count} page{'s' if count != 1 else ''}"
return f"{count} item{'s' if count != 1 else ''}"
def _build_validation_message(self, function_name: str, payload: dict, count: int, input_description: str) -> str:
@@ -86,8 +88,11 @@ class AIEngine:
blueprint_name = ''
if isinstance(data, dict):
blueprint = data.get('blueprint')
blueprint_name = f"{getattr(blueprint, 'name', '')}" if blueprint and getattr(blueprint, 'name', None) else ''
if blueprint and getattr(blueprint, 'name', None):
blueprint_name = f'"{blueprint.name}"'
return f"Preparing site blueprint {blueprint_name}".strip()
elif function_name == 'generate_page_content':
return f"Preparing {count} page{'s' if count != 1 else ''} for content generation"
return f"Preparing {count} item{'s' if count != 1 else ''}"
def _get_ai_call_message(self, function_name: str, count: int) -> str:
@@ -102,6 +107,8 @@ class AIEngine:
return f"Creating image{'s' if count != 1 else ''} with AI"
elif function_name == 'generate_site_structure':
return "Designing complete site architecture"
elif function_name == 'generate_page_content':
return f"Generating structured page content"
return f"Processing with AI"
def _get_parse_message(self, function_name: str) -> str:
@@ -116,6 +123,8 @@ class AIEngine:
return "Processing images"
elif function_name == 'generate_site_structure':
return "Compiling site map"
elif function_name == 'generate_page_content':
return "Structuring content blocks"
return "Processing results"
def _get_parse_message_with_count(self, function_name: str, count: int) -> str:
@@ -136,6 +145,8 @@ class AIEngine:
return "Writing Inarticle Image Prompts"
elif function_name == 'generate_site_structure':
return f"{count} page blueprint{'s' if count != 1 else ''} mapped"
elif function_name == 'generate_page_content':
return f"{count} page{'s' if count != 1 else ''} with structured blocks"
return f"{count} item{'s' if count != 1 else ''} processed"
def _get_save_message(self, function_name: str, count: int) -> str:
@@ -153,6 +164,8 @@ class AIEngine:
return f"Assigning {count} Prompts to Dedicated Slots"
elif function_name == 'generate_site_structure':
return f"Publishing {count} page blueprint{'s' if count != 1 else ''}"
elif function_name == 'generate_page_content':
return f"Saving {count} page{'s' if count != 1 else ''} with content blocks"
return f"Saving {count} item{'s' if count != 1 else ''}"
def execute(self, fn: BaseAIFunction, payload: dict) -> dict: