Spaces:
Sleeping
Sleeping
| import yaml | |
| def load_prompts(): | |
| files = ["config/base.yml", "config/contenteval.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) | |
| merged_prompts = {str(k): _to_str(v) for k, v in merged.items()} | |
| print(merged_prompts) | |
| return {str(k): _to_str(v) for k, v in merged.items()} | |