Skip to content

Commit

Permalink
disable ddg
Browse files Browse the repository at this point in the history
  • Loading branch information
FOLLGAD committed May 24, 2023
1 parent c75ab03 commit 07f078f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,6 @@ vicuna-*
openai/

# news
CURRENT_BULLETIN.md
CURRENT_BULLETIN.md
credentials/
.env*
44 changes: 22 additions & 22 deletions autogpt/commands/google_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,36 @@
from autogpt.commands.command import command
from autogpt.config import Config

from googleapiclient.discovery import build
from googleapiclient.errors import HttpError

global_config = Config()


@command("google", "Google Search", '"query": "<query>"', not global_config.google_api_key)
def google_search(query: str, num_results: int = 8, **kwargs) -> str:
"""Return the results of a Google search
# @command("google", "Google Search", '"query": "<query>"', not bool(global_config.google_api_key))
# def google_search(query: str, num_results: int = 8, **kwargs) -> str:
# """Return the results of a Google search

Args:
query (str): The search query.
num_results (int): The number of results to return.
# Args:
# query (str): The search query.
# num_results (int): The number of results to return.

Returns:
str: The results of the search.
"""
search_results = []
if not query:
return json.dumps(search_results)
# Returns:
# str: The results of the search.
# """
# search_results = []
# if not query:
# return json.dumps(search_results)

results = ddg(query, max_results=num_results)
if not results:
return json.dumps(search_results)
# results = ddg(query, max_results=num_results)
# if not results:
# return json.dumps(search_results)

for j in results:
search_results.append(j)
# for j in results:
# search_results.append(j)

results = json.dumps(search_results, ensure_ascii=False, indent=4)
return safe_google_results(results)
# results = json.dumps(search_results, ensure_ascii=False, indent=4)
# return safe_google_results(results)


@command(
Expand All @@ -55,9 +58,6 @@ def google_official_search(query: str, num_results: int = 8, **kwargs) -> str |
str: The results of the search.
"""

from googleapiclient.discovery import build
from googleapiclient.errors import HttpError

try:
# Get the Google API key and Custom Search Engine ID from the config file
api_key = global_config.google_api_key
Expand Down

0 comments on commit 07f078f

Please sign in to comment.