mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-20 05:43:55 +00:00
Harrison/serp api imp (#444)
improve serp api Co-authored-by: Bruno Bornsztein <bruno.bornsztein@gmail.com>
This commit is contained in:
parent
ffe35c396c
commit
c994ce6b7f
@ -92,6 +92,16 @@ class SerpAPIWrapper(BaseModel):
|
|||||||
toret = res["answer_box"]["snippet_highlighted_words"][0]
|
toret = res["answer_box"]["snippet_highlighted_words"][0]
|
||||||
elif "snippet" in res["organic_results"][0].keys():
|
elif "snippet" in res["organic_results"][0].keys():
|
||||||
toret = res["organic_results"][0]["snippet"]
|
toret = res["organic_results"][0]["snippet"]
|
||||||
|
elif (
|
||||||
|
"sports_results" in res.keys()
|
||||||
|
and "game_spotlight" in res["sports_results"].keys()
|
||||||
|
):
|
||||||
|
toret = res["sports_results"]["game_spotlight"]
|
||||||
|
elif (
|
||||||
|
"knowledge_graph" in res.keys()
|
||||||
|
and "description" in res["knowledge_graph"].keys()
|
||||||
|
):
|
||||||
|
toret = res["knowledge_graph"]["description"]
|
||||||
else:
|
else:
|
||||||
toret = "No good search result found"
|
toret = "No good search result found"
|
||||||
return toret
|
return toret
|
||||||
|
Loading…
Reference in New Issue
Block a user