import csv
import json

# Define the constant values
constant_values = {
    "steps": "40",
    "cfgscale": "7",
    "sampler": "uni_pc",
    "scheduler": "normal",
    "sdtextencs": "CLIP + T5"
}

# Read the CSV file
csv_file = 'styles.csv'
json_data = {}

with open(csv_file, mode='r') as file:
    csv_reader = csv.DictReader(file)
    for row in csv_reader:
        name = row['name']
        formatted_prompt = row['prompt'].replace("{prompt}", "{value}")
        
        json_data[name] = {
            "author": "local",
            "title": name,
            "description": name,
            "param_map": {
                "prompt": formatted_prompt,
                "negativeprompt": row['negative_prompt'],
                **constant_values
            }
        }

# Write the JSON data to a file
with open('Fooocus_All_Presets_For_StableSwarmUI.json', mode='w') as file:
    json.dump(json_data, file, indent=4)

print("CSV data has been converted to JSON and saved to Fooocus_All_Presets_For_StableSwarmUI.json")