nikhmr1235 commited on
Commit
411073f
·
verified ·
1 Parent(s): f22cccb

Update helper.py

Browse files
Files changed (1) hide show
  1. helper.py +18 -16
helper.py CHANGED
@@ -47,6 +47,9 @@ repl_tool = Tool(
47
  )
48
 
49
 
 
 
 
50
  from langchain_community.tools import TavilySearchResults
51
  from langchain.tools import Tool
52
  from typing import List, Optional
@@ -77,26 +80,26 @@ def get_travily_api_search_tool(
77
  Returns:
78
  A LangChain Tool configured for Tavily Search.
79
  """
 
 
 
 
 
 
 
 
80
  tavily_search = TavilySearchResults(
81
- max_results=5, # Increased from 3 to 5 (or more) for a larger pool of data.
82
- # This increases the chance of finding the correct answer even if rankings shift.
83
- include_answer=False, # **CRITICAL CHANGE for GAIA L1/L2:**
84
- # For precise factual answers, it's generally better to
85
- # let YOUR agent's LLM synthesize the answer from raw snippets.
86
- # Tavily's `include_answer` uses its own LLM which adds another
87
- # layer of potential variability and might not always be perfectly aligned
88
- # with GAIA's strict answer format.
89
- include_raw_content=False, # Good for saving tokens, keep as is.
90
- include_images=False, # Good for saving tokens, keep as is.
91
  tavily_api_key=tavily_api_key,
92
- # Incorporating new parameters for better control:
93
- search_depth=search_depth, # Passed from function argument, default 'advanced'
94
- include_domains=include_domains,
95
- exclude_domains=exclude_domains,
96
  time_range=time_range
97
  )
98
 
99
- # Updated description to reflect changes and emphasize strict input/output for GAIA
100
  return Tool(
101
  name="tavily_search",
102
  description="""
@@ -130,7 +133,6 @@ def get_travily_api_search_tool(
130
  """,
131
  func=tavily_search.run,
132
  )
133
-
134
  import requests
135
  from langchain.tools import Tool
136
  import os
 
47
  )
48
 
49
 
50
+ from langchain_community.tools import TavilySearchResults
51
+ from langchain.tools import Tool
52
+ from typing import List, Optional
53
  from langchain_community.tools import TavilySearchResults
54
  from langchain.tools import Tool
55
  from typing import List, Optional
 
80
  Returns:
81
  A LangChain Tool configured for Tavily Search.
82
  """
83
+
84
+ # Prepare parameters for TavilySearchResults
85
+ # Ensure include_domains and exclude_domains are lists, even if empty
86
+ # This resolves the Pydantic ValidationError
87
+ _include_domains = include_domains if include_domains is not None else []
88
+ _exclude_domains = exclude_domains if exclude_domains is not None else []
89
+
90
+
91
  tavily_search = TavilySearchResults(
92
+ max_results=5,
93
+ include_answer=False,
94
+ include_raw_content=False,
95
+ include_images=False,
 
 
 
 
 
 
96
  tavily_api_key=tavily_api_key,
97
+ search_depth=search_depth,
98
+ include_domains=_include_domains, # Pass the validated list
99
+ exclude_domains=_exclude_domains, # Pass the validated list
 
100
  time_range=time_range
101
  )
102
 
 
103
  return Tool(
104
  name="tavily_search",
105
  description="""
 
133
  """,
134
  func=tavily_search.run,
135
  )
 
136
  import requests
137
  from langchain.tools import Tool
138
  import os