trongld commited on
Commit
9e2c057
·
1 Parent(s): 8f4431b

Update get_tools function to include WikipediaAPIWrapper and modify WikipediaQuery tool

Browse files
Files changed (1) hide show
  1. tools.py +8 -6
tools.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  from langchain_community.tools import Tool, BraveSearch, YouTubeSearchTool
3
  from langchain_community.tools import DuckDuckGoSearchResults, GoogleSearchResults
4
  from langchain_community.tools import WikipediaQueryRun
 
5
  from langchain_community.tools import WolframAlphaQueryRun
6
  from typing import Any, Dict, List, Optional
7
  import json
@@ -403,6 +404,7 @@ def get_tools():
403
  """
404
  Returns a list of tools that can be used by the agent.
405
  """
 
406
  tools = [
407
  Tool(
408
  name="YouTubeSearch",
@@ -421,14 +423,14 @@ def get_tools():
421
  # ),
422
  Tool(
423
  name="WikipediaQuery",
424
- func=WikipediaQueryRun().run,
425
  description="Query Wikipedia for information."
426
  ),
427
- Tool(
428
- name="WolframAlphaQuery",
429
- func=WolframAlphaQueryRun().run,
430
- description="Query Wolfram Alpha for computational knowledge."
431
- )
432
  ]
433
  # Add structured tools (LangChain @tool)
434
  tools.extend([
 
2
  from langchain_community.tools import Tool, BraveSearch, YouTubeSearchTool
3
  from langchain_community.tools import DuckDuckGoSearchResults, GoogleSearchResults
4
  from langchain_community.tools import WikipediaQueryRun
5
+ from langchain_community.utilities import WikipediaAPIWrapper, WolframAlphaAPIWrapper
6
  from langchain_community.tools import WolframAlphaQueryRun
7
  from typing import Any, Dict, List, Optional
8
  import json
 
404
  """
405
  Returns a list of tools that can be used by the agent.
406
  """
407
+ wikipedia_api_wrapper = WikipediaAPIWrapper()
408
  tools = [
409
  Tool(
410
  name="YouTubeSearch",
 
423
  # ),
424
  Tool(
425
  name="WikipediaQuery",
426
+ func=WikipediaQueryRun(api_wrapper=wikipedia_api_wrapper).run,
427
  description="Query Wikipedia for information."
428
  ),
429
+ # Tool(
430
+ # name="WolframAlphaQuery",
431
+ # func=WolframAlphaQueryRun().run,
432
+ # description="Query Wolfram Alpha for computational knowledge."
433
+ # )
434
  ]
435
  # Add structured tools (LangChain @tool)
436
  tools.extend([