Skip to content

Commit

Permalink
chore: improve doc string for google_search
Browse files Browse the repository at this point in the history
  • Loading branch information
luochen1990 committed Aug 7, 2024
1 parent 175e9b4 commit 6623b13
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ai_powered/tools/google_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ class SearchResult(TypedDict):

@make_tool
def google_search(keywords: str, options: SearchOption) -> List[SearchResult]:
''' 用Google搜索互联网,对于专业问题请用英文关键词搜索 '''
'''
Use Google to search the internet.
For professional inquiries, use English keywords for the search.
For time-sensitive questions, filter the search results using the dateRestrict option:
d[1] means within the last day, w[1] means within the last week, m[1] means within the last month.
'''

url = "https://www.googleapis.com/customsearch/v1"
params : dict[str, str] = {
"key": GOOGLE_API_KEY,
Expand All @@ -28,7 +34,7 @@ def google_search(keywords: str, options: SearchOption) -> List[SearchResult]:
}

response = requests.get(url, params=params)
response.raise_for_status() # 如果请求失败,抛出异常
response.raise_for_status() # if failed, raise exception

search_results = response.json()
results : list[SearchResult] = []
Expand Down

0 comments on commit 6623b13

Please sign in to comment.