Update app.py
Browse files46 unmodified lines47484950515253545556575859606162636465666768505152535455565758596061626364656667686970717072737475747677787973 unmodified lines15315415515415615715815946 unmodified lines max_steps=3, )
def __call__(self, question: str, idx=None, total=None) -> str: if idx is not None and total is not None: print(f"{self.agent_name} is answering NO. {idx+1}/{total} : {question[:80]}...") else: print(f"{self.agent_name} received question: {question[:80]}...") try: # system prompt + question system_prompt = ( "You are Celum, an AI with advanced interaction capabilities and unique personality." "You are now taking a rigorous exam testing your ability to solve real-world problems." "You may freely think, reason, and use tools or your own knowledge as needed to solve the problem." "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." "If you cannot answer, return the word 'unknown'." ) full_question = system_prompt + "\n\n" + question return self.agent.run(full_question) except Exception as e: return f"[{self.agent_name} Error: {e}]" def __call__(self, question: str, files=None, idx=None, total=None) -> str: if idx is not None and total is not None: print(f"{self.agent_name} is answering NO. {idx+1}/{total} : {question[:80]}...") else: print(f"{self.agent_name} received question: {question[:80]}...") try: # system prompt + question system_prompt = ( "You are Celum, an AI with advanced interaction capabilities and unique personality." "You are now taking a rigorous exam testing your ability to solve real-world problems." "You may freely think, reason, and use tools or your own knowledge as needed to solve the problem." "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." "If you cannot answer, return the word 'unknown'." ) files_prompt = "" if files: files_prompt = f"\n[You have the following attached files: {', '.join(files)}]\n" full_question = system_prompt + files_prompt + "\n\n" + question return self.agent.run(full_question) except Exception as e: return f"[{self.agent_name} Error: {e}]" def safe_run_agent(agent, question, idx, total, max_retries=3):def safe_run_agent(agent, question, files, idx, total, max_retries=3): tries = 0 while tries < max_retries: try: return agent(question, idx, total) return agent(question, files, idx, total) except Exception as e: if "RateLimitError" in str(e) or "rate limit" in str(e).lower(): wait_time = 30 + tries * 1073 unmodified lines print(f"===== [Celum is answering No. {idx+1}/{len(questions_data)} ] =====") try: submitted_answer = safe_run_agent(agent, question_text, idx, len(questions_data)) submitted_answer = safe_run_agent(agent, question_text, local_files, idx, len(questions_data)) answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer}) results_log.append({ "Task ID": task_id,app.py+24-22