9jini commited on
Commit
898d902
·
verified ·
1 Parent(s): 5ac85f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -7
app.py CHANGED
@@ -3,28 +3,45 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
6
-
7
  from smolagents import CodeAgent, DuckDuckGoSearchTool, OpenAIServerModel, WikipediaSearchTool
8
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
11
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  # --- Basic Agent Definition ---
14
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
15
  class BasicAgent:
16
  def __init__(self):
17
- model = OpenAIServerModel(model_id="gpt-4o")
18
 
19
  search_tool = DuckDuckGoSearchTool()
20
  wiki_search = WikipediaSearchTool()
21
 
22
  self.agent = CodeAgent(
23
  model = model,
24
- tools=[
25
- search_tool,
26
- wiki_search
27
- ]
28
  )
29
 
30
  def __call__(self, question: str) -> str:
@@ -156,7 +173,6 @@ with gr.Blocks() as demo:
156
  gr.Markdown("# Basic Agent Evaluation Runner")
157
  gr.Markdown(
158
  """
159
- Modified by niku....
160
  **Instructions:**
161
 
162
  1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
@@ -167,6 +183,7 @@ with gr.Blocks() as demo:
167
  **Disclaimers:**
168
  Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).
169
  This space provides a basic setup and is intentionally sub-optimal to encourage you to develop your own, more robust solution. For instance for the delay process of the submit button, a solution could be to cache the answers and submit in a seperate action or even to answer the questions in async.
 
170
  """
171
  )
172
 
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from langchain_core.prompts import ChatPromptTemplate
7
  from smolagents import CodeAgent, DuckDuckGoSearchTool, OpenAIServerModel, WikipediaSearchTool
8
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
11
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
 
13
+ SYSTEM_PROMPT = """
14
+ You are GAIA-Bot, a fully-autonomous problem-solver.
15
+ • For each question, THINK step-by-step before answering.
16
+ • When outside knowledge or calculations are needed, CALL an appropriate tool.
17
+ • Explain your reasoning only to yourself (in “Thought” messages); do NOT reveal it to the user.
18
+ • After finishing all reasoning, RESPOND with **only** the final answer string—no pre-amble, no labels, no extra text.
19
+ You have access to these tools:
20
+ - gaia_file_fetch – download the file attached to the current task_id.
21
+ - duckduckgo_search – look up current facts on the public web.
22
+ If you require a file attached to the current task, download it with
23
+ `requests_get("https://agents-course-unit4-scoring.hf.space/files/{task_id}")`
24
+ and parse it inside Python.
25
+ Adhere strictly to these rules:
26
+ 1. Use tools whenever they can reduce hallucination.
27
+ 2. Never mention tool names or JSON in your final answer.
28
+ 3. If you cannot find an answer, return “unknown”.
29
+ Begin.
30
+ """
31
  # --- Basic Agent Definition ---
32
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
33
  class BasicAgent:
34
  def __init__(self):
35
+ model = OpenAIServerModel(model_id="deepseek-chat",api_key="sk-04da63f756c9468182d278f52e33ad15", api_base="https://api.deepseek.com")
36
 
37
  search_tool = DuckDuckGoSearchTool()
38
  wiki_search = WikipediaSearchTool()
39
 
40
  self.agent = CodeAgent(
41
  model = model,
42
+ tools=[search_tool,wiki_search],
43
+ prompt=SYSTEM_PROMPT,
44
+
 
45
  )
46
 
47
  def __call__(self, question: str) -> str:
 
173
  gr.Markdown("# Basic Agent Evaluation Runner")
174
  gr.Markdown(
175
  """
 
176
  **Instructions:**
177
 
178
  1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
 
183
  **Disclaimers:**
184
  Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).
185
  This space provides a basic setup and is intentionally sub-optimal to encourage you to develop your own, more robust solution. For instance for the delay process of the submit button, a solution could be to cache the answers and submit in a seperate action or even to answer the questions in async.
186
+ Please note that this version requires an OpenAI Key to run.
187
  """
188
  )
189