mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-03 20:16:52 +00:00
community[minor]: Improve Brave Search Tool, allow api key in env var (#30364)
- **Description:** - Make Brave Search Tool consistent with other tools and allow reading its api key from `BRAVE_SEARCH_API_KEY` instead of having to pass the api key manually (no breaking changes) - Improve Brave Search Tool by storing api key in `SecretStr` instead of plain `str`. - Add unit test for `BraveSearchWrapper` - Reflect the changes in the documentation - **Issue:** N/A - **Dependencies:** N/A - **Twitter handle:** ivan_brko
This commit is contained in:
@@ -43,12 +43,21 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": null,
|
||||
"id": "5b14008a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"tool = BraveSearch.from_api_key(api_key=api_key, search_kwargs={\"count\": 3})"
|
||||
"tool = BraveSearch.from_api_key(api_key=api_key, search_kwargs={\"count\": 3})\n",
|
||||
"\n",
|
||||
"# or if you want to get the api key from environment variable BRAVE_SEARCH_API_KEY, and leave search_kwargs empty\n",
|
||||
"# tool = BraveSearch()\n",
|
||||
"\n",
|
||||
"# or if you want to provide just the api key, and leave search_kwargs empty\n",
|
||||
"# tool = BraveSearch.from_api_key(api_key=api_key)\n",
|
||||
"\n",
|
||||
"# or if you want to provide just the search_kwargs and read the api key from the BRAVE_SEARCH_API_KEY environment variable\n",
|
||||
"# tool = BraveSearch.from_search_kwargs(search_kwargs={\"count\": 3})"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user