Samuel Thomas commited on
Commit
c1d0e30
·
1 Parent(s): 1bcac95
Files changed (1) hide show
  1. app.py +25 -24
app.py CHANGED
@@ -39,7 +39,28 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
39
  questions_url = f"{api_url}/questions"
40
  submit_url = f"{api_url}/submit"
41
 
42
- # 1. Create states
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  for item in hf_questions:
44
  file_name = item.get('file_name', '')
45
  if file_name == '':
@@ -66,10 +87,10 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
66
  file_type = hf_questions[r]['file_type'],
67
  file_path = hf_questions[r]['file_path'])
68
  print(s['question'])
69
- temp_ans = intelligent_agent(s)
70
- print(temp_ans)
71
  print('\n')
72
- ans.append(temp_ans)
73
  except Exception as e:
74
  print(f"Error instantiating agent: {e}")
75
  return f"Error initializing agent: {e}", None
@@ -77,26 +98,6 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
77
  agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
78
  print(agent_code)
79
 
80
- # 2. Fetch Questions
81
- print(f"Fetching questions from: {questions_url}")
82
- try:
83
- response = requests.get(questions_url, timeout=15)
84
- response.raise_for_status()
85
- hf_questions = response.json()
86
- if not hf_questions:
87
- print("Fetched questions list is empty.")
88
- return "Fetched questions list is empty or invalid format.", None
89
- print(f"Fetched {len(hf_questions)} questions.")
90
- except requests.exceptions.RequestException as e:
91
- print(f"Error fetching questions: {e}")
92
- return f"Error fetching questions: {e}", None
93
- except requests.exceptions.JSONDecodeError as e:
94
- print(f"Error decoding JSON response from questions endpoint: {e}")
95
- print(f"Response text: {response.text[:500]}")
96
- return f"Error decoding server response for questions: {e}", None
97
- except Exception as e:
98
- print(f"An unexpected error occurred fetching questions: {e}")
99
- return f"An unexpected error occurred fetching questions: {e}", None
100
 
101
 
102
  """
 
39
  questions_url = f"{api_url}/questions"
40
  submit_url = f"{api_url}/submit"
41
 
42
+ # 1. Fetch Questions
43
+ print(f"Fetching questions from: {questions_url}")
44
+ try:
45
+ response = requests.get(questions_url, timeout=15)
46
+ response.raise_for_status()
47
+ hf_questions = response.json()
48
+ if not hf_questions:
49
+ print("Fetched questions list is empty.")
50
+ return "Fetched questions list is empty or invalid format.", None
51
+ print(f"Fetched {len(hf_questions)} questions.")
52
+ except requests.exceptions.RequestException as e:
53
+ print(f"Error fetching questions: {e}")
54
+ return f"Error fetching questions: {e}", None
55
+ except requests.exceptions.JSONDecodeError as e:
56
+ print(f"Error decoding JSON response from questions endpoint: {e}")
57
+ print(f"Response text: {response.text[:500]}")
58
+ return f"Error decoding server response for questions: {e}", None
59
+ except Exception as e:
60
+ print(f"An unexpected error occurred fetching questions: {e}")
61
+ return f"An unexpected error occurred fetching questions: {e}", None
62
+
63
+ # 2. Create states
64
  for item in hf_questions:
65
  file_name = item.get('file_name', '')
66
  if file_name == '':
 
87
  file_type = hf_questions[r]['file_type'],
88
  file_path = hf_questions[r]['file_path'])
89
  print(s['question'])
90
+ #temp_ans = intelligent_agent(s)
91
+ #print(temp_ans)
92
  print('\n')
93
+ #ans.append(temp_ans)
94
  except Exception as e:
95
  print(f"Error instantiating agent: {e}")
96
  return f"Error initializing agent: {e}", None
 
98
  agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
99
  print(agent_code)
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
 
103
  """