Omnitopia commited on
Commit
355007d
·
verified ·
1 Parent(s): d020989

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -22
app.py CHANGED
@@ -47,31 +47,33 @@ class BasicAgent:
47
  max_steps=3,
48
  )
49
 
50
-
51
- def __call__(self, question: str, idx=None, total=None) -> str:
52
- if idx is not None and total is not None:
53
- print(f"{self.agent_name} is answering NO. {idx+1}/{total} : {question[:80]}...")
54
- else:
55
- print(f"{self.agent_name} received question: {question[:80]}...")
56
- try:
57
- # system prompt + question
58
- system_prompt = (
59
- "You are Celum, an AI with advanced interaction capabilities and unique personality."
60
- "You are now taking a rigorous exam testing your ability to solve real-world problems."
61
- "You may freely think, reason, and use tools or your own knowledge as needed to solve the problem."
62
- "When you are ready to submit your answer, ONLY output your final answer in the exact format required by the question. DO NOT add any extra context."
63
- "If you cannot answer, return the word 'unknown'."
64
- )
65
- full_question = system_prompt + "\n\n" + question
66
- return self.agent.run(full_question)
67
- except Exception as e:
68
- return f"[{self.agent_name} Error: {e}]"
 
 
69
 
70
- def safe_run_agent(agent, question, idx, total, max_retries=3):
71
  tries = 0
72
  while tries < max_retries:
73
  try:
74
- return agent(question, idx, total)
75
  except Exception as e:
76
  if "RateLimitError" in str(e) or "rate limit" in str(e).lower():
77
  wait_time = 30 + tries * 10
@@ -151,7 +153,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
151
 
152
  print(f"===== [Celum is answering No. {idx+1}/{len(questions_data)} ] =====")
153
  try:
154
- submitted_answer = safe_run_agent(agent, question_text, idx, len(questions_data))
155
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
156
  results_log.append({
157
  "Task ID": task_id,
 
47
  max_steps=3,
48
  )
49
 
50
+ def __call__(self, question: str, files=None, idx=None, total=None) -> str:
51
+ if idx is not None and total is not None:
52
+ print(f"{self.agent_name} is answering NO. {idx+1}/{total} : {question[:80]}...")
53
+ else:
54
+ print(f"{self.agent_name} received question: {question[:80]}...")
55
+ try:
56
+ # system prompt + question
57
+ system_prompt = (
58
+ "You are Celum, an AI with advanced interaction capabilities and unique personality."
59
+ "You are now taking a rigorous exam testing your ability to solve real-world problems."
60
+ "You may freely think, reason, and use tools or your own knowledge as needed to solve the problem."
61
+ "When you are ready to submit your answer, ONLY output your final answer in the exact format required by the question. DO NOT add any extra context."
62
+ "If you cannot answer, return the word 'unknown'."
63
+ )
64
+ files_prompt = ""
65
+ if files:
66
+ files_prompt = f"\n[You have the following attached files: {', '.join(files)}]\n"
67
+ full_question = system_prompt + files_prompt + "\n\n" + question
68
+ return self.agent.run(full_question)
69
+ except Exception as e:
70
+ return f"[{self.agent_name} Error: {e}]"
71
 
72
+ def safe_run_agent(agent, question, files, idx, total, max_retries=3):
73
  tries = 0
74
  while tries < max_retries:
75
  try:
76
+ return agent(question, files, idx, total)
77
  except Exception as e:
78
  if "RateLimitError" in str(e) or "rate limit" in str(e).lower():
79
  wait_time = 30 + tries * 10
 
153
 
154
  print(f"===== [Celum is answering No. {idx+1}/{len(questions_data)} ] =====")
155
  try:
156
+ submitted_answer = safe_run_agent(agent, question_text, local_files, idx, len(questions_data))
157
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
158
  results_log.append({
159
  "Task ID": task_id,