Add confidence_score field to save_data function for enhanced data tracking
Browse files
main.py
CHANGED
@@ -345,7 +345,8 @@ async def save_data(
|
|
345 |
"retrieved_text": [],
|
346 |
"model_type": [],
|
347 |
"reaction": [],
|
348 |
-
"timestamp": []
|
|
|
349 |
}
|
350 |
|
351 |
# Add each item to the data dict
|
@@ -357,6 +358,7 @@ async def save_data(
|
|
357 |
data["model_type"].append(item.model_type)
|
358 |
data["reaction"].append(item.reaction)
|
359 |
data["timestamp"].append(datetime.now(timezone.utc).isoformat().replace('+00:00', 'Z'))
|
|
|
360 |
|
361 |
try:
|
362 |
# Load existing dataset and merge
|
@@ -369,7 +371,10 @@ async def save_data(
|
|
369 |
# Add new data
|
370 |
for key in data:
|
371 |
if key not in existing_data:
|
372 |
-
existing_data[key] = [
|
|
|
|
|
|
|
373 |
existing_data[key].extend(data[key])
|
374 |
|
375 |
except Exception as e:
|
|
|
345 |
"retrieved_text": [],
|
346 |
"model_type": [],
|
347 |
"reaction": [],
|
348 |
+
"timestamp": [],
|
349 |
+
"confidence_score": []
|
350 |
}
|
351 |
|
352 |
# Add each item to the data dict
|
|
|
358 |
data["model_type"].append(item.model_type)
|
359 |
data["reaction"].append(item.reaction)
|
360 |
data["timestamp"].append(datetime.now(timezone.utc).isoformat().replace('+00:00', 'Z'))
|
361 |
+
data["confidence_score"].append(item.get("confidence_score", 0.0))
|
362 |
|
363 |
try:
|
364 |
# Load existing dataset and merge
|
|
|
371 |
# Add new data
|
372 |
for key in data:
|
373 |
if key not in existing_data:
|
374 |
+
existing_data[key] = [
|
375 |
+
"" if key in ["timestamp"] else
|
376 |
+
0.0 if key in ["confidence_score"] else None
|
377 |
+
] * len(next(iter(existing_data.values())))
|
378 |
existing_data[key].extend(data[key])
|
379 |
|
380 |
except Exception as e:
|