Skip to content

Commit cec59c8

Browse files
sahilds1TineoC
authored andcommitted
Check if the required columns are present
1 parent 3de54bb commit cec59c8

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

server/api/services/evals.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ def evaluate_response(
8888
# Remove the trailing whitespace from column names
8989
df_config.columns = df_config.columns.str.strip()
9090

91-
# TODO: Check if the required columns are present
91+
# Check if the required columns are present
92+
required_columns = ["Model Name", "Query"]
93+
if not all(col in df_config.columns for col in required_columns):
94+
raise ValueError(
95+
f"Config DataFrame must contain the following columns: {required_columns}"
96+
)
9297

9398
# Check if all models in the config are supported by ModelFactory
9499
if not all(
@@ -103,6 +108,15 @@ def evaluate_response(
103108
logging.info(f"Reference DataFrame shape: {df_reference.shape}")
104109
logging.info(f"Reference DataFrame columns: {df_reference.columns.tolist()}")
105110

111+
# Remove the trailing whitespace from column names
112+
df_reference.columns = df_reference.columns.str.strip()
113+
# Check if the required columns are present
114+
required_columns = ["Context", "Reference"]
115+
if not all(col in df_reference.columns for col in required_columns):
116+
raise ValueError(
117+
f"Reference DataFrame must contain the following columns: {required_columns}"
118+
)
119+
106120
# Cross join the config and reference DataFrames
107121
df_in = df_config.merge(df_reference, how="cross")
108122

0 commit comments

Comments
 (0)