File size: 442 Bytes
f016beb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from langchain_community.utilities import GoogleSerperAPIWrapper
from langchain.agents import Tool

import os

search_tool = GoogleSerperAPIWrapper(
    serper_api_key=os.getenv("SERPER_API_KEY"),   # add this to your .env
    k=3                                          # top-5 results
)

serper_search_tool = Tool(
    name="Google Search",
    func=search_tool.run,
    description="Useful for answering questions by searching the web."
)