From 8508a352520c2328da1e77b0525bdd17941c7c1c Mon Sep 17 00:00:00 2001 From: liuweiqing Date: Sun, 28 Jan 2024 19:01:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4pubmed=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/GetPubMed .tsx | 5 ++--- components/chatAI.tsx | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/components/GetPubMed .tsx b/components/GetPubMed .tsx index 8e479c30..675cdcff 100644 --- a/components/GetPubMed .tsx +++ b/components/GetPubMed .tsx @@ -16,9 +16,8 @@ async function getPubMedPapers(query: string, year: number, limit = 2) { "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi"; const db = "pubmed"; // 设定搜索的数据库为PubMed const retMax = limit; // 检索的最大记录数 - const retStart = getRandomOffset(10 - limit); // 假设每页最多10条,根据需要随机偏移 - - const url = `${baseURL}?db=${db}&term=${query}[Title/Abstract]+AND+${year}[Date+-+Publication]&retMax=${retMax}&retStart=${retStart}&api_key=${process.env.NEXT_PUBLIC_PUBMED_API_KEY}`; + const retStart = getRandomOffset(30 - limit); // 假设每页最多30条,根据需要随机偏移 + const url = `${baseURL}?db=${db}&term=${query}[Title/Abstract]+AND+2018:3000[Date - Publication]&retMax=${retMax}&retStart=${retStart}&api_key=${process.env.NEXT_PUBLIC_PUBMED_API_KEY}`; const response = await axios.get(url, { responseType: "text" }); console.log(response.data); // 解析XML数据 diff --git a/components/chatAI.tsx b/components/chatAI.tsx index 1fc162d4..da024a95 100644 --- a/components/chatAI.tsx +++ b/components/chatAI.tsx @@ -58,7 +58,7 @@ const sendMessageToOpenAI = async ( prompt || `作为论文写作助手,您的主要任务是根据用户提供的研究主题和上下文,以及相关的研究论文,来撰写和完善学术论文。在撰写过程中,请注意以下要点: 1.学术格式:请采用标准的学术论文格式进行写作,包括清晰的段落结构、逻辑严谨的论点展开,以及恰当的专业术语使用。 - 2.文献引用:只引用与主题紧密相关的论文。在引用文献时,文末应使用方括号内的数字来标注引用来源,如 [1]。请确保每个引用在文章中都有其对应的编号,*无需在文章末尾提供参考文献列表*。 + 2.文献引用:只引用与主题紧密相关的论文。在引用文献时,文末应使用方括号内的数字来标注引用来源,如 [1]。。请确保每个引用在文章中都有其对应的编号,*无需在文章末尾提供参考文献列表*。*每个文献对应的序号只应该出现一次,比如说引用了第一篇文献文中就只能出现一次[1]*。 3.忽略无关文献:对于与主题无关的论文,请不要包含在您的写作中。只关注对理解和阐述主题有实质性帮助的资料。 4.来源明确:在文章中,清楚地指出每个引用的具体来源。引用的信息应准确无误,确保读者能够追溯到原始文献。 5.使用用户所说的语言完成回答,不超过三百字 @@ -154,7 +154,7 @@ async function processResult(reader, decoder, editor) { break; } buffer += decoder.decode(value, { stream: true }); - console.log("buffer", buffer); + // console.log("buffer", buffer); // 处理缓冲区中的所有完整的 JSON 对象 let boundary; try { @@ -162,7 +162,7 @@ async function processResult(reader, decoder, editor) { // 找到一个完整的 JSON 对象的边界 let jsonStr = buffer.substring(0, boundary + 1); buffer = buffer.substring(boundary + 2); - console.log("jsonStr", jsonStr); + // console.log("jsonStr", jsonStr); // 尝试解析 JSON 对象 try {