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搜索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.']