site updates
This commit is contained in:
22
projects/dev/python-prompt-crafting/main.py
Normal file
22
projects/dev/python-prompt-crafting/main.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import csv
|
||||
import random
|
||||
|
||||
def read_seeds(filename):
|
||||
seeds = {}
|
||||
with open(filename, newline='') as csvfile:
|
||||
reader = csv.DictReader(csvfile)
|
||||
for row in reader:
|
||||
category = row['Category']
|
||||
seed = row['Seed']
|
||||
if category not in seeds:
|
||||
seeds[category] = []
|
||||
seeds[category].append(seed)
|
||||
return seeds
|
||||
|
||||
def generate_prompt(seeds):
|
||||
prompt_parts = [random.choice(seeds[category]) for category in seeds]
|
||||
return f"A wallpaper with a {' '.join(prompt_parts)}."
|
||||
|
||||
# Reading seeds from a CSV file and generating a prompt
|
||||
seeds = read_seeds('seeds.csv')
|
||||
print(generate_prompt(seeds))
|
||||
Reference in New Issue
Block a user