Hugalino commited on
Commit
813bc9f
·
verified ·
1 Parent(s): 79691da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -1,10 +1,10 @@
1
  import os
2
  import gradio as gr
3
- from smolagents import CodeAgent, InferenceClientModel, OpenAIServerModel, FinalAnswerTool, MultiStepAgent
4
  import requests
5
  import inspect
6
  import pandas as pd
7
- from tools import search_tool, google_search_tool, wiki_search_tool, visit_web_tool
8
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
@@ -26,16 +26,17 @@ class BasicAgent:
26
  instruction = """
27
  You are an expert in question-and-answer tasks.
28
  You will receive questions in the following format:
29
- "[Question content] | Task Id: [task_id] - file: '[file_name]'"
30
 
31
  * Use the available tools to answer each question.
32
  * If a question requires accessing an additional file, use the download tool with the provided task ID and file name.
33
  * For questions involving mathematics or counting, write code to calculate the answer.
34
  * Return your response in the exact format specified by the question.
35
  """
36
- self.my_agent = MultiStepAgent(
37
  tools=[search_tool, google_search_tool, wiki_search_tool,
38
- visit_web_tool, FinalAnswerTool()],
 
39
  instructions=instruction,
40
  model=model,
41
  add_base_tools=True, # Add any additional base tools
@@ -46,7 +47,8 @@ You will receive questions in the following format:
46
  print(f"Task {task_id} - Agent received question (first 50 chars): {question[:50]}...")
47
  # fixed_answer = "This is a default answer."
48
  # print(f"Agent returning fixed answer: {fixed_answer}")
49
- response = self.my_agent.run(question)
 
50
  return response
51
 
52
  def run_and_submit_all( profile: gr.OAuthProfile | None):
 
1
  import os
2
  import gradio as gr
3
+ from smolagents import CodeAgent, InferenceClientModel, OpenAIServerModel, FinalAnswerTool
4
  import requests
5
  import inspect
6
  import pandas as pd
7
+ from tools import search_tool, google_search_tool, wiki_search_tool, visit_web_tool, file_download_tool
8
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
 
26
  instruction = """
27
  You are an expert in question-and-answer tasks.
28
  You will receive questions in the following format:
29
+ "[Question content] | Task ID: [task_id] - file: '[file_name]'"
30
 
31
  * Use the available tools to answer each question.
32
  * If a question requires accessing an additional file, use the download tool with the provided task ID and file name.
33
  * For questions involving mathematics or counting, write code to calculate the answer.
34
  * Return your response in the exact format specified by the question.
35
  """
36
+ self.my_agent = CodeAgent(
37
  tools=[search_tool, google_search_tool, wiki_search_tool,
38
+ visit_web_tool, file_download_tool,
39
+ FinalAnswerTool()],
40
  instructions=instruction,
41
  model=model,
42
  add_base_tools=True, # Add any additional base tools
 
47
  print(f"Task {task_id} - Agent received question (first 50 chars): {question[:50]}...")
48
  # fixed_answer = "This is a default answer."
49
  # print(f"Agent returning fixed answer: {fixed_answer}")
50
+ submitted_question = f"{question} | Task ID: {task_id} - file: '{file_name}'"
51
+ response = self.my_agent.run(submitted_question)
52
  return response
53
 
54
  def run_and_submit_all( profile: gr.OAuthProfile | None):