Ajaykanth Maddi commited on
Commit ·
aa531e0
1
Parent(s): 95fc507
Export Button UI Changes
Browse files
app.py
CHANGED
|
@@ -47,6 +47,7 @@ import datetime
|
|
| 47 |
from utils import (
|
| 48 |
form_document_sentences_from_chunks,
|
| 49 |
form_response_sentences,
|
|
|
|
| 50 |
)
|
| 51 |
|
| 52 |
from constants import (
|
|
@@ -212,7 +213,7 @@ def generate_file(subset_dropdown, dataset_type_dropdown,
|
|
| 212 |
"y_metrics": y_metrics_display,
|
| 213 |
"generated_answer": gen_ans_display,
|
| 214 |
"y_pred_metrics": y_pred_metrics_display,
|
| 215 |
-
"retrieved_chunks": chunks_retrieved_display,
|
| 216 |
"evaluator_json_output": evaluator_json_output
|
| 217 |
}
|
| 218 |
}
|
|
|
|
| 47 |
from utils import (
|
| 48 |
form_document_sentences_from_chunks,
|
| 49 |
form_response_sentences,
|
| 50 |
+
convert_to_serializable
|
| 51 |
)
|
| 52 |
|
| 53 |
from constants import (
|
|
|
|
| 213 |
"y_metrics": y_metrics_display,
|
| 214 |
"generated_answer": gen_ans_display,
|
| 215 |
"y_pred_metrics": y_pred_metrics_display,
|
| 216 |
+
"retrieved_chunks": convert_to_serializable(chunks_retrieved_display),
|
| 217 |
"evaluator_json_output": evaluator_json_output
|
| 218 |
}
|
| 219 |
}
|
utils.py
CHANGED
|
@@ -2,9 +2,11 @@ from nltk.tokenize import sent_tokenize
|
|
| 2 |
import re
|
| 3 |
import requests
|
| 4 |
import time
|
| 5 |
-
import logging
|
| 6 |
|
|
|
|
|
|
|
| 7 |
import nltk
|
|
|
|
| 8 |
from nltk.tokenize import sent_tokenize
|
| 9 |
|
| 10 |
# Ensure punkt resources are available
|
|
@@ -170,4 +172,16 @@ def get_evaluator_trace_prompt(documents, question, answer):
|
|
| 170 |
As a reminder: your task is to review the response and assess which documents contain
|
| 171 |
useful information pertaining to the question, and how each sentence in the response
|
| 172 |
is supported by the text in the documents.\
|
| 173 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import re
|
| 3 |
import requests
|
| 4 |
import time
|
|
|
|
| 5 |
|
| 6 |
+
import pandas as pd
|
| 7 |
+
from datetime import datetime
|
| 8 |
import nltk
|
| 9 |
+
|
| 10 |
from nltk.tokenize import sent_tokenize
|
| 11 |
|
| 12 |
# Ensure punkt resources are available
|
|
|
|
| 172 |
As a reminder: your task is to review the response and assess which documents contain
|
| 173 |
useful information pertaining to the question, and how each sentence in the response
|
| 174 |
is supported by the text in the documents.\
|
| 175 |
+
"""
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def convert_to_serializable(obj):
|
| 180 |
+
"""Convert DataFrame and other objects to JSON-serializable formats"""
|
| 181 |
+
if isinstance(obj, pd.DataFrame):
|
| 182 |
+
return obj.to_dict(orient='records')
|
| 183 |
+
elif hasattr(obj, 'to_dict'): # Handle other pandas objects
|
| 184 |
+
return obj.to_dict()
|
| 185 |
+
elif isinstance(obj, (datetime, pd.Timestamp)):
|
| 186 |
+
return obj.isoformat()
|
| 187 |
+
return str(obj) # Fallback for other types
|