feat(backend): 文件处理和语义分割 API 更新

- chunks API: 支持语义分割模式和 embedding 配置
- files API: 文件异步处理优化

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Developer
2026-03-19 10:11:59 +08:00
parent 135f75e6be
commit a280b4f014
2 changed files with 4 additions and 4 deletions

View File

@@ -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"""

View File

@@ -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