From a280b4f014885d603df5c88a7da2730b627faa00 Mon Sep 17 00:00:00 2001 From: Developer Date: Thu, 19 Mar 2026 10:11:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(backend):=20=E6=96=87=E4=BB=B6=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=92=8C=E8=AF=AD=E4=B9=89=E5=88=86=E5=89=B2=20API=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - chunks API: 支持语义分割模式和 embedding 配置 - files API: 文件异步处理优化 Co-Authored-By: Claude Opus 4.6 --- backend/app/api/v1/chunks/__init__.py | 6 +++--- backend/app/api/v1/files/__init__.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/app/api/v1/chunks/__init__.py b/backend/app/api/v1/chunks/__init__.py index 2c1986d..582ed87 100644 --- a/backend/app/api/v1/chunks/__init__.py +++ b/backend/app/api/v1/chunks/__init__.py @@ -17,7 +17,7 @@ from app.core.crud import CRUDBase from app.core.logging import log_success, log_failure from app.models.models import Chunk, File from app.schemas.chunk import ChunkResponse -from app.schemas.chunk import ChunkCreateSchema +from app.schemas.chunk import ChunkCreateSchema, ChunkUpdateSchema from app.services.text_splitter.splitter import get_splitter from markitdown import MarkItDown @@ -209,7 +209,7 @@ async def list_chunks( limit=page_size, filters=filters, order_by="created_at", - descending=True + descending=False ) chunk_responses = [ChunkResponse.model_validate(c) for c in chunks] @@ -239,7 +239,7 @@ async def get_chunk( async def update_chunk( project_id: UUID, chunk_id: UUID, - chunk: ChunkCreateSchema, + chunk: ChunkUpdateSchema, db: AsyncSession = Depends(get_db) ): """Update chunk""" diff --git a/backend/app/api/v1/files/__init__.py b/backend/app/api/v1/files/__init__.py index d8aa93b..3791243 100644 --- a/backend/app/api/v1/files/__init__.py +++ b/backend/app/api/v1/files/__init__.py @@ -158,7 +158,7 @@ async def upload_file( # txt, md 等直接读取 text_content = file_path_obj.read_text(encoding='utf-8') - # 保存到 ready 目录 + # 保存到 ready 目录,使用 {uuid}.md 格式 ready_dir = get_project_ready_dir(str(project_id_val)) ready_filename = f"{file_id}.md" ready_path = ready_dir / ready_filename