SerpAPI
本頁面涵蓋如何在 LangChain 中使用 SerpAPI 搜尋 API。它分為兩個部分:安裝與設定,以及 SerpAPI 封裝器的參考資料。
安裝與設定
- 使用
pip install google-search-results
安裝需求套件 - 取得 SerpAPI API 金鑰,並將其設定為環境變數 (`SERPAPI_API_KEY`)
封裝器
工具
存在一個 SerpAPI 工具,用於封裝此 API。若要匯入此工具
from langchain_community.utilities import SerpAPIWrapper
API 參考文檔:SerpAPIWrapper
如需更詳細的封裝器逐步說明,請參閱此筆記本。
工具
您也可以輕鬆地將此封裝器作為工具載入(以與 Agent 一起使用)。您可以使用以下方式執行此操作:
from langchain.agents import load_tools
tools = load_tools(["serpapi"])
API 參考文檔:load_tools
如需更多資訊,請參閱此頁面