File size: 914 Bytes
1a4ef4f
42ae0c5
 
18c94d5
4a7f58e
 
 
 
 
 
42ae0c5
1a4ef4f
 
 
 
 
 
 
 
 
 
 
7db517f
 
 
 
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
25
26
27
28
import yaml

def load_prompts():
    files = ["prompts/base.yml", "prompts/contenteval.yml",  "prompts/planning.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()}