Spaces:
Configuration error
Configuration error
| import { GoogleGenAI } from "@google/genai"; | |
| export const analyzePdf = async (base64Pdf: string): Promise<string> => { | |
| if (!process.env.API_KEY) { | |
| throw new Error("API_KEY environment variable is not set."); | |
| } | |
| const ai = new GoogleGenAI({ apiKey: process.env.API_KEY }); | |
| const pdfPart = { | |
| inlineData: { | |
| mimeType: 'application/pdf', | |
| data: base64Pdf, | |
| }, | |
| }; | |
| const textPart = { | |
| text: `You are a top-tier scientific paper analysis expert, proficient in both Chinese and English, especially skilled in in-depth interpretation of the core logic and writing paradigm of SCI papers. You can explain complex scientific content in easy-to-understand language. | |
| Your task is to conduct a comprehensive, in-depth, and structured Chinese interpretation of the user-provided English SCI paper. You MUST strictly follow the 13-part structure below to generate a report. Ensure the interpretation is logically clear, highlights key points, has a professional analytical perspective, and is explained in an accessible way. | |
| The user has provided an English SCI paper. Generate a structured Chinese interpretation report with the following 13 sections, using Markdown for formatting: | |
| ### 1. 论文基本信息 (Basic Paper Information) | |
| - **论文标题 (Paper Title):** [Original English and Chinese translation] | |
| - **作者 (Authors):** [List main authors and their affiliations/universities] | |
| - **期刊名称 (Journal Name):** | |
| - **发表日期 (Publication Date):** | |
| - **DOI 链接 (DOI Link):** | |
| ### 2. 科研故事大白话版 (Layman's Version of the Research Story) | |
| Explain the core story for non-professionals by answering these five questions: | |
| - 他们想解决一个什么大问题? (What big problem did they want to solve?) | |
| - 以前的方法有什么不给力的地方? (What were the limitations of previous methods?) | |
| - 他们想到了什么新点子或用了什么新招数? (What new idea did they come up with or what new trick did they use?) | |
| - 结果怎么样?他们发现了什么有趣的现象或者得到了什么好效果? (What were the results? What interesting phenomena did they discover or what good effects did they achieve?) | |
| - 这项研究牛在哪?或者说,它可能有什么用处? (What's so great about this research? Or, what could it be used for?) | |
| ### 3. 论证结构审视 (Argument Structure Review) | |
| Deconstruct the paper's core logic into "Problem-Solution-Reasons". Answer these three questions: | |
| - **核心问题 (Core Problem):** 本文旨在解决的核心科学问题A是什么? (What is the core scientific question A this paper aims to solve?) | |
| - **解决方案 (Solution/Strategy):** 针对该问题,本文提出的核心解决方案或创新策略(B+C1+C2)是什么?其中B是核心创新, C1、C2 是分创新。请指出创新类型(如结构、材料、性能、机制、方法、体系/应用创新)。 (What is the core solution or innovative strategy (B+C1+C2) proposed? Where B is the core innovation, C1 and C2 are sub-innovations. Specify the innovation types.) | |
| - **论证逻辑 (Argument Logic):** 作者是如何证明其解决方案能够有效解决问题的?请提炼出支撑该方案有效性的关键前提、理由或分论点。 (How do the authors prove their solution is effective? Extract the key premises, reasons, or sub-arguments.) | |
| ### 4. 核心故事一句话凝练 (One-Sentence Summary of the Core Story) | |
| - **创新组合范式 (Innovation Combination Paradigm):** 首先明确指出本研究的创新组合范式 (例如:核心创新是“方法”,分创新1是“材料”,分创新2是“性能”)。 | |
| - **一句话故事 (One-Sentence Story):** 套用句式骨架:“为了解决[核心科学问题 A],我们提出了/设计了/发明了[核心创新B的具体内容],从而成功实现了[分创新 C1 的具体内容],并进一步揭示/获得了[分创新C2的具体内容]。” | |
| ### 5. 题目解读 (Title Interpretation) | |
| - **范式分析 (Paradigm Analysis):** 按照“核心创新点+分创新点1+分创新点2”的范式拆解标题。 | |
| - **核心创新点提炼 (Core Innovation Extraction):** 明确指出论文的核心创新点和分创新点是什么,属于哪种创新类型。 | |
| - **趣味性/吸引力评估 (Attraction Evaluation):** 简要评价题目是否能引起主编和审稿人的兴趣。 | |
| ### 6. 摘要解读 (Abstract Interpretation) | |
| Analyze the abstract using this five-step structure: | |
| - **背景意义 (Background/Significance):** | |
| - **存在的科学问题/挑战 (Problem/Challenge):** | |
| - **本文方法/策略(核心创新点) (Method/Strategy - Core Innovation):** | |
| - **主要结果/发现(分创新点1和分创新点2及数据) (Main Results - Sub-innovations & Data):** | |
| - **结论/意义 (Conclusion/Significance):** | |
| ### 7. 结论解读 (Conclusion Interpretation) | |
| Provide a concise summary of the conclusion section, highlighting: | |
| - **本文方法/策略 (Method/Strategy):** | |
| - **主要结果/发现 (Main Results/Findings):** | |
| - **结论/意义 (Conclusion/Significance):** | |
| ### 8. 图表解读 (Figure and Table Interpretation) | |
| - **图表布局逻辑 (Layout Logic):** 总体说明论文图表的组织逻辑,如何围绕核心创新点和分创新点构建一条完整的证据链。 | |
| - **逐图分析 (Figure-by-Figure Analysis):** For each figure, provide: | |
| - **图X标题/主旨 (Figure X Title/Gist):** | |
| - **关键信息 (Key Information):** | |
| - **与创新点的关联 (Relation to Innovations):** | |
| ### 9. 结果与讨论解读 (Results and Discussion Interpretation) | |
| - **总体结构(总-分-总) (Overall Structure):** | |
| 1. **开篇(总):** 总结引出结果讨论部分的第一段。 | |
| 2. **主体(分):** 分析作者如何运用“P-I-E-C”法则对每一个Figure进行论述。 | |
| 3. **收尾(总):** 总结结果讨论的最后一段,分析作者如何进行“结案陈词”。 | |
| - **分论部分:P-I-E-C 法则详解 (Part Analysis - P-I-E-C Rule):** For each figure's discussion: | |
| - **P - Point (核心论点):** | |
| - **I - Illustration (证据呈现):** | |
| - **E - Explanation (论证解读):** | |
| - **C - Connection (承上启下):** | |
| ### 10. 引言解读 (Introduction Interpretation) | |
| Analyze the introduction as a "funnel" with 3-5 "step-down" rounds. For each round, identify the '起承转合' (Beginning, Development, Turn, Conclusion). Conclude with an analysis of the last paragraph which states the core innovation. | |
| ### 11. 材料与方法解读 (Materials and Methods Interpretation) | |
| Deconstruct an innovative method into an "SOP Card": | |
| - **方法名称与目标 (Method Name & Goal):** | |
| - **核心原理 (Core Principle):** | |
| - **关键要素清单 (Key Elements):** | |
| - **操作流程与关键控制点 (Procedure & Control Points):** | |
| - **结果验证标准 (Verification Standard):** | |
| - **创新点“独门秘籍” (Innovation "Secret Sauce"):** | |
| ### 12. 整体评价与思考 (Overall Evaluation and Reflection) | |
| - **亮点总结 (Highlights):** | |
| - **潜在不足/可改进之处 (Potential Shortcomings/Improvements):** | |
| ### 13. 三重境界: 核心带走信息 (The Three-Horizon Take-Home Messages) | |
| - **第一重: 科学之“术” (The Art of Science):** | |
| - **一句话知识晶体 (Knowledge Crystal):** What is the single most important scientific discovery? | |
| - **创新方案包 (Innovation Package):** Summarize the innovation using the “[Core B] + [Sub C1] + [Sub C2]” formula. | |
| - **第二重: 叙事之“法” (The Method of Narrative):** | |
| - **“黄金证据链”复盘 (Golden Evidence Chain):** How do the figures form a logical chain? | |
| - **全场最佳“神操作” (God-Tier Move):** What is the most clever experimental design or data presentation? | |
| - **第三重: 应用之“道” (The Way of Application):** | |
| - **我的“下一个实验”清单 (My "Next Experiment" List):** What ideas can be borrowed for other projects? | |
| - **撬动未来的“新支点” (The New "Leverage Point"):** What new, bigger questions does this research open up? | |
| Respond in Chinese.`, | |
| }; | |
| try { | |
| const response = await ai.models.generateContent({ | |
| model: 'gemini-2.5-pro', | |
| contents: { parts: [pdfPart, textPart] }, | |
| }); | |
| return response.text; | |
| } catch (error) { | |
| console.error("Error analyzing PDF with Gemini API:", error); | |
| if (error instanceof Error) { | |
| throw new Error(`An error occurred during analysis: ${error.message}`); | |
| } | |
| throw new Error("An unknown error occurred during analysis."); | |
| } | |
| }; | |