feat(backend): 文件处理和语义分割 API 更新
- chunks API: 支持语义分割模式和 embedding 配置 - files API: 文件异步处理优化 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@ from app.core.crud import CRUDBase
|
|||||||
from app.core.logging import log_success, log_failure
|
from app.core.logging import log_success, log_failure
|
||||||
from app.models.models import Chunk, File
|
from app.models.models import Chunk, File
|
||||||
from app.schemas.chunk import ChunkResponse
|
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 app.services.text_splitter.splitter import get_splitter
|
||||||
from markitdown import MarkItDown
|
from markitdown import MarkItDown
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ async def list_chunks(
|
|||||||
limit=page_size,
|
limit=page_size,
|
||||||
filters=filters,
|
filters=filters,
|
||||||
order_by="created_at",
|
order_by="created_at",
|
||||||
descending=True
|
descending=False
|
||||||
)
|
)
|
||||||
|
|
||||||
chunk_responses = [ChunkResponse.model_validate(c) for c in chunks]
|
chunk_responses = [ChunkResponse.model_validate(c) for c in chunks]
|
||||||
@@ -239,7 +239,7 @@ async def get_chunk(
|
|||||||
async def update_chunk(
|
async def update_chunk(
|
||||||
project_id: UUID,
|
project_id: UUID,
|
||||||
chunk_id: UUID,
|
chunk_id: UUID,
|
||||||
chunk: ChunkCreateSchema,
|
chunk: ChunkUpdateSchema,
|
||||||
db: AsyncSession = Depends(get_db)
|
db: AsyncSession = Depends(get_db)
|
||||||
):
|
):
|
||||||
"""Update chunk"""
|
"""Update chunk"""
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ async def upload_file(
|
|||||||
# txt, md 等直接读取
|
# txt, md 等直接读取
|
||||||
text_content = file_path_obj.read_text(encoding='utf-8')
|
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_dir = get_project_ready_dir(str(project_id_val))
|
||||||
ready_filename = f"{file_id}.md"
|
ready_filename = f"{file_id}.md"
|
||||||
ready_path = ready_dir / ready_filename
|
ready_path = ready_dir / ready_filename
|
||||||
|
|||||||
Reference in New Issue
Block a user