3.4 KiB
3.4 KiB
Expected Response Structure for generate_images_from_prompts
Function Flow
-
Frontend calls:
POST /v1/writer/images/generate_images/with{ ids: [1, 2, 3] } -
Backend ViewSet (
ImagesViewSet.generate_images):- Calls
run_ai_taskwithfunction_name='generate_images_from_prompts' - Returns response with
queued_promptsif in TEST MODE
- Calls
-
AIEngine.execute:
- Validates, prepares, builds prompt (placeholder), parses (placeholder)
- Calls
save_outputwhich queues prompts (TEST MODE)
-
GenerateImagesFromPromptsFunction.save_output:
- Returns dict with queued prompts
Response Structure (TEST MODE)
{
"success": true,
"count": 3,
"images_generated": 0,
"images_failed": 0,
"total_images": 3,
"queued_prompts": [
{
"image_id": 1,
"index": 1,
"image_type": "featured_image",
"content_title": "Your Content Title",
"provider": "openai",
"model": "dall-e-2",
"formatted_prompt": "Create a high-quality realistic image to use as a featured photo for a blog post titled \"Your Content Title\". The image should visually represent the theme, mood, and subject implied by the image prompt: [original prompt]. Focus on a realistic, well-composed scene that naturally communicates the topic without text or logos...",
"negative_prompt": null,
"prompt_length": 250
},
{
"image_id": 2,
"index": 2,
"image_type": "in_article_1",
"content_title": "Your Content Title",
"provider": "openai",
"model": "dall-e-2",
"formatted_prompt": "...",
"negative_prompt": null,
"prompt_length": 245
}
],
"test_mode": true,
"provider": "openai",
"model": "dall-e-2",
"errors": null
}
Response Structure (Production Mode - when AI calls are enabled)
{
"success": true,
"count": 3,
"images_generated": 3,
"images_failed": 0,
"total_images": 3,
"errors": null
}
Key Points
-
TEST MODE (current):
images_generated: 0(no actual images generated)queued_promptsarray contains all formatted promptstest_mode: true- Each prompt includes the complete formatted prompt that would be sent to AI
-
Production MODE (when AI calls are uncommented):
images_generatedwill be > 0queued_promptswill not be in responsetest_mode: falseor not present- Images will have
image_urlandstatus='generated'
Console Logging
The function logs to console (if DEBUG_MODE=True):
[generate_images_from_prompts] [TEST MODE] Queued prompt X/Y[generate_images_from_prompts] [TEST MODE] Provider: openai, Model: dall-e-2[generate_images_from_prompts] [TEST MODE] Prompt length: 250 chars[generate_images_from_prompts] [TEST MODE] Prompt preview: ...
Frontend Console Output
When clicking "Generate Images", browser console will show:
[Generate Images] Request: { imageIds: [1, 2, 3], count: 3 }
[Generate Images] Endpoint: /v1/writer/images/generate_images/
[Generate Images] Full Response: { success: true, queued_prompts: [...], ... }
[Generate Images] Queued Prompts (TEST MODE - NOT sent to AI): [...]
[Generate Images] Provider: openai, Model: dall-e-2
[Generate Images] Prompt 1/3:
- Image Type: featured_image
- Content: "Your Content Title"
- Prompt Length: 250 chars
- Full Prompt: "Create a high-quality realistic image..."