4
This commit is contained in:
@@ -163,9 +163,12 @@ def kb_index_html(
|
||||
doc_url = f"/k/{token}/doc/{decrypt_token(doc.doc_token_encrypted) if doc.doc_token_encrypted else ''}"
|
||||
keywords_html = f'<span class="keywords">关键词:{doc.keywords}</span>' if doc.keywords else ""
|
||||
summary_html = f'<p class="summary">{doc.content_summary or ""}</p>' if doc.content_summary else ""
|
||||
status_badge = ""
|
||||
if doc.status != "READY":
|
||||
status_badge = f' <span class="status-badge">[{doc.status}]</span>'
|
||||
doc_rows += f"""
|
||||
<div class="doc-item">
|
||||
<h3><a href="{doc_url}">{doc.title or doc.original_filename}</a></h3>
|
||||
<h3><a href="{doc_url}">{doc.title or doc.original_filename}</a>{status_badge}</h3>
|
||||
<p class="meta">类型:{doc.file_ext} | 更新:{doc.updated_at}</p>
|
||||
{summary_html}
|
||||
{keywords_html}
|
||||
@@ -195,6 +198,7 @@ def kb_index_html(
|
||||
.summary {{ color: #444; font-size: 0.95em; margin: 5px 0; }}
|
||||
.keywords {{ color: #888; font-size: 0.85em; }}
|
||||
.pagination {{ color: #666; font-size: 0.9em; text-align: center; }}
|
||||
.status-badge {{ color: #e67e22; font-size: 0.8em; font-weight: normal; }}
|
||||
.footer {{ margin-top: 30px; padding-top: 15px; border-top: 1px solid #eee; color: #999; font-size: 0.85em; }}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@@ -29,9 +29,9 @@ class KbPublicService:
|
||||
def list_documents(
|
||||
self, kb: KnowledgeBase, *, page: int = 1, page_size: int = 50
|
||||
) -> tuple[list[Document], int]:
|
||||
"""获取知识库的文档列表(仅 READY 状态)。"""
|
||||
"""获取知识库的文档列表(排除 DELETED)。"""
|
||||
return self._doc_repo.list_by_knowledge_base(
|
||||
kb.id, page=page, page_size=page_size, status="READY"
|
||||
kb.id, page=page, page_size=page_size
|
||||
)
|
||||
|
||||
def get_document_by_token(self, kb: KnowledgeBase, doc_token: str) -> Document:
|
||||
|
||||
@@ -20,8 +20,8 @@ python-multipart>=0.0.7
|
||||
# --- 文档解析 ---
|
||||
# MIME 嗅探:纯 Python,Windows 无需 libmagic DLL
|
||||
filetype>=1.2
|
||||
# MarkItDown(MIT)
|
||||
markitdown>=0.1.0
|
||||
# MarkItDown(MIT)—— 含 docx/pdf 支持
|
||||
markitdown[docx,pdf]>=0.1.0
|
||||
# PDF fallback: PyMuPDF(AGPL-3.0)
|
||||
# TODO: 商品化前替换为 pypdfium2(Apache-2.0/BSD),见 docs/technical-review.md R3
|
||||
PyMuPDF>=1.24.0
|
||||
|
||||
Reference in New Issue
Block a user