dlaima commited on
Commit
d5ffeee
·
verified ·
1 Parent(s): d2607ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -6,13 +6,26 @@ import requests
6
  import pandas as pd
7
 
8
  from smolagents import LiteLLMModel, CodeAgent, DuckDuckGoSearchTool
 
9
 
10
  # System prompt for the agent
11
  SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question.
12
  Report your thoughts, and finish your answer with just the answer — no prefixes like "FINAL ANSWER:".
13
  Your answer should be a number OR as few words as possible OR a comma-separated list of numbers and/or strings.
14
  If you're asked for a number, don’t use commas or units like $ or %, unless specified.
15
- If you're asked for a string, don’t use articles or abbreviations (e.g. for cities), and write digits in plain text unless told otherwise."""
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
18
 
@@ -23,16 +36,19 @@ class MyAgent:
23
  if not gemini_api_key:
24
  raise ValueError("GEMINI_API_KEY not set in environment variables.")
25
 
26
- # Instantiate LiteLLMModel with Gemini API key and model id
27
  self.model = LiteLLMModel(
28
  model_id="gemini/gemini-2.0-flash-lite",
29
  api_key=gemini_api_key,
30
  system_prompt=SYSTEM_PROMPT
31
  )
32
 
33
- # Create the CodeAgent with optional base tools and DuckDuckGo search
34
  self.agent = CodeAgent(
35
- tools=[DuckDuckGoSearchTool()],
 
 
 
 
 
36
  model=self.model,
37
  add_base_tools=True,
38
  )
@@ -132,4 +148,3 @@ if __name__ == "__main__":
132
 
133
 
134
 
135
-
 
6
  import pandas as pd
7
 
8
  from smolagents import LiteLLMModel, CodeAgent, DuckDuckGoSearchTool
9
+ from gaia_tools import ReverseTextTool, RunPythonFileTool, download_server
10
 
11
  # System prompt for the agent
12
  SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question.
13
  Report your thoughts, and finish your answer with just the answer — no prefixes like "FINAL ANSWER:".
14
  Your answer should be a number OR as few words as possible OR a comma-separated list of numbers and/or strings.
15
  If you're asked for a number, don’t use commas or units like $ or %, unless specified.
16
+ If you're asked for a string, don’t use articles or abbreviations (e.g. for cities), and write digits in plain text unless told otherwise.
17
+
18
+ Tool Use Guidelines:
19
+ 1. Do **not** use any tools outside of the provided tools list.
20
+ 2. Always use **only one tool at a time** in each step of your execution.
21
+ 3. If the question refers to a `.py` file or uploaded Python script, use **RunPythonFileTool** to execute it and base your answer on its output.
22
+ 4. If the question looks reversed (starts with a period or reads backward), first use **ReverseTextTool** to reverse it, then process the question.
23
+ 5. For logic or word puzzles, solve them directly unless they are reversed — in which case, decode first using **ReverseTextTool**.
24
+ 6. When dealing with Excel files, prioritize using the **excel** tool over writing code in **terminal-controller**.
25
+ 7. If you need to download a file, always use the **download_server** tool and save it to the correct path.
26
+ 8. Even for complex tasks, assume a solution exists. If one method fails, try another approach using different tools.
27
+ 9. Due to context length limits, keep browser-based tasks (e.g., searches) as short and efficient as possible.
28
+ """
29
 
30
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
31
 
 
36
  if not gemini_api_key:
37
  raise ValueError("GEMINI_API_KEY not set in environment variables.")
38
 
 
39
  self.model = LiteLLMModel(
40
  model_id="gemini/gemini-2.0-flash-lite",
41
  api_key=gemini_api_key,
42
  system_prompt=SYSTEM_PROMPT
43
  )
44
 
 
45
  self.agent = CodeAgent(
46
+ tools=[
47
+ DuckDuckGoSearchTool(),
48
+ ReverseTextTool(),
49
+ RunPythonFileTool(),
50
+ download_server()
51
+ ],
52
  model=self.model,
53
  add_base_tools=True,
54
  )
 
148
 
149
 
150