From ff1e79603d9d1577ccfcb404efeef0dfb2ad9991 Mon Sep 17 00:00:00 2001 From: AnotiaWang Date: Sun, 23 Mar 2025 14:53:09 +0800 Subject: [PATCH] chore: throw error when no search results found --- i18n/en.json | 3 ++- i18n/nl.json | 3 ++- i18n/zh.json | 3 ++- lib/deep-research.ts | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index 4897bd9..fda8a0b 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -92,7 +92,8 @@ "nodeFailed": "Search failed", "nodeFailedToast": "Search node \"{label}\" failed", "followUpQuestions": "Follow-up Questions", - "retry": "Retry" + "retry": "Retry", + "noSearchResult": "No search results found" }, "researchReport": { "title": "4. Research Report", diff --git a/i18n/nl.json b/i18n/nl.json index 478ae73..db8875a 100644 --- a/i18n/nl.json +++ b/i18n/nl.json @@ -92,7 +92,8 @@ "nodeFailed": "Zoeken mislukt", "nodeFailedToast": "Zoekknooppunt \"{label}\" is mislukt", "followUpQuestions": "Vervolgvragen", - "retry": "Opnieuw proberen" + "retry": "Opnieuw proberen", + "noSearchResult": "Geen zoekresultaten gevonden" }, "researchReport": { "title": "4. Onderzoeksrapport", diff --git a/i18n/zh.json b/i18n/zh.json index 47bef65..6ba3446 100644 --- a/i18n/zh.json +++ b/i18n/zh.json @@ -92,7 +92,8 @@ "nodeFailed": "搜索失败", "nodeFailedToast": "搜索步骤 “{label}” 失败", "followUpQuestions": "后续问题", - "retry": "重试" + "retry": "重试", + "noSearchResult": "未找到搜索结果" }, "researchReport": { "title": "4. 研究报告", diff --git a/lib/deep-research.ts b/lib/deep-research.ts index 761966a..6add729 100644 --- a/lib/deep-research.ts +++ b/lib/deep-research.ts @@ -384,6 +384,9 @@ export async function deepResearch({ maxResults: 5, lang: languageCode, }) + if (!results.length) { + throw new Error(t('webBrowsing.noSearchResult')) + } console.log( `[DeepResearch] Searched "${searchQuery.query}", found ${results.length} contents`, )