-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete implementation of AI Tools #41
Use Google Search, Bing search, Tavily web search for web search (e.g. can you give me some articles to read about anxiety in the workplace?) Use Google places for maps search (e.g. Where are some therapists in my area?) added youtube too
- Loading branch information
1 parent
8758661
commit 99e9c10
Showing
5 changed files
with
110 additions
and
35 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,75 @@ | ||
""" This module contains the agent functions that interact with the external APIs. """ | ||
|
||
from langchain_google_community import GoogleSearchAPIWrapper, GoogleSearchResults, GooglePlacesTool, GooglePlacesAPIWrapper | ||
from langchain_community.utilities import BingSearchAPIWrapper | ||
from langchain_community.tools import YouTubeSearchTool | ||
|
||
def get_google_search_results(query): | ||
""" | ||
Uses Google Custom Search to fetch search results for a given query. | ||
Args: | ||
query (str): The search query. | ||
Returns: | ||
list: A list of search results with titles and links. | ||
""" | ||
|
||
try: | ||
google_search_wrapper = GoogleSearchAPIWrapper(k=3) | ||
search_results = google_search_wrapper.run(query) | ||
print("Search results obtained:", search_results) | ||
|
||
# Ensure the results are JSON-serializable | ||
|
||
return search_results | ||
|
||
except Exception as e: | ||
print(f"Failed to fetch Google search results: {e}") | ||
return None | ||
|
||
def get_youtube_search_results(query): | ||
""" | ||
Uses YouTube Search to fetch search results for a given query. | ||
Args: | ||
query (str): The search query. | ||
Returns: | ||
list: A list of search results with titles, descriptions, and video links. | ||
""" | ||
try: | ||
youtube_search_tool = YouTubeSearchTool() | ||
search_results = youtube_search_tool.run(query) | ||
print("Search results obtained:", search_results) | ||
|
||
# Ensure the results are JSON-serializable | ||
return search_results | ||
|
||
except Exception as e: | ||
print(f"Failed to fetch YouTube search results: {e}") | ||
return None | ||
|
||
|
||
def get_bing_search_results(query): | ||
""" | ||
Uses Bing Search to fetch search results for a given query. | ||
Args: | ||
query (str): The search query. | ||
Returns: | ||
list: A list of search results with titles and links. | ||
""" | ||
try: | ||
bing_search_wrapper = BingSearchAPIWrapper() | ||
search_results = bing_search_wrapper.run(query) | ||
print("Search results obtained:", search_results) | ||
|
||
# Ensure the results are JSON-serializable | ||
return search_results | ||
|
||
except Exception as e: | ||
print(f"Failed to fetch Bing search results: {e}") | ||
return None | ||
|