Update app.py
Browse files
app.py
CHANGED
|
@@ -239,18 +239,27 @@ def extract_validation_metrics(validation_text):
|
|
| 239 |
|
| 240 |
if start_idx != -1 and end_idx != -1 and start_idx < end_idx:
|
| 241 |
json_str = validation_text[start_idx:end_idx]
|
| 242 |
-
|
|
|
|
| 243 |
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
except Exception as e:
|
| 255 |
print(f"Error extracting metrics: {e}")
|
| 256 |
return None
|
|
|
|
| 239 |
|
| 240 |
if start_idx != -1 and end_idx != -1 and start_idx < end_idx:
|
| 241 |
json_str = validation_text[start_idx:end_idx]
|
| 242 |
+
# Print for debugging
|
| 243 |
+
print("Extracted JSON:", json_str)
|
| 244 |
|
| 245 |
+
try:
|
| 246 |
+
data = json.loads(json_str)
|
| 247 |
+
|
| 248 |
+
# Extract the required metrics with default values
|
| 249 |
+
metrics = {
|
| 250 |
+
"quality_rating": float(data.get("quality_rating", 0)),
|
| 251 |
+
"accuracy": float(data.get("accuracy", 0.0)),
|
| 252 |
+
"completeness": float(data.get("completeness", 0.0)),
|
| 253 |
+
"best_practices_alignment": float(data.get("best_practices_alignment", 0.0))
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
return metrics
|
| 257 |
+
except json.JSONDecodeError as je:
|
| 258 |
+
print(f"JSON decode error: {je}")
|
| 259 |
+
return None
|
| 260 |
+
else:
|
| 261 |
+
print("No JSON found in validation text")
|
| 262 |
+
return None
|
| 263 |
except Exception as e:
|
| 264 |
print(f"Error extracting metrics: {e}")
|
| 265 |
return None
|