generated from ks6088ts/template-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from ks6088ts-labs/feature/issue-67_support-bi…
…ng-search support bing search
- Loading branch information
Showing
6 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from os import getenv | ||
|
||
from langchain_core.tools import tool | ||
|
||
|
||
@tool | ||
def bing_search_tool(query: str) -> str: | ||
"""Perform web searches by 'query' using Bing Search API. Returns search results as a string.""" | ||
from langchain_community.utilities import BingSearchAPIWrapper | ||
|
||
return BingSearchAPIWrapper( | ||
k=int( | ||
getenv("BING_SEARCH_K", 1), | ||
), | ||
bing_search_url=getenv("BING_SEARCH_URL"), | ||
bing_subscription_key=getenv("BING_SUBSCRIPTION_KEY"), | ||
).run( | ||
query=query, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters