Spaces:
Runtime error
Runtime error
Update helper.py
Browse files
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,
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 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 |
-
|
| 93 |
-
|
| 94 |
-
|
| 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
|