Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -245,40 +245,43 @@ def process_pdf(uploaded_files, llm_model, n_criteria = num_criteria):
|
|
245 |
|
246 |
# Evaluate with OpenAI model
|
247 |
total_score, criteria_met, score_percentage, score_list, reasoning = pdf_criteria_query.evaluate_with_llm(registration_result, peer_journal_result, eq_journal_result, queries)
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
|
278 |
-
|
279 |
-
|
280 |
|
281 |
-
|
|
|
|
|
|
|
282 |
|
283 |
# Convert reasoning list to plain text
|
284 |
#reasoning_text = "\n".join([f"{idx + 1}. {reason}" for idx, reason in enumerate(reasoning)])
|
|
|
245 |
|
246 |
# Evaluate with OpenAI model
|
247 |
total_score, criteria_met, score_percentage, score_list, reasoning = pdf_criteria_query.evaluate_with_llm(registration_result, peer_journal_result, eq_journal_result, queries)
|
248 |
+
try:
|
249 |
+
# Define the path to your CSV file
|
250 |
+
csv_file_path = 'storing_output.csv'
|
251 |
+
|
252 |
+
|
253 |
+
# Create a dictionary for the new row
|
254 |
+
new_row = {
|
255 |
+
'Id': id_number,
|
256 |
+
'Title': title,
|
257 |
+
'Author': author_result
|
258 |
+
}
|
259 |
+
new_row.update({f'score_cr_{i}': score for i, score in enumerate(score_list, 1)})
|
260 |
+
new_row.update({f'reasoning_cr_{i}': reasoning for i, reasoning in enumerate(reasoning, 1)})
|
261 |
+
|
262 |
+
# Convert new_row dictionary to a DataFrame for easy appending
|
263 |
+
new_row_df = pd.DataFrame([new_row])
|
264 |
+
print(new_row_df)
|
265 |
|
266 |
+
# Check if the CSV file exists
|
267 |
+
if os.path.exists(csv_file_path):
|
268 |
+
# Load the existing data
|
269 |
+
df = pd.read_csv(csv_file_path)
|
270 |
+
else:
|
271 |
+
# Or create a new DataFrame if the file does not exist
|
272 |
+
columns = ['Id', 'Title', 'Author'] + [f'score_cr_{i}' for i in range(1, 10)] + [f'reasoning_cr_{i}' for i in range(1, 10)]
|
273 |
+
df = pd.DataFrame(columns=columns)
|
274 |
+
|
275 |
+
# Append the new data using pd.concat
|
276 |
+
df = pd.concat([df, new_row_df], ignore_index=True)
|
277 |
|
278 |
+
# Save the updated DataFrame back to CSV
|
279 |
+
df.to_csv(csv_file_path, index=False)
|
280 |
|
281 |
+
print(f"Updated data saved to {csv_file_path}.")
|
282 |
+
|
283 |
+
except Exception as e:
|
284 |
+
print(f"An error occurred: {e}")
|
285 |
|
286 |
# Convert reasoning list to plain text
|
287 |
#reasoning_text = "\n".join([f"{idx + 1}. {reason}" for idx, reason in enumerate(reasoning)])
|