rosemariafontana commited on
Commit
1b9c64b
·
verified ·
1 Parent(s): 3fe8c14

Update script_for_automation.py

Browse files
Files changed (1) hide show
  1. script_for_automation.py +63 -0
script_for_automation.py CHANGED
@@ -299,7 +299,70 @@ def get_data_ready(recipe_dict, input_data_piece):
299
 
300
  return processed_data
301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
 
304
 
305
  def drive_process():
 
299
 
300
  return processed_data
301
 
302
+ def generate_markdown_output(df):
303
+ # Start the markdown output string
304
+ markdown = ""
305
+
306
+ # Table for Recipe Fields (recipe_id to prompting_strategy)
307
+ markdown += "### Recipe Fields (Basic Information)\n"
308
+ markdown += "| Recipe ID | Testing Strategy | Schema Processing Model | Pre-Processing Strategy | Pre-Processing Text | Pre-Processing Model | Prompting Strategy |\n"
309
+ markdown += "|-----------|------------------|-------------------------|--------------------------|---------------------|----------------------|-------------------|\n"
310
+
311
+ # Iterate over rows to create the first table (recipe_id to prompting_strategy)
312
+ for _, row in df.iterrows():
313
+ markdown += 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"
314
+
315
+ # Separate section for Prompts
316
+ markdown += "\n### Prompts\n"
317
+ markdown += "| Plantings and Fields Prompt | Interactions Prompt | Treatments Prompt |\n"
318
+ markdown += "|-----------------------------|---------------------|-------------------|\n"
319
+
320
+ # Iterate over rows to create the second table (plantings_and_fields_prompt, interactions_prompt, treatments_prompt)
321
+ for _, row in df.iterrows():
322
+ markdown += f"| {row['Plantings_and_Fields_Prompt']} | {row['Interactions_Prompt']} | {row['Treatments_Prompt']} |\n"
323
+
324
+ # Separate section for Input Transcript
325
+ markdown += "\n### Input Transcript\n"
326
+ markdown += "Since the input transcript might be very long, it is truncated here for readability:\n"
327
 
328
+ # Display a truncated version of the input transcript to avoid long text in the table
329
+ for _, row in df.iterrows():
330
+ truncated_input = (row['Input_Transcript'][:500] + '...') if len(row['Input_Transcript']) > 500 else row['Input_Transcript']
331
+ markdown += f"**Recipe ID {row['Recipe_ID']}**: {truncated_input}\n\n"
332
+
333
+ # Side-by-side comparison of Gold Standard and Machine Generated Key-Values
334
+ markdown += "\n### Gold Standard vs Machine Generated Key-Values\n"
335
+ markdown += "| Key | Gold Standard | Machine Generated |\n"
336
+ markdown += "|-----|---------------|-------------------|\n"
337
+
338
+ # Iterate over rows to create the comparison table
339
+ for _, row in df.iterrows():
340
+ markdown += f"| {row['Recipe_ID']} | {row['Gold_Standard_Key_Values']} | {row['Machine_Generated_Key_Values']} |\n"
341
+
342
+ # Display differences in a readable format
343
+ markdown += "\n### Differences\n"
344
+ markdown += "The following differences were found between the gold standard and the machine-generated output:\n"
345
+ markdown += "| Key | Difference |\n"
346
+ markdown += "|-----|------------|\n"
347
+
348
+ for _, row in df.iterrows():
349
+ # Assuming 'Differences' is a list of dictionaries with keys and changes
350
+ differences = json.loads(row['Differences'])
351
+ for diff in differences:
352
+ if diff.get("values_changed"):
353
+ for change in diff["values_changed"]:
354
+ markdown += f"| {change['path']} | {change['old_value']} -> {change['new_value']} |\n"
355
+
356
+ # Side-by-side YAML comparison for human visual inspection
357
+ markdown += "\n### Gold Standard vs Machine Generated YAML\n"
358
+ markdown += "| Gold Standard YAML | Machine Generated YAML |\n"
359
+ markdown += "|--------------------|------------------------|\n"
360
+
361
+ # Add the side-by-side YAML comparison
362
+ for _, row in df.iterrows():
363
+ markdown += f"| ```yaml\n{row['Gold_Standard_YAML']}\n``` | ```yaml\n{row['Machine_Generated_YAML']}\n``` |\n"
364
+
365
+ return markdown
366
 
367
 
368
  def drive_process():