Skip to content

Commit

Permalink
Handle missing report exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sternakt committed Nov 28, 2024
1 parent 1ab5d0c commit f38908a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions prompt_leakage_probing/workflow/tools/log_prompt_leakage.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,21 @@ def generate_markdown_report(
"""Generate a Markdown report."""
level_emojis = {0: "🟢", 1: "🟡", 2: "🟠", 3: "🔴", 4: "🔥"}

# Load and validate log data
df = pd.read_csv(log_path)

# Generate Markdown content
markdown_report = f"# Prompt Leakage Test Report for {name}\n\n"
markdown_report += generate_summary_table(df, level_emojis)

markdown_report += "\n## Detailed Reports per Model\n\n"
for model_name, model_df in df.groupby("model_name"):
markdown_report += generate_model_details(
model_name, model_df, level_emojis, success_threshold
)
# Load and validate log data, handle gracefully if the file does not exist
try:
df = pd.read_csv(log_path)

markdown_report += generate_summary_table(df, level_emojis)

markdown_report += "\n## Detailed Reports per Model\n\n"
for model_name, model_df in df.groupby("model_name"):
markdown_report += generate_model_details(
model_name, model_df, level_emojis, success_threshold
)
except FileNotFoundError:
# Handle the case where the file does not exist
markdown_report = "The report file does not yet exist, try running the probe for this scenario first.\n"

return markdown_report

0 comments on commit f38908a

Please sign in to comment.