Final_Assignment_Template / utils /search_tool.py
chevisli
Alpha version app
bfb26a0
raw
history blame contribute delete
699 Bytes
from langchain_google_community import GoogleSearchRun, GoogleSearchAPIWrapper
from dotenv import load_dotenv
load_dotenv()
search_wrapper = GoogleSearchAPIWrapper()
search_tool = GoogleSearchRun(api_wrapper=search_wrapper)
if __name__ == "__main__":
print("Start testing search tool with an example question")
# Import here to avoid circular import
from utils.agent_executor import create_agent_executor
tools = [search_tool]
agent_executor = create_agent_executor(tools=tools)
response = agent_executor.invoke(
{"input": "What is the current capital of Australia and when was it founded?"}
)
print("\nFinal Answer:")
print(response["output"])