9jini commited on
Commit
2f17ead
·
verified ·
1 Parent(s): 31dae8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -5
app.py CHANGED
@@ -3,13 +3,31 @@ 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:
@@ -18,12 +36,15 @@ class BasicAgent:
18
 
19
  search_tool = DuckDuckGoSearchTool()
20
  wiki_search = WikipediaSearchTool()
21
-
 
 
 
22
  self.agent = CodeAgent(
23
  model = model,
24
- tools=[
25
- search_tool,
26
- ]
27
  )
28
 
29
  def __call__(self, question: str) -> str:
 
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:
 
36
 
37
  search_tool = DuckDuckGoSearchTool()
38
  wiki_search = WikipediaSearchTool()
39
+ prompt = ChatPromptTemplate.from_messages([
40
+ ("system", SYSTEM_PROMPT),
41
+ ("user", "{input}")
42
+ ])
43
  self.agent = CodeAgent(
44
  model = model,
45
+ tools=[search_tool,wiki_search],
46
+ prompt=prompt,
47
+
48
  )
49
 
50
  def __call__(self, question: str) -> str: