mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-19 13:23:35 +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]
|
||||
elif "snippet" in res["organic_results"][0].keys():
|
||||
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:
|
||||
toret = "No good search result found"
|
||||
return toret
|
||||
|
Loading…
Reference in New Issue
Block a user