Imnotchis commited on
Commit
846bab3
·
verified ·
1 Parent(s): 784ddae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -15
app.py CHANGED
@@ -114,25 +114,28 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
114
  print(agent_code)
115
 
116
  # 2. Fetch Questions
117
- print(f"Fetching questions from: {questions_url}")
118
  try:
119
- response = requests.get(questions_url, timeout=15)
120
- response.raise_for_status()
121
- questions_data = response.json()
122
  if not questions_data:
123
- print("Fetched questions list is empty.")
124
- return "Fetched questions list is empty or invalid format.", None
 
125
  print(f"Fetched {len(questions_data)} questions.")
126
- except requests.exceptions.RequestException as e:
127
- print(f"Error fetching questions: {e}")
128
- return f"Error fetching questions: {e}", None
129
- except requests.exceptions.JSONDecodeError as e:
130
- print(f"Error decoding JSON response from questions endpoint: {e}")
131
- print(f"Response text: {response.text[:500]}")
132
- return f"Error decoding server response for questions: {e}", None
 
 
133
  except Exception as e:
134
- print(f"An unexpected error occurred fetching questions: {e}")
135
- return f"An unexpected error occurred fetching questions: {e}", None
136
 
137
  # 3. Run your Agent
138
  results_log = []
 
114
  print(agent_code)
115
 
116
  # 2. Fetch Questions
117
+ print("Loading questions from questions.json")
118
  try:
119
+ with open("questions.json", "r", encoding="utf-8") as f:
120
+ questions_data = json.load(f)
121
+
122
  if not questions_data:
123
+ print("Fetched questions list is empty.")
124
+ return "Fetched questions list is empty or invalid format.", None
125
+
126
  print(f"Fetched {len(questions_data)} questions.")
127
+
128
+ except FileNotFoundError as e:
129
+ print(f"Error: questions.json not found: {e}")
130
+ return f"Error: questions.json not found: {e}", None
131
+
132
+ except json.JSONDecodeError as e:
133
+ print(f"Error decoding questions.json: {e}")
134
+ return f"Error decoding questions.json: {e}", None
135
+
136
  except Exception as e:
137
+ print(f"An unexpected error occurred loading questions: {e}")
138
+ return f"An unexpected error occurred loading questions: {e}", None
139
 
140
  # 3. Run your Agent
141
  results_log = []