Spaces:
Sleeping
Sleeping
File size: 788 Bytes
1a4ef4f 42ae0c5 4a7f58e 42ae0c5 1a4ef4f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import yaml
def load_prompts():
files = ["config/prompts.yaml", "config/contentprompts.yml"]
merged = {}
for path in files:
with open(path, "r", encoding="utf-8") as f:
data = yaml.safe_load(f) or {}
if isinstance(data, dict):
merged.update(data)
def _to_str(v):
if v is None:
return "" # avoid literal "None"
if isinstance(v, str):
return v
if isinstance(v, dict) and "content" in v:
return str(v["content"]) # flatten chat-style entries
if isinstance(v, (list, tuple)):
return "\n".join(map(str, v)) # readable multiline
return str(v)
return {str(k): _to_str(v) for k, v in merged.items()}
|