(
pdf_error: Optional[str],
*,
fallback_mode: str = "abstract",
response_language: str = "zh",
)
| 793 | |
| 794 | |
| 795 | def _describe_pdf_fallback( |
| 796 | pdf_error: Optional[str], |
| 797 | *, |
| 798 | fallback_mode: str = "abstract", |
| 799 | response_language: str = "zh", |
| 800 | ) -> str: |
| 801 | is_en = _normalize_response_language(response_language) == "en" |
| 802 | lowered = _clean_text(pdf_error).lower() |
| 803 | if not lowered: |
| 804 | reason = "The PDF full text was unavailable" if is_en else "未能拿到 PDF 全文" |
| 805 | elif "403" in lowered or "forbidden" in lowered: |
| 806 | reason = "The source blocked PDF access" if is_en else "源站拒绝了 PDF 访问" |
| 807 | elif "timed out" in lowered or "timeout" in lowered: |
| 808 | reason = "PDF fetching timed out" if is_en else "PDF 抓取超时" |
| 809 | elif "ssl" in lowered or "eof" in lowered or "connection" in lowered: |
| 810 | reason = "The network connection was unstable while fetching the PDF" if is_en else "PDF 抓取时网络连接不稳定" |
| 811 | elif "content-type" in lowered or "did not return a pdf" in lowered: |
| 812 | reason = "The source did not return a PDF file directly" if is_en else "源站没有直接返回 PDF 文件" |
| 813 | else: |
| 814 | reason = "PDF fetching or parsing failed" if is_en else "PDF 抓取或解析失败" |
| 815 | if is_en: |
| 816 | if fallback_mode == "source_page": |
| 817 | return ( |
| 818 | f"{reason}; this report fell back to the source page text and metadata. " |
| 819 | "Verify method and experiment details in the original paper." |
| 820 | ) |
| 821 | return ( |
| 822 | f"{reason}; this report fell back to the template, abstract, and metadata. " |
| 823 | "Verify method and experiment details in the original paper." |
| 824 | ) |
| 825 | if fallback_mode == "source_page": |
| 826 | return f"{reason},本次报告已回退为基于源站正文和元数据生成;方法与实验细节仍建议回原文核对。" |
| 827 | return f"{reason},本次报告改为按模板基于摘要和元数据生成;方法与实验细节建议回原文核对。" |
| 828 | |
| 829 | |
| 830 | def _recommendation_score(label: str) -> int: |
no test coverage detected