# Script 2: Generate Prompt Templates and Start Script 3
import json
import random
import subprocess
import os

def load_customer_data(filename='customer_data.json'):
    with open(filename, 'r') as file:
        return json.load(file)

def generate_prompt(templates, data):
    template = random.choice(templates)
    prompt = template.format(
        style=random.choice(data['preferences']['styles']),
        product_service=random.choice(data['business_info']['products_services']),
        color_scheme=random.choice(data['preferences']['color_schemes']),
        business_value=random.choice(data['business_info']['business_values']),
        target_audience=random.choice(data['business_info']['target_audience']),
        mood=random.choice(data['preferences']['moods']),
        business_type=data['business_info']['business_type'],
        business_name=data['business_info']['business_name']
    )
    return prompt

def generate_prompts(data, num_prompts=5):
    templates = [
        "A {style} illustration of {product_service} in {color_scheme} colors, conveying {business_value}, suitable for {target_audience}.",
        "An image with a {mood} atmosphere depicting {business_type} focused on {product_service}, styled in {style}.",
        "Creative representation of {product_service} for {business_name} in {style} style and {color_scheme} scheme.",
        "Artistic {style} portrayal of {business_value} through {product_service}, aimed at {target_audience}."
    ]
    prompts = []
    for _ in range(num_prompts):
        prompt_text = generate_prompt(templates, data)
        prompt = {
            "prompt_text": prompt_text,
            "negative_keywords": data['keywords_info']['negative_keywords'],
            "image_settings": data['image_settings']
        }
        prompts.append(prompt)
    return prompts

def save_prompts(prompts, filename='prompts.json'):
    with open(filename, 'w') as file:
        json.dump({"prompts": prompts}, file, indent=4)
    print(f"\nPrompts saved to {filename}")

def start_script_3():
    print("\nStarting Script 3...")
    # Adjusted to use python3 explicitly
    subprocess.Popen(['python3', 'script3.py'], env=os.environ)

def main():
    data = load_customer_data()
    prompts = generate_prompts(data)
    save_prompts(prompts)
    start_script_3()

if __name__ == "__main__":
    main()
_final/automated_image_generator root# python3 script3.py

Generating image 1...
Prompt: An image with a Bold atmosphere depicting online slots focused on online slot machines, styled in Futuristic.
Parameters: {'negative_prompt': 'kids, chrildren, baby, babiies, teenager, under 18 years old', 'width': 1024, 'height': 1024, 'format': 'png'}
Error 400: {"error":"__call__() got an unexpected keyword argument 'negative_prompt'"}

Generating image 2...
Prompt: An image with a Playful atmosphere depicting online slots focused on online slots provider, styled in Fantasy.
Parameters: {'negative_prompt': 'kids, chrildren, baby, babiies, teenager, under 18 years old', 'width': 1024, 'height': 1024, 'format': 'png'}
Error 400: {"error":"__call__() got an unexpected keyword argument 'negative_prompt'"}

Generating image 3...
Prompt: A Vintage illustration of online slot machines in Cool Colors colors, conveying winning, suitable for online slots gaming.
Parameters: {'negative_prompt': 'kids, chrildren, baby, babiies, teenager, under 18 years old', 'width': 1024, 'height': 1024, 'format': 'png'}
Error 400: {"error":"__call__() got an unexpected keyword argument 'negative_prompt'"}

Generating image 4...
Prompt: Creative representation of play from anywhere slots for Game Changer Gaming in 3D Render style and Cool Colors scheme.
Parameters: {'negative_prompt': 'kids, chrildren, baby, babiies, teenager, under 18 years old', 'width': 1024, 'height': 1024, 'format': 'png'}
Error 400: {"error":"__call__() got an unexpected keyword argument 'negative_prompt'"}

Generating image 5...
Prompt: Creative representation of online slot machines for Game Changer Gaming in Fantasy style and Warm Colors scheme.
Parameters: {'negative_prompt': 'kids, chrildren, baby, babiies, teenager, under 18 years old', 'width': 1024, 'height': 1024, 'format': 'png'}
Error 400: {"error":"__call__() got an unexpected keyword argument 'negative_prompt'"} this shouldn't call all templates it should randomly choose one template that is randomly created with the templates available and the negative keywords need to be removed