跳到主要内容
Brave Search 是由 Brave Software 开发的一款搜索引擎。
  • Brave Search 使用自己的网络索引。截至2022年5月,它已覆盖超过100亿个页面,并用于提供92%的搜索结果,而无需依赖任何第三方。其余结果则通过服务器端从 Bing API 获取,或在用户选择加入的情况下通过客户端从 Google 获取。根据 Brave 的说法,该索引被“有意地保持比谷歌或必应的索引小”,以帮助避免垃圾邮件和其他低质量内容,其缺点是“Brave Search 在处理长尾查询方面尚不如谷歌。”
  • Brave Search Premium:截至2023年4月,Brave Search 是一个无广告的网站,但它最终将转向一种新模式,该模式将包含广告,而高级用户将获得无广告的体验。默认情况下,不会从用户那里收集包括 IP 地址在内的用户数据。选择性加入的数据收集将需要一个高级账户。

安装和设置

要访问 Brave Search API,您需要创建一个账户并获取一个 API 密钥
api_key = "..."
from langchain_community.document_loaders import BraveSearchLoader

示例

loader = BraveSearchLoader(
    query="obama middle name", api_key=api_key, search_kwargs={"count": 3}
)
docs = loader.load()
len(docs)
3
[doc.metadata for doc in docs]
[{'title': "Obama's Middle Name -- My Last Name -- is 'Hussein.' So?",
  'link': 'https://www.cair.com/cair_in_the_news/obamas-middle-name-my-last-name-is-hussein-so/'},
 {'title': "What's up with Obama's middle name? - Quora",
  'link': 'https://www.quora.com/Whats-up-with-Obamas-middle-name'},
 {'title': 'Barack Obama | Biography, Parents, Education, Presidency, Books, ...',
  'link': 'https://www.britannica.com/biography/Barack-Obama'}]
[doc.page_content for doc in docs]
['I wasn’t sure whether to laugh or cry a few days back listening to radio talk show host Bill Cunningham repeatedly scream Barack <strong>Obama</strong>’<strong>s</strong> <strong>middle</strong> <strong>name</strong> — my last <strong>name</strong> — as if he had anti-Muslim Tourette’s. “Hussein,” Cunningham hissed like he was beckoning Satan when shouting the ...',
 'Answer (1 of 15): A better question would be, “What’s up with <strong>Obama</strong>’s first <strong>name</strong>?” President Barack Hussein <strong>Obama</strong>’s father’s <strong>name</strong> was Barack Hussein <strong>Obama</strong>. He was <strong>named</strong> after his father. Hussein, <strong>Obama</strong>’<strong>s</strong> <strong>middle</strong> <strong>name</strong>, is a very common Arabic <strong>name</strong>, meaning &quot;good,&quot; &quot;handsome,&quot; or ...',
 'Barack <strong>Obama</strong>, in full Barack Hussein <strong>Obama</strong> II, (born August 4, 1961, Honolulu, Hawaii, U.S.), 44th president of the United States (2009–17) and the first African American to hold the office. Before winning the presidency, <strong>Obama</strong> represented Illinois in the U.S.']

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.