InfinityCoder5607 commited on
Commit
a2037d8
·
1 Parent(s): 86f0f36

Add Tavily search tool

Browse files
Files changed (1) hide show
  1. app.py +23 -6
app.py CHANGED
@@ -6,6 +6,8 @@ import pandas as pd
6
  import spaces
7
  from langchain_openai import ChatOpenAI
8
  from langchain.agents import create_agent
 
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
11
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
@@ -23,7 +25,12 @@ def zerogpu_function():
23
  # fixed_answer = "This is a default answer."
24
  # print(f"Agent returning fixed answer: {fixed_answer}")
25
  # return fixed_answer
 
 
 
 
26
 
 
27
  model = ChatOpenAI(
28
  model="qwen-plus",
29
  api_key=os.environ["DASHSCOPE_API_KEY"],
@@ -39,16 +46,26 @@ class BasicAgent:
39
 
40
  self.agent = create_agent(
41
  model=agent_model,
42
- tools=[],
43
  system_prompt="""
44
  You are solving GAIA benchmark questions.
45
 
46
- You have NO external tools.
47
- You cannot browse the web.
48
- You cannot access files or attachments.
49
- You cannot use a calculator or Python.
 
 
 
 
 
 
 
50
 
51
- Solve each question using only your internal knowledge and reasoning.
 
 
 
52
 
53
  IMPORTANT:
54
  - Return only the final answer.
 
6
  import spaces
7
  from langchain_openai import ChatOpenAI
8
  from langchain.agents import create_agent
9
+ from langchain_tavily import TavilySearch
10
+
11
  # (Keep Constants as is)
12
  # --- Constants ---
13
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
25
  # fixed_answer = "This is a default answer."
26
  # print(f"Agent returning fixed answer: {fixed_answer}")
27
  # return fixed_answer
28
+ search_tool = TavilySearch(
29
+ max_results=5,
30
+ topic="general",
31
+ search_depth="advanced",
32
 
33
+ )
34
  model = ChatOpenAI(
35
  model="qwen-plus",
36
  api_key=os.environ["DASHSCOPE_API_KEY"],
 
46
 
47
  self.agent = create_agent(
48
  model=agent_model,
49
+ tools=[search_tool],
50
  system_prompt="""
51
  You are solving GAIA benchmark questions.
52
 
53
+ You have access to a web search tool.
54
+
55
+ Use web search whenever:
56
+ - The question asks about specific facts that may not be in your knowledge.
57
+ - The question refers to Wikipedia, websites, historical records,
58
+ specific people, articles, dates, publications, or other information
59
+ that should be verified.
60
+ - You are uncertain about a factual answer.
61
+
62
+ You still cannot access files or attachments.
63
+ You do not have Python or a calculator.
64
 
65
+ When searching:
66
+ - Search multiple times if necessary.
67
+ - Use different search queries when the first search is insufficient.
68
+ - Carefully reason over the search results before answering.
69
 
70
  IMPORTANT:
71
  - Return only the final answer.