AntonVoronko commited on
Commit
6490c12
·
verified ·
1 Parent(s): 1a866bf

Wiki and arxiv tools added

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -11,6 +11,8 @@ from llama_index.llms.groq import Groq
11
  from llama_index.core.agent.workflow import FunctionAgent
12
 
13
  from llama_index.tools.duckduckgo import DuckDuckGoSearchToolSpec
 
 
14
  from llama_index.core.tools import FunctionTool
15
 
16
  # (Keep Constants as is)
@@ -21,12 +23,14 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
21
  class BasicAgent:
22
  def __init__(self):
23
  api_key = os.getenv("GROQ_API_KEY")
24
- tool_spec = DuckDuckGoSearchToolSpec()
25
- search_tool = FunctionTool.from_defaults(tool_spec.duckduckgo_full_search)
 
 
26
  llm = Groq(model="deepseek-r1-distill-llama-70b", api_key=api_key)
27
- self.agent = FunctionAgent(tools=[search_tool], llm=llm, system_prompt='''
28
  You are a general AI assistant.
29
- I will ask you a question. You can use the search tool to help you with an answer.
30
  Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
31
  YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
32
  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.
 
11
  from llama_index.core.agent.workflow import FunctionAgent
12
 
13
  from llama_index.tools.duckduckgo import DuckDuckGoSearchToolSpec
14
+ from llama_index.tools.wikipedia import WikipediaToolSpec
15
+ from llama_index.tools.arxiv import ArxivToolSpec
16
  from llama_index.core.tools import FunctionTool
17
 
18
  # (Keep Constants as is)
 
23
  class BasicAgent:
24
  def __init__(self):
25
  api_key = os.getenv("GROQ_API_KEY")
26
+ duck_spec = DuckDuckGoSearchToolSpec()
27
+ search_tool = FunctionTool.from_defaults(duck_spec.duckduckgo_full_search)
28
+ wiki_tool = WikipediaToolSpec().to_tool_list()
29
+ arxiv_tool = ArxivToolSpec().to_tool_list()
30
  llm = Groq(model="deepseek-r1-distill-llama-70b", api_key=api_key)
31
+ self.agent = FunctionAgent(tools=[search_tool, wiki_tool, arxiv_tool], llm=llm, system_prompt='''
32
  You are a general AI assistant.
33
+ I will ask you a question. You can use the tools at your disposal to help you with an answer.
34
  Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
35
  YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
36
  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.