Spaces:
Build error
Build error
Update script_for_automation.py
Browse files298 unmodified lines299300301302303304305298 unmodified linesreturn processed_datadef drive_process():298 unmodified lines299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368298 unmodified linesreturn processed_datadef generate_markdown_output(df):# Start the markdown output stringmarkdown = ""# Table for Recipe Fields (recipe_id to prompting_strategy)markdown += "### Recipe Fields (Basic Information)\n"markdown += "| Recipe ID | Testing Strategy | Schema Processing Model | Pre-Processing Strategy | Pre-Processing Text | Pre-Processing Model | Prompting Strategy |\n"markdown += "|-----------|------------------|-------------------------|--------------------------|---------------------|----------------------|-------------------|\n"# Iterate over rows to create the first table (recipe_id to prompting_strategy)for _, row in df.iterrows():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"# Separate section for Promptsmarkdown += "\n### Prompts\n"markdown += "| Plantings and Fields Prompt | Interactions Prompt | Treatments Prompt |\n"markdown += "|-----------------------------|---------------------|-------------------|\n"# Iterate over rows to create the second table (plantings_and_fields_prompt, interactions_prompt, treatments_prompt)for _, row in df.iterrows():markdown += f"| {row['Plantings_and_Fields_Prompt']} | {row['Interactions_Prompt']} | {row['Treatments_Prompt']} |\n"# Separate section for Input Transcriptmarkdown += "\n### Input Transcript\n"markdown += "Since the input transcript might be very long, it is truncated here for readability:\n"# Display a truncated version of the input transcript to avoid long text in the tablefor _, row in df.iterrows():truncated_input = (row['Input_Transcript'][:500] + '...') if len(row['Input_Transcript']) > 500 else row['Input_Transcript']markdown += f"**Recipe ID {row['Recipe_ID']}**: {truncated_input}\n\n"# Side-by-side comparison of Gold Standard and Machine Generated Key-Valuesmarkdown += "\n### Gold Standard vs Machine Generated Key-Values\n"markdown += "| Key | Gold Standard | Machine Generated |\n"markdown += "|-----|---------------|-------------------|\n"# Iterate over rows to create the comparison tablefor _, row in df.iterrows():markdown += f"| {row['Recipe_ID']} | {row['Gold_Standard_Key_Values']} | {row['Machine_Generated_Key_Values']} |\n"# Display differences in a readable formatmarkdown += "\n### Differences\n"markdown += "The following differences were found between the gold standard and the machine-generated output:\n"markdown += "| Key | Difference |\n"markdown += "|-----|------------|\n"for _, row in df.iterrows():# Assuming 'Differences' is a list of dictionaries with keys and changesdifferences = json.loads(row['Differences'])for diff in differences:if diff.get("values_changed"):for change in diff["values_changed"]:markdown += f"| {change['path']} | {change['old_value']} -> {change['new_value']} |\n"# Side-by-side YAML comparison for human visual inspectionmarkdown += "\n### Gold Standard vs Machine Generated YAML\n"markdown += "| Gold Standard YAML | Machine Generated YAML |\n"markdown += "|--------------------|------------------------|\n"# Add the side-by-side YAML comparisonfor _, row in df.iterrows():markdown += f"| ```yaml\n{row['Gold_Standard_YAML']}\n``` | ```yaml\n{row['Machine_Generated_YAML']}\n``` |\n"return markdowndef drive_process():
script_for_automation.py+63