rosemariafontana commited on
Commit
1a3f77c
·
verified ·
1 Parent(s): dc2d686

Update script_for_automation.py

Browse files
Files changed (1) hide show
  1. script_for_automation.py +26 -20
script_for_automation.py CHANGED
@@ -389,26 +389,32 @@ def generate_markdown_output(df):
389
  markdown += f"\n### Recipe ID: {row['Recipe_ID']}\n"
390
  differences = row['Differences']
391
 
392
- # Loop through all differences and display them
393
- for key, diff in differences.items():
394
- markdown += f"#### {key.capitalize()}\n"
395
-
396
- # If diff is a string, check if it's a JSON-like string
397
- if isinstance(diff, str):
398
- try:
399
- # Check if it's a valid JSON string by trying to load it
400
- parsed_json = json.loads(diff)
401
- # If successful, pretty print it as JSON
402
- markdown += f"```\n{json.dumps(parsed_json, indent=2)}\n```\n"
403
- except json.JSONDecodeError:
404
- # If it's not valid JSON, just output the string as it is
405
- markdown += f"{diff}\n"
406
- elif isinstance(diff, (dict, list)):
407
- # If diff is already a dict or list, just pretty-print it
408
- markdown += f"```\n{json.dumps(diff, indent=2)}\n```\n"
409
- else:
410
- # For other types, convert them into string format
411
- markdown += f"{custom_serializer(diff)}\n"
 
 
 
 
 
 
412
 
413
  # 4. Prompts
414
  markdown += "\n## Prompts\n"
 
389
  markdown += f"\n### Recipe ID: {row['Recipe_ID']}\n"
390
  differences = row['Differences']
391
 
392
+ # Loop through the differences list
393
+ for diff in differences:
394
+ for key, value in diff.items():
395
+ markdown += f"#### {key.capitalize()}\n"
396
+
397
+ # If the value is a string, output the string
398
+ if isinstance(value, str):
399
+ markdown += f"{value}\n"
400
+
401
+ # If the value is a dictionary, pretty-print the dictionary
402
+ elif isinstance(value, dict):
403
+ markdown += "```\n"
404
+ for sub_key, sub_value in value.items():
405
+ markdown += f"{sub_key}: {sub_value}\n"
406
+ markdown += "```\n"
407
+
408
+ # If the value is a list, output the list items
409
+ elif isinstance(value, list):
410
+ markdown += "```\n"
411
+ for item in value:
412
+ markdown += f"{item}\n"
413
+ markdown += "```\n"
414
+
415
+ # For any other type, just print the value
416
+ else:
417
+ markdown += f"{value}\n"
418
 
419
  # 4. Prompts
420
  markdown += "\n## Prompts\n"