Update script_for_automation.py
Browse files- script_for_automation.py +21 -2
script_for_automation.py
CHANGED
|
@@ -373,13 +373,32 @@ def generate_markdown_output(df):
|
|
| 373 |
recipe_table += f"| {row['Recipe_ID']} | {row['Testing_Strategy_Text']} | {row['Schema_Processing_Model']} | {row['Pre_Processing_Strategy']} | {row['Pre_Processing_Text']} | {row['Pre_Processing_Model']} | {row['Prompting_Strategy']} |\n"
|
| 374 |
markdown += recipe_table + "\n"
|
| 375 |
|
| 376 |
-
|
| 377 |
markdown += "\n## Differences\n"
|
| 378 |
for _, row in df.iterrows():
|
| 379 |
markdown += f"\n### Recipe ID: {row['Recipe_ID']}\n"
|
| 380 |
differences = row['Differences']
|
|
|
|
|
|
|
| 381 |
for key, diff in differences.items():
|
| 382 |
-
markdown += f"#### {key.capitalize()}\n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
|
| 384 |
# 4. Prompts
|
| 385 |
markdown += "\n## Prompts\n"
|
|
|
|
| 373 |
recipe_table += f"| {row['Recipe_ID']} | {row['Testing_Strategy_Text']} | {row['Schema_Processing_Model']} | {row['Pre_Processing_Strategy']} | {row['Pre_Processing_Text']} | {row['Pre_Processing_Model']} | {row['Prompting_Strategy']} |\n"
|
| 374 |
markdown += recipe_table + "\n"
|
| 375 |
|
| 376 |
+
# 3. Differences
|
| 377 |
markdown += "\n## Differences\n"
|
| 378 |
for _, row in df.iterrows():
|
| 379 |
markdown += f"\n### Recipe ID: {row['Recipe_ID']}\n"
|
| 380 |
differences = row['Differences']
|
| 381 |
+
|
| 382 |
+
# Loop through all differences and display them
|
| 383 |
for key, diff in differences.items():
|
| 384 |
+
markdown += f"#### {key.capitalize()}\n"
|
| 385 |
+
|
| 386 |
+
# If diff is a string, check if it's a JSON-like string
|
| 387 |
+
if isinstance(diff, str):
|
| 388 |
+
try:
|
| 389 |
+
# Check if it's a valid JSON string by trying to load it
|
| 390 |
+
parsed_json = json.loads(diff)
|
| 391 |
+
# If successful, pretty print it as JSON
|
| 392 |
+
markdown += f"```\n{json.dumps(parsed_json, indent=2)}\n```\n"
|
| 393 |
+
except json.JSONDecodeError:
|
| 394 |
+
# If it's not valid JSON, just output the string as it is
|
| 395 |
+
markdown += f"{diff}\n"
|
| 396 |
+
elif isinstance(diff, (dict, list)):
|
| 397 |
+
# If diff is already a dict or list, just pretty-print it
|
| 398 |
+
markdown += f"```\n{json.dumps(diff, indent=2)}\n```\n"
|
| 399 |
+
else:
|
| 400 |
+
# For other types, convert them into string format
|
| 401 |
+
markdown += f"{custom_serializer(diff)}\n"
|
| 402 |
|
| 403 |
# 4. Prompts
|
| 404 |
markdown += "\n## Prompts\n"
|