Sonu313131 commited on
Commit
fbcb571
·
verified ·
1 Parent(s): 6706f7c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -36
app.py CHANGED
@@ -46,42 +46,42 @@ async def run_and_submit_all(profile: gr.OAuthProfile | None):
46
  if not task_id or question_text is None:
47
  continue
48
  try:
49
- # Construct full prompt with required system instructions
50
- system_prompt = (
51
- "You are a general AI assistant. I will ask you a question. "
52
- "Report your thoughts, and finish your answer with the following template: "
53
- "FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. "
54
- "If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. "
55
- "If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. "
56
- "If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.\n\n"
57
- )
58
- full_prompt = system_prompt + f"Question: {question_text.strip()}"
59
-
60
- # Run agent with full prompt
61
- loop = asyncio.get_event_loop()
62
- agent_response = await loop.run_in_executor(None, agent, full_prompt)
63
-
64
- # Extract FINAL ANSWER and reasoning
65
- if "FINAL ANSWER:" in agent_response:
66
- reasoning_trace, final_answer = agent_response.rsplit("FINAL ANSWER:", 1)
67
- final_answer = final_answer.strip()
68
- reasoning_trace = reasoning_trace.strip()
69
- else:
70
- final_answer = agent_response.strip()
71
- reasoning_trace = "Model did not follow format; full response returned."
72
-
73
- answers_payload.append({
74
- "task_id": task_id,
75
- "model_answer": final_answer,
76
- "reasoning_trace": reasoning_trace
77
- })
78
-
79
- results_log.append({
80
- "Task ID": task_id,
81
- "Question": question_text,
82
- "Submitted Answer": final_answer,
83
- "Reasoning Trace": reasoning_trace
84
- })
85
 
86
  except Exception as e:
87
  print(f"Error running agent on task {task_id}: {e}")
 
46
  if not task_id or question_text is None:
47
  continue
48
  try:
49
+ # Construct full prompt with required system instructions
50
+ system_prompt = (
51
+ "You are a general AI assistant. I will ask you a question. "
52
+ "Report your thoughts, and finish your answer with the following template: "
53
+ "FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. "
54
+ "If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. "
55
+ "If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. "
56
+ "If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.\n\n"
57
+ )
58
+ full_prompt = system_prompt + f"Question: {question_text.strip()}"
59
+
60
+ # Run agent with full prompt
61
+ loop = asyncio.get_event_loop()
62
+ agent_response = await loop.run_in_executor(None, agent, full_prompt)
63
+
64
+ # Extract FINAL ANSWER and reasoning
65
+ if "FINAL ANSWER:" in agent_response:
66
+ reasoning_trace, final_answer = agent_response.rsplit("FINAL ANSWER:", 1)
67
+ final_answer = final_answer.strip()
68
+ reasoning_trace = reasoning_trace.strip()
69
+ else:
70
+ final_answer = agent_response.strip()
71
+ reasoning_trace = "Model did not follow format; full response returned."
72
+
73
+ answers_payload.append({
74
+ "task_id": task_id,
75
+ "model_answer": final_answer,
76
+ "reasoning_trace": reasoning_trace
77
+ })
78
+
79
+ results_log.append({
80
+ "Task ID": task_id,
81
+ "Question": question_text,
82
+ "Submitted Answer": final_answer,
83
+ "Reasoning Trace": reasoning_trace
84
+ })
85
 
86
  except Exception as e:
87
  print(f"Error running agent on task {task_id}: {e}")