이 노트북은 SerpAPI component를 사용하여 웹을 검색하는 방법을 다룹니다.
from langchain_community.utilities import SerpAPIWrapper
search = SerpAPIWrapper()
search.run("Obama's first name?")
'Barack Hussein Obama II'

Custom Parameters

임의의 parameter를 사용하여 SerpAPI wrapper를 커스터마이징할 수도 있습니다. 예를 들어, 아래 예제에서는 google 대신 bing을 사용합니다.
params = {
    "engine": "bing",
    "gl": "us",
    "hl": "en",
}
search = SerpAPIWrapper(params=params)
search.run("Obama's first name?")
'Barack Hussein Obama II is an American politician who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, Obama was the first African-American presi…New content will be added above the current area of focus upon selectionBarack Hussein Obama II is an American politician who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, Obama was the first African-American president of the United States. He previously served as a U.S. senator from Illinois from 2005 to 2008 and as an Illinois state senator from 1997 to 2004, and previously worked as a civil rights lawyer before entering politics.Wikipediabarackobama.com'
from langchain.tools import Tool

# You can create the tool to pass to an agent
custom_tool = Tool(
    name="web search",
    description="Search the web for information",
    func=search.run,
)

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I