RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(agent): fall back to the default email when PubMed email is blank (#20509)
Eugene Kalinin3b81c1a3ee17
diff --git a/internal/agent/tool/pubmed_test.go b/internal/agent/tool/pubmed_test.goindex b218c454e0..62dbdb377c 100644--- a/internal/agent/tool/pubmed_test.go+++ b/internal/agent/tool/pubmed_test.go@@ -260,6 +260,40 @@ func TestPubMed_BuildByNameAcceptsNodeParams(t *testing.T) {}}+// The agent UI saves the PubMed email as an empty string by default; a blank email+// must build and fall back to the default contact address.+func TestPubMed_BuildByNameBlankEmailUsesDefault(t *testing.T) {+ t.Parallel()++ for _, email := range []string{"", " "} {+ built, err := BuildByName("pubmed", map[string]any{"top_n": 12, "email": email})+ if err != nil {+ t.Fatalf("BuildByName(email=%q): %v", email, err)+ }+ tool, ok := built.(*PubMedTool)+ if !ok {+ t.Fatalf("built type = %T, want *PubMedTool", built)+ }+ if tool.defaults.Email != "[email protected]" {+ t.Fatalf("email=%q: defaults.Email = %q, want [email protected]", email, tool.defaults.Email)+ }+ }+}++func TestPubMed_BuildAllAcceptsBlankEmail(t *testing.T) {+ t.Parallel()++ tools, err := BuildAll([]string{"PubMed"}, map[string]map[string]any{+ "pubmed": {"top_n": 12, "email": ""},+ })+ if err != nil {+ t.Fatalf("BuildAll: %v", err)+ }+ if len(tools) != 1 {+ t.Fatalf("len(tools) = %d, want 1", len(tools))+ }+}+func TestPubMed_ComponentReferencesAndOutputs(t *testing.T) {ctx := t.Context()t.Parallel()@@ -315,7 +349,7 @@ func TestPubMed_BuildByNameRejectsInvalidTopN(t *testing.T) {func TestPubMed_BuildByNameRejectsInvalidNodeTypes(t *testing.T) {t.Parallel()- for _, params := range []map[string]any{{"top_n": 1.5}, {"email": 1}, {"email": ""}} {+ for _, params := range []map[string]any{{"top_n": 1.5}, {"email": 1}} {if _, err := BuildByName("pubmed", params); err == nil {t.Fatalf("BuildByName(%#v) succeeded", params)}diff --git a/internal/agent/tool/registry.go b/internal/agent/tool/registry.goindex d92f515be7..9797ba39d2 100644--- a/internal/agent/tool/registry.go+++ b/internal/agent/tool/registry.go@@ -390,8 +390,8 @@ func buildPubMedTool(params map[string]any) (einotool.BaseTool, error) {}if value, ok := params["email"]; ok {email, valid := value.(string)- if !valid || strings.TrimSpace(email) == "" {- return nil, fmt.Errorf("agent tool: tool %q requires non-empty string node-level param email", "pubmed")+ if !valid {+ return nil, fmt.Errorf("agent tool: tool %q requires string node-level param email", "pubmed")}defaults.Email = email}diff --git a/web/src/locales/en.ts b/web/src/locales/en.tsindex aa62445d8b..8f18431a02 100644--- a/web/src/locales/en.ts+++ b/web/src/locales/en.ts@@ -3009,7 +3009,7 @@ Best for: Documents with flowing, contextually connected content — such as boobgptDaysBackTip: 'Optional recency filter (e.g. 365 for the last year).',email: 'Email',emailTip:- 'E-mail is a required field. You must input an E-mail address here.',+ 'E-mail is optional. If left empty, a default E-mail address is used for PubMed requests.',arXiv: 'ArXiv',arXivDescription:'A component that searches from https://arxiv.org/, allowing you to specify the number of search results using TopN. It supplements the existing datasets.',diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.tsindex d44f084698..8ce5747d33 100644--- a/web/src/locales/zh.ts+++ b/web/src/locales/zh.ts@@ -2585,11 +2585,11 @@ NER:使用 spaCy NER 和基于规则的关键词提取来抽取 Entities 和 R'LLM 需要查看的对话历史窗口大小。越大越好。但要注意 LLM 的最大 Token 数。',wikipedia: '维基百科',emailTip:- '此组件用于从 https://pubmed.ncbi.nlm.nih.gov/ 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要调整的搜索结果数。电子邮件是必填字段。',+ '此组件用于从 https://pubmed.ncbi.nlm.nih.gov/ 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要调整的搜索结果数。电子邮件为选填项,留空时将使用默认邮箱地址。',email: '邮箱',pubMed: 'PubMed',pubMedDescription:- '此组件用于从 https://pubmed.ncbi.nlm.nih.gov/ 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要调整的搜索结果数。电子邮件是必填字段。',+ '此组件用于从 https://pubmed.ncbi.nlm.nih.gov/ 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要调整的搜索结果数。电子邮件为选填项,留空时将使用默认邮箱地址。',bGPT: 'BGPT',bGPTDescription:'通过 BGPT 搜索科学论文,并返回全文提取的结构化证据:方法、样本量、局限性、利益冲突、数据可用性、研究盲点和可证伪性提示。免费额度后可选 API Key。',diff --git a/web/src/pages/agent/form/pubmed-form/index.tsx b/web/src/pages/agent/form/pubmed-form/index.tsxindex a2c35d55c6..253040f64e 100644--- a/web/src/pages/agent/form/pubmed-form/index.tsx+++ b/web/src/pages/agent/form/pubmed-form/index.tsx@@ -25,7 +25,7 @@ import { QueryVariable } from '../components/query-variable';export const PubMedFormPartialSchema = {top_n: z.number(),- email: z.string().email(),+ email: z.string().email().or(z.literal('')),};export const FormSchema = z.object({