import openai
client = openai.OpenAI(api_key="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")
example_path = "example.json"
with open(example_path, 'r') as f: example_json_format = f.read()

# Create chat prompt
count=2
scene_desc="a beauitful serene garden scene"
chat_prompt = f"""
Please generate a JSON file with {count} objects based on the scene description:
"{scene_desc}"
Match the structure and field names exactly as shown in this example:
{example_json_format}
Each object should include a `prompt` field for text-to-image generation, describing the object in high-quality detail.
Make sure:
- Each prompt describes a **single, complete, and centered object**
- The object should be **clearly separated from the background** (object-level focus)
- Use words like "isolated," "on a plain white background," or "studio-lit" to ensure easy background removal
- Avoid describing scenes or background elements
- The object should have a **clear contour** and be **fully visible** (no parts cropped or occluded)
Only return JSON. No extra explanation.
"""
response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": chat_prompt}], temperature=0.7,)
json_result = response.choices[0].message.content
print(json_result)
with open("out/scene.json", 'w') as f: f.write(json_result)
