{"record":{"id":"bc71d18342fc4858","repo":"binary-husky/gpt_academic","slug":"grobid-config-grobid-url-grobid","errorCode":null,"errorMessage":"GROBID服务不可用，请修改config中的GROBID_URL，可修改成本地GROBID服务。","messagePattern":"GROBID服务不可用，请修改config中的GROBID_URL，可修改成本地GROBID服务。","errorType":"exception","errorClass":"GROBID_OFFLINE_EXCEPTION","httpStatus":null,"severity":"error","filePath":"crazy_functions/pdf_fns/parse_pdf.py","lineNumber":37,"sourceCode":"    try:\n        _grobid_url = random.choice(GROBID_URLS) # 随机负载均衡\n        if _grobid_url.endswith('/'): _grobid_url = _grobid_url.rstrip('/')\n        with ProxyNetworkActivate('Connect_Grobid'):\n            res = requests.get(_grobid_url+'/api/isalive')\n        if res.text=='true': return _grobid_url\n        else: return None\n    except:\n        return None\n\n@lru_cache(maxsize=32)\ndef parse_pdf(pdf_path, grobid_url):\n    import scipdf   # pip install scipdf_parser\n    if grobid_url.endswith('/'): grobid_url = grobid_url.rstrip('/')\n    try:\n        with ProxyNetworkActivate('Connect_Grobid'):\n            article_dict = scipdf.parse_pdf_to_dict(pdf_path, grobid_url=grobid_url)\n    except GROBID_OFFLINE_EXCEPTION:\n        raise GROBID_OFFLINE_EXCEPTION(\"GROBID服务不可用，请修改config中的GROBID_URL，可修改成本地GROBID服务。\")\n    except:\n        raise RuntimeError(\"解析PDF失败，请检查PDF是否损坏。\")\n    return article_dict\n\n\ndef produce_report_markdown(gpt_response_collection, meta, paper_meta_info, chatbot, fp, generated_conclusion_files):\n    # -=-=-=-=-=-=-=-= 写出第1个文件：翻译前后混合 -=-=-=-=-=-=-=-=\n    res_path = write_history_to_file(meta +  [\"# Meta Translation\" , paper_meta_info] + gpt_response_collection, file_basename=f\"{gen_time_str()}translated_and_original.md\", file_fullname=None)\n    promote_file_to_downloadzone(res_path, rename_file=os.path.basename(res_path)+'.md', chatbot=chatbot)\n    generated_conclusion_files.append(res_path)\n\n    # -=-=-=-=-=-=-=-= 写出第2个文件：仅翻译后的文本 -=-=-=-=-=-=-=-=\n    translated_res_array = []\n    # 记录当前的大章节标题：\n    last_section_name = \"\"\n    for index, value in enumerate(gpt_response_collection):\n        # 先挑选偶数序列号：\n        if index % 2 != 0:","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/crazy_functions/pdf_fns/parse_pdf.py#L19-L55","documentation":"parse_pdf() calls the GROBID service (via scipdf.parse_pdf_to_dict) to structure a PDF; when the request fails in the specific way recognized as GROBID_OFFLINE_EXCEPTION (service unreachable / connection refused), it is re-raised with this guidance message. GROBID is an external HTTP service whose URL comes from config (GROBID_URL) — default points at a public instance that is often slow or down.","triggerScenarios":"GROBID_URL points to the default public server which is unreachable, rate-limited, or DNS-fails; a local GROBID container is not started; wrong port; ProxyNetworkActivate('Connect_Grobid') routing the request through a proxy that blocks it.","commonSituations":"Fresh installs relying on the default remote GROBID; local Docker GROBID not running (docker run grobid/grobid); corporate proxy environments; server behind firewall blocking outbound 8070.","solutions":["Run GROBID locally: docker run --rm -p 8070:8070 grobid/grobid and set GROBID_URL=http://127.0.0.1:8070","Verify the configured URL responds: curl <GROBID_URL>/api/isalive","If a local service is set, confirm the container/process is actually up and the port matches","Check proxy settings (ProxyNetworkActivate) are not redirecting GROBID traffic incorrectly"],"exampleFix":"# before (config)\nGROBID_URL = \"https://cloud.science-miner.com/grobid/\"\n\n# after\ndocker run -d --name grobid -p 8070:8070 grobid/grobid\nGROBID_URL = \"http://127.0.0.1:8070\"","handlingStrategy":"validation","validationCode":"import requests\n\ndef grobid_alive(url: str, timeout=5) -> bool:\n    try:\n        return requests.get(url.rstrip('/') + '/api/isalive', timeout=timeout).ok\n    except requests.RequestException:\n        return False\n\nif not grobid_alive(grobid_url):\n    raise RuntimeError('Start GROBID first: docker run -p 8070:8070 grobid/grobid')","typeGuard":null,"tryCatchPattern":"try:\n    article = parse_pdf(fp, grobid_url)\nexcept GROBID_OFFLINE_EXCEPTION:\n    # fall back to a non-GROBID parser or queue for retry after service start\n    article = parse_pdf_fallback(fp)","preventionTips":["Health-check GROBID_URL/api/isalive before batch jobs","Run a local GROBID container for reliability instead of the public instance","Keep GROBID_URL in one config location and validate it at startup"],"tags":["grobid","network","external-service","pdf-parsing","config"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}