feat: 添加译文功能 + Attention Is All You Need 中文译本
This commit is contained in:
@@ -464,6 +464,24 @@ def download_single_pdf(arxiv_id: str):
|
||||
except subprocess.TimeoutExpired:
|
||||
return {"ok": False, "arxiv_id": arxiv_id, "status": "timeout"}
|
||||
|
||||
# ─── Routes: Translated PDFs ────────────────────────────
|
||||
TRANSLATED_DIR = PAPERS_DIR / "translated"
|
||||
|
||||
@app.get("/api/translated/{arxiv_id}")
|
||||
def check_translation(arxiv_id: str):
|
||||
"""Check if translation exists for a paper"""
|
||||
fn = f"{arxiv_id}.pdf"
|
||||
return {"arxiv_id": arxiv_id, "exists": (TRANSLATED_DIR / fn).exists()}
|
||||
|
||||
@app.get("/papers/translated/{arxiv_id}.pdf")
|
||||
def serve_translated(arxiv_id: str):
|
||||
"""Serve translated PDF from cache"""
|
||||
fp = TRANSLATED_DIR / f"{arxiv_id}.pdf"
|
||||
if not fp.exists():
|
||||
raise HTTPException(status_code=404, detail="Translation not found")
|
||||
return FileResponse(fp, media_type="application/pdf",
|
||||
headers={"Content-Disposition": "inline"})
|
||||
|
||||
# ─── Health ─────────────────────────────────────────────
|
||||
@app.get("/api/health")
|
||||
def health():
|
||||
|
||||
Reference in New Issue
Block a user