The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
handle search errors (#70)
Harrison Chasedce26dfceccb
diff --git a/langchain/chains/serpapi.py b/langchain/chains/serpapi.pyindex ffa6062c98..007e90bc7c 100644--- a/langchain/chains/serpapi.py+++ b/langchain/chains/serpapi.py@@ -94,7 +94,8 @@ class SerpAPIChain(Chain, BaseModel):with HiddenPrints():search = self.search_engine(params)res = search.get_dict()-+ if "error" in res.keys():+ raise ValueError(f"Got error from SerpAPI: {res['error']}")if "answer_box" in res.keys() and "answer" in res["answer_box"].keys():toret = res["answer_box"]["answer"]elif "answer_box" in res.keys() and "snippet" in res["answer_box"].keys():