lokeessshhhh commited on
Commit
f0baba4
·
verified ·
1 Parent(s): d9da53f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -20,10 +20,17 @@ final_answer = FinalAnswer()
20
  with open(os.path.join(CURRENT_DIR, "prompts.yaml"), "r") as f:
21
  prompt_templates = yaml.safe_load(f)
22
 
23
- # 2) Flatten EVERYTHING into strings
24
- for key, val in prompt_templates.items():
25
- if not isinstance(val, str):
26
- prompt_templates[key] = yaml.safe_dump(val, default_flow_style=False)
 
 
 
 
 
 
 
27
 
28
  agent = CodeAgent(
29
  model=model,
 
20
  with open(os.path.join(CURRENT_DIR, "prompts.yaml"), "r") as f:
21
  prompt_templates = yaml.safe_load(f)
22
 
23
+ # 2) Recursively stringify any non-str leaves, preserving nested dicts
24
+ def stringify_leaves(obj):
25
+ if isinstance(obj, dict):
26
+ return { k: stringify_leaves(v) for k, v in obj.items() }
27
+ elif isinstance(obj, list):
28
+ # join lists of things into one big string
29
+ return "".join(stringify_leaves(v) for v in obj)
30
+ else:
31
+ return str(obj)
32
+
33
+ prompt_templates = stringify_leaves(raw_templates)
34
 
35
  agent = CodeAgent(
36
  model=model,