FD900 commited on
Commit
9b50b85
·
verified ·
1 Parent(s): c7945b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -19
app.py CHANGED
@@ -5,7 +5,6 @@ import traceback
5
 
6
  from agent import answer_question
7
  from submit import submit_answers
8
- from tools.file_loader import read_pdf, read_csv, read_txt
9
 
10
  qa_data = []
11
  answers = []
@@ -22,26 +21,13 @@ def run_agent():
22
  answers = []
23
 
24
  for idx, q in enumerate(qa_data, start=1):
25
- task_id = q.get("task_id")
26
- question = q.get("question")
27
- file_text = ""
28
-
29
  file_name = q.get("file_name", "")
30
- if file_name:
31
- file_path = os.path.join("data", file_name)
32
- try:
33
- with open(file_path, "rb") as f:
34
- if file_name.endswith(".pdf"):
35
- file_text = read_pdf(f.read())
36
- elif file_name.endswith(".csv"):
37
- file_text = read_csv(f.read())
38
- elif file_name.endswith(".txt"):
39
- file_text = read_txt(f.read())
40
- except Exception as e:
41
- status_lines.append(f"⚠️ Failed to read file {file_name}: {e}")
42
-
43
- # Pass file path to agent
44
  q["file_path"] = os.path.join("data", file_name) if file_name else ""
 
45
  response = answer_question(q)
46
  answers.append({"task_id": task_id, "submitted_answer": response})
47
  status_lines.append(f"✅ Q{idx}: Answered")
 
5
 
6
  from agent import answer_question
7
  from submit import submit_answers
 
8
 
9
  qa_data = []
10
  answers = []
 
21
  answers = []
22
 
23
  for idx, q in enumerate(qa_data, start=1):
24
+ task_id = q.get("task_id", "")
 
 
 
25
  file_name = q.get("file_name", "")
26
+
27
+ # Construct full path and ensure required fields
28
+ q["question"] = q.get("question", "")
 
 
 
 
 
 
 
 
 
 
 
29
  q["file_path"] = os.path.join("data", file_name) if file_name else ""
30
+
31
  response = answer_question(q)
32
  answers.append({"task_id": task_id, "submitted_answer": response})
33
  status_lines.append(f"✅ Q{idx}: Answered")