Skip to content

The agent engineering platform.

Harrison/serp api imp (#444)

Harrison Chasec994ce6b7ff7
diff --git a/langchain/serpapi.py b/langchain/serpapi.py
index 6224939d58..cb9e68e27c 100644
--- a/langchain/serpapi.py
+++ b/langchain/serpapi.py
@@ -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