Brave Search
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 Reference: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 "good," "handsome," 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.']
Related
- Document loader conceptual guide
- Document loader how-to guides