-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated readme, requirements, validation
- Loading branch information
1 parent
cf15f35
commit 4477d01
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
numpy==1.26.2 | ||
pandas==2.1.4 | ||
python-dateutil==2.8.2 | ||
pytz==2023.3.post1 | ||
six==1.16.0 | ||
tzdata==2023.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pandas as pd | ||
import ast | ||
|
||
INJECTION_DATA_PATH = "prompt_injections.csv" | ||
GISKARD_META_PATH = "giskard_meta_data.csv" | ||
|
||
def _check_matching_dfs_len(df1, df2): | ||
if len(df1) != len(df2): | ||
raise ValueError( | ||
f"{__name__}: {INJECTION_DATA_PATH} and {GISKARD_META_PATH} should " | ||
"have the same length and should be a one-to-one mapping of each other." | ||
) | ||
|
||
def _check_meta_df_requirements(df): | ||
if "expected_strings" not in df.columns: | ||
raise ValueError(f"{__name__}: expected_strings are needed for the evaluation.") | ||
|
||
if df.expected_strings.isnull().values.any(): | ||
raise ValueError(f"{__name__}: expected_strings column cannot have any NaN values.") | ||
df.expected_strings = df.expected_strings.apply(ast.literal_eval) | ||
|
||
|
||
if __name__ == "__main__": | ||
prompt_injections_df = pd.read_csv(INJECTION_DATA_PATH, index_col=["index"]) | ||
meta_df = pd.read_csv(GISKARD_META_PATH, index_col=["index"]) | ||
_check_matching_dfs_len(meta_df, prompt_injections_df) | ||
_check_meta_df_requirements(meta_df) | ||
print("Validation passed succesfully!") |