From 5e47c648ed2c1fd832f35852a5cdad0cbeefd475 Mon Sep 17 00:00:00 2001 From: venetisgr <38510475+venetisgr@users.noreply.github.com> Date: Mon, 22 May 2023 16:34:36 -0400 Subject: [PATCH] Update serpapi.py (#4947) Added link option in _process_response Fixes # (issue) In _process_response link provided correct answers while the snippet reply provided non working links @vowelparrot ## Before submitting ## Who can review? Community members can review the PR once tests pass. Tag maintainers/contributors who might be interested: --------- Co-authored-by: Dev 2049 --- langchain/utilities/serpapi.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/langchain/utilities/serpapi.py b/langchain/utilities/serpapi.py index 65042264..60ceb378 100644 --- a/langchain/utilities/serpapi.py +++ b/langchain/utilities/serpapi.py @@ -150,6 +150,8 @@ class SerpAPIWrapper(BaseModel): toret = res["knowledge_graph"]["description"] elif "snippet" in res["organic_results"][0].keys(): toret = res["organic_results"][0]["snippet"] + elif "link" in res["organic_results"][0].keys(): + toret = res["organic_results"][0]["link"] else: toret = "No good search result found"