跳至主要内容

Brave 搜索

Brave Search 是 Brave Software 开发的一款搜索引擎。

  • Brave Search 使用其自己的网页索引。截至 2022 年 5 月,它涵盖了超过 100 亿个页面,并用于提供 92% 的搜索结果,而无需依赖任何第三方,其余结果则从 Bing API 服务器端检索或(在选择加入的情况下)从 Google 客户端检索。根据 Brave 的说法,该索引“有意保持小于 Google 或 Bing 的索引”,以帮助避免垃圾邮件和其他低质量内容,但缺点是“Brave Search 在恢复长尾查询方面还不如 Google 好”。
  • Brave Search Premium:截至 2023 年 4 月,Brave Search 是一个无广告网站,但它最终将转向一个包含广告的新模式,高级用户将获得无广告体验。默认情况下,不会从其用户那里收集包括 IP 地址在内的用户数据。需要高级帐户才能选择加入数据收集。

安装和设置

要访问 Brave Search API,您需要创建帐户并获取 API 密钥

api_key = "..."
from langchain_community.document_loaders import BraveSearchLoader
API 参考: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.']

此页面是否有帮助?


您还可以留下详细的反馈 在 GitHub 上.