Commit ba0b4ec

benny-dou <60535774+benny-dou@users.noreply.github.com>
2026-06-16 08:45:57
chore(arxiv): add AI summary inplace
1 parent be0a387
Changed files (1)
src
preview
src/preview/arxiv.py
@@ -18,6 +18,7 @@ from messages.progress import modify_progress
 from messages.sender import send2tg, send_blockquote_texts
 from messages.utils import smart_split
 from networking import download_file, hx_req
+from preview.utils import add_summary_url
 from summarize.summarize import summarize
 from utils import nowdt
 
@@ -68,7 +69,7 @@ async def preview_arxiv(
     comment = arxiv_info["comment"]
     abstract = arxiv_info["abstract"]
 
-    texts = f"๐Ÿ“„**[{title}]({url})**\n๐Ÿ‘ฅ{authors}\n๐Ÿ•’{updated}\n"
+    texts = f"๐Ÿ“„**[{title}]({url})**\n๐Ÿ•’{updated}\n๐Ÿ‘ฅ{authors}\n"
     if comment:
         texts += f"๐Ÿ“{comment}"
 
@@ -79,7 +80,7 @@ async def preview_arxiv(
     else:
         iframe = f'<iframe src="{pdf_url}" width="100%" height="800px" style="border: none; border-radius: 8px;"></iframe>'
         ptag = f'<p style="text-align: center;"><a href="{pdf_url}" target="_blank">ๅœจๆ–ฐๆ ‡็ญพ้กตไธญๆ‰“ๅผ€่ฎบๆ–‡</a></p>'
-        sources = [{"type": "text", "text": json.dumps(arxiv_info)}] + await extract_arxiv_tex(arxiv_id) + [{"type": "file", "path": pdf, "mime_type": "application/pdf"}]
+        sources = [{"type": "file", "path": pdf, "mime_type": "application/pdf"}, {"type": "text", "text": json.dumps(arxiv_info)}] + await extract_arxiv_tex(arxiv_id)
         summary = await summarize(
             sources=sources,
             title=title,
@@ -90,7 +91,11 @@ async def preview_arxiv(
             description={"emoji": "๐Ÿ“„", "name": "ๅŽŸๅง‹่ฎบๆ–‡", "html": iframe + ptag},
             force_r2_page=True,
         )
-        await send_blockquote_texts(client, status_msg, texts=summary.get("texts", ""), **kwargs)
+        telegraph_url = summary.get("telegraph_url")
+        if not telegraph_url:
+            await send_blockquote_texts(client, status_msg, texts=summary.get("texts", ""), **kwargs)
+        else:
+            await add_summary_url(telegraph_url, status_msg)
 
     Path(pdf).unlink(missing_ok=True)