Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
OurBuilding Ambient Agents with LangGraph course is now available on LangChain Academy!
Open In ColabOpen on GitHub

SerpAPI

This notebook goes over how to use the SerpAPI component to search the web.

from langchain_community.utilitiesimport SerpAPIWrapper
API Reference:SerpAPIWrapper
search= SerpAPIWrapper()
search.run("Obama's first name?")
'Barack Hussein Obama II'

Custom Parameters

You can also customize the SerpAPI wrapper with arbitrary parameters. For example, in the below example we will usebing instead ofgoogle.

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_core.toolsimport 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,
)
API Reference:Tool

Related


[8]ページ先頭

©2009-2025 Movatter.jp