added support for Google Images search (#7751)

- Description: Added Google Image Search support for SerpAPIWrapper 
  - Issue: NA
  - Dependencies: None
  - Tag maintainer: @hinthornw
  - Twitter handle: @sausheong

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
Chang Sau Sheong 2023-07-15 22:04:18 +08:00 committed by GitHub
parent 1ff5b67025
commit b6a7f40ad3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -159,7 +159,12 @@ class SerpAPIWrapper(BaseModel):
toret = res["organic_results"][0]["snippet"] toret = res["organic_results"][0]["snippet"]
elif "link" in res["organic_results"][0].keys(): elif "link" in res["organic_results"][0].keys():
toret = res["organic_results"][0]["link"] toret = res["organic_results"][0]["link"]
elif (
"images_results" in res.keys()
and "thumbnail" in res["images_results"][0].keys()
):
thumbnails = [item["thumbnail"] for item in res["images_results"][:10]]
toret = thumbnails
else: else:
toret = "No good search result found" toret = "No good search result found"
return toret return toret