From 03e3af689490cfba4787881809201c1b4c0b2c55 Mon Sep 17 00:00:00 2001 From: Eminem <19890913k@163.com> Date: Sun, 27 Oct 2024 09:57:45 +0800 Subject: [PATCH 1/2] [SerperRM Bug] valid_url_to_snippets.get(url, {}) get none value. call strip function will be fix it. just like url.strip("\'") --- knowledge_storm/rm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knowledge_storm/rm.py b/knowledge_storm/rm.py index ec57d79a..19c64e08 100644 --- a/knowledge_storm/rm.py +++ b/knowledge_storm/rm.py @@ -537,7 +537,7 @@ def forward(self, query_or_queries: Union[str, List[str]], exclude_urls: List[st snippets = [organic.get("snippet")] if self.ENABLE_EXTRA_SNIPPET_EXTRACTION: snippets.extend( - valid_url_to_snippets.get(url, {}).get("snippets", []) + valid_url_to_snippets.get(url.strip("\'"), {}).get("snippets", []) ) collected_results.append( { From d7d8f4086c649c1a19991357c4ecadfcb682b594 Mon Sep 17 00:00:00 2001 From: Eminem <19890913k@163.com> Date: Sun, 27 Oct 2024 16:59:52 +0800 Subject: [PATCH 2/2] [SerperRM Bug] valid_url_to_snippets.get(url, {}) get none value. call strip function will be fix it. just like url.strip("\'"). format code and commit. --- knowledge_storm/rm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/knowledge_storm/rm.py b/knowledge_storm/rm.py index 19c64e08..a9836275 100644 --- a/knowledge_storm/rm.py +++ b/knowledge_storm/rm.py @@ -537,7 +537,9 @@ def forward(self, query_or_queries: Union[str, List[str]], exclude_urls: List[st snippets = [organic.get("snippet")] if self.ENABLE_EXTRA_SNIPPET_EXTRACTION: snippets.extend( - valid_url_to_snippets.get(url.strip("\'"), {}).get("snippets", []) + valid_url_to_snippets.get(url.strip("'"), {}).get( + "snippets", [] + ) ) collected_results.append( {