From 07a901043ac73f49b118d4840d9ce7c5653acb7e Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Mon, 2 Feb 2026 15:39:06 +0800 Subject: [PATCH] =?UTF-8?q?refactor(annotation):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E5=86=85=E5=AE=B9=E8=8E=B7=E5=8F=96=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除了 fetch_text_content_via_download_api 导入 - 移除了 TEXT 类型数据集的文本内容获取逻辑 - 删除了 _append_annotation_to_content 方法实现 - 简化了知识同步服务的内容处理流程 --- .../annotation/service/knowledge_sync.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/runtime/datamate-python/app/module/annotation/service/knowledge_sync.py b/runtime/datamate-python/app/module/annotation/service/knowledge_sync.py index 850a470..ae345ea 100644 --- a/runtime/datamate-python/app/module/annotation/service/knowledge_sync.py +++ b/runtime/datamate-python/app/module/annotation/service/knowledge_sync.py @@ -11,7 +11,6 @@ from sqlalchemy.ext.asyncio import AsyncSession from app.core.config import settings from app.core.logging import get_logger from app.db.models import Dataset, DatasetFiles, LabelingProject -from app.module.annotation.service.text_fetcher import fetch_text_content_via_download_api logger = get_logger(__name__) @@ -254,16 +253,6 @@ class KnowledgeSyncService: content_type = "MARKDOWN" content = annotation_json - if dataset_type == "TEXT": - try: - content = await fetch_text_content_via_download_api( - project.dataset_id, - str(file_record.id), - ) - content = self._append_annotation_to_content(content, annotation_json, content_type) - except Exception as exc: - logger.warning("读取文本失败,改为仅存标注JSON:%s", exc) - content = annotation_json payload: Dict[str, Any] = { "title": title, @@ -294,13 +283,6 @@ class KnowledgeSyncService: extension = file_type return extension.lower() in {"md", "markdown"} - def _append_annotation_to_content(self, content: str, annotation_json: str, content_type: str) -> str: - if content_type == "MARKDOWN": - return ( - f"{content}\n\n---\n\n## 标注结果\n\n```json\n" - f"{annotation_json}\n```") - return f"{content}\n\n---\n\n标注结果(JSON):\n{annotation_json}" - def _strip_extension(self, file_name: str) -> str: if not file_name: return ""