sabonzo commited on
Commit
91ea2fd
·
verified ·
1 Parent(s): ff6effb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -24,6 +24,7 @@ from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
24
  from langchain_community.tools.tavily_search import TavilySearchResults
25
  from langchain_community.tools.ddg_search import DuckDuckGoSearchRun
26
  from langchain_community.utilities.wikipedia import WikipediaAPIWrapper
 
27
  from langchain_experimental.tools import PythonREPLTool # Use with caution
28
  # Custom tools will be defined below (or implicitly used)
29
 
@@ -354,8 +355,11 @@ class GaiaAgent:
354
  else:
355
  logging.warning("TAVILY_API_KEY not found, using DuckDuckGoSearchRun.")
356
  self.tools.append(DuckDuckGoSearchRun())
357
- self.tools.append(WikipediaAPIWrapper())
358
- logging.info("Using Wikipedia Search Tool.")
 
 
 
359
  try:
360
  self.tools.append(PythonREPLTool())
361
  logging.info("Using Python REPL Tool.")
 
24
  from langchain_community.tools.tavily_search import TavilySearchResults
25
  from langchain_community.tools.ddg_search import DuckDuckGoSearchRun
26
  from langchain_community.utilities.wikipedia import WikipediaAPIWrapper
27
+ from langchain_community.tools import WikipediaQueryRun
28
  from langchain_experimental.tools import PythonREPLTool # Use with caution
29
  # Custom tools will be defined below (or implicitly used)
30
 
 
355
  else:
356
  logging.warning("TAVILY_API_KEY not found, using DuckDuckGoSearchRun.")
357
  self.tools.append(DuckDuckGoSearchRun())
358
+ # Initialize the API wrapper needed by the tool
359
+ api_wrapper = WikipediaAPIWrapper(top_k_results=3, doc_content_chars_max=4000, lang='en', load_all_available_meta=False) # Re-create the wrapper explicitly
360
+ # Add the WikipediaQueryRun tool, passing the wrapper
361
+ self.tools.append(WikipediaQueryRun(api_wrapper=api_wrapper))
362
+ logging.info("Using Wikipedia Query Run Tool.") # Update log message slightly
363
  try:
364
  self.tools.append(PythonREPLTool())
365
  logging.info("Using Python REPL Tool.")