George Sergia commited on
Commit
60f7dea
·
1 Parent(s): bc33688

Update final answer

Browse files
Files changed (2) hide show
  1. agent.py +2 -2
  2. app.py +3 -0
agent.py CHANGED
@@ -32,13 +32,13 @@ async def main(query: str, file_url: str | None) -> str:
32
 
33
  excel_file_reader_tool = FunctionTool.from_defaults(excel_file_reader, name="excel_file_reader", description="Loads Excel files and analyzes the content of the file.")
34
  tools.append(excel_file_reader_tool)
35
-
36
  agent = AgentWorkflow.from_tools_or_functions(
37
  tools_or_functions=tools,
38
  llm=google_genai_llm,
39
  system_prompt="""
40
  You are a general AI assistant. I will ask you a question.
41
- Do not report your thoughts, and finish your answer with the following template: [YOUR FINAL ANSWER].
42
  YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
43
  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.
44
  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.
 
32
 
33
  excel_file_reader_tool = FunctionTool.from_defaults(excel_file_reader, name="excel_file_reader", description="Loads Excel files and analyzes the content of the file.")
34
  tools.append(excel_file_reader_tool)
35
+
36
  agent = AgentWorkflow.from_tools_or_functions(
37
  tools_or_functions=tools,
38
  llm=google_genai_llm,
39
  system_prompt="""
40
  You are a general AI assistant. I will ask you a question.
41
+ Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
42
  YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
43
  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.
44
  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.
app.py CHANGED
@@ -84,6 +84,9 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
84
 
85
  agent_output = asyncio.run(agent.main(question_text, file_url))
86
  submitted_answer = str(agent_output)
 
 
 
87
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
88
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
89
  except Exception as e:
 
84
 
85
  agent_output = asyncio.run(agent.main(question_text, file_url))
86
  submitted_answer = str(agent_output)
87
+ if 'FINAL ANSWER:' in submitted_answer:
88
+ submitted_answer = submitted_answer.split('FINAL ANSWER:')[1].strip()
89
+
90
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
91
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
92
  except Exception as e: