import anthropic import os from dotenv import load_dotenv import json load_dotenv() def get_data_for_page(page: str): print(f"Getting data for page: {page}") client = anthropic.Anthropic() prompt = f"""Given this use case for a song: "{page}", provide data for a landing page promoting Suno AI's song generation capabilities. Format the response as JSON with these fields: - title: A concise SEO-friendly page title - headline: An engaging headline for the landing page - song_prompts: List of 3-5 example prompts users could try with Suno - image_prompts: List of 3-5 prompts for generating relevant imagery - url_slug: An SEO-friendly URL path - description: A compelling 3-5 sentence description of how Suno can help with this use case""" message = client.messages.create( model="claude-3-7-sonnet-20250219", max_tokens=1000, temperature=1, system="We are building a landing page for Suno AI. Always talk about how users create songs. Suno doesn't create the songs, the users do. Respond only with the JSON object.", messages=[ { "role": "user", "content": [ { "type": "text", "text": prompt } ] } ] ) data = message.content json_str = data[0].text.strip('```json\n').strip('```') json_data = json.loads(json_str) json_data['page'] = page return(json_data) def read_seeds_file(): try: with open('seeds.md', 'r', encoding='utf-8') as file: content = file.readlines() current_section = None for line_number, line in enumerate(content, 1): line = line.strip() if not line: continue if line.startswith(('#', 'a.', 'b.', 'c.', 'd.', 'e.', 'f.')): current_section = line.split('.')[0] continue page = line.split('. ')[1] json_data = get_data_for_page(page) # Save each page's data to data.json try: with open(f'./json-files/{current_section}.{line_number}.json', 'w', encoding='utf-8') as f: json.dump(json_data, f, indent=4) except Exception as e: print(f"Error saving to data.json: {e}") except FileNotFoundError: print("Error: seeds.md file not found") except Exception as e: print(f"An error occurred: {e}") if __name__ == "__main__": read_seeds_file()