mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-28 17:38:36 +00:00
Fix failing serpapi response processing for Google Maps API (#14817)
**Description:** Fix for processing for serpapi response for Google Maps API **Issue:** Due to the fact corresponding [api](https://serpapi.com/google-maps-api) returns 'local_results' as list, and old version requested `res["local_results"].keys()` of the list. As the result we got exception: ```AttributeError: 'list' object has no attribute 'keys'```. Way to reproduce wrong behaviour: ``` params = { "engine": "google_maps", "type": "search", "google_domain": "google.de", "ll": "@51.1917,10.525,14z", "hl": "de", "gl": "de", } search = SerpAPIWrapper(params=params) results = search.run("cafe") ``` --------- Co-authored-by: Harrison Chase <hw.chase.17@gmail.com> Co-authored-by: Ran <rccalman@gmail.com>
This commit is contained in:
parent
da0f750a0b
commit
b4ec340fb3
@ -211,9 +211,14 @@ class SerpAPIWrapper(BaseModel):
|
||||
|
||||
if "buying_guide" in res.keys():
|
||||
snippets.append(res["buying_guide"])
|
||||
if "local_results" in res.keys() and "places" in res["local_results"].keys():
|
||||
if "local_results" in res and isinstance(res["local_results"], list):
|
||||
snippets += res["local_results"]
|
||||
if (
|
||||
"local_results" in res.keys()
|
||||
and isinstance(res["local_results"], dict)
|
||||
and "places" in res["local_results"].keys()
|
||||
):
|
||||
snippets.append(res["local_results"]["places"])
|
||||
|
||||
if len(snippets) > 0:
|
||||
return str(snippets)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user