fix(avatar): 异步知识库索引并修复大文件上传 #16

Merged
stefanfeng merged 3 commits from codex/avatar-knowledge-async-20260904 into main 2026-09-04 15:59:12 +08:00
2 changed files with 3 additions and 3 deletions
Showing only changes of commit 08c58fe0e6 - Show all commits
@@ -17,7 +17,7 @@ UPLOAD_DIR = os.path.abspath(os.getenv("UPLOAD_DIR", os.path.join(BASE_DIR, "upl
os.makedirs(UPLOAD_DIR, exist_ok=True)
ALLOWED_EXT = {".md", ".txt", ".pdf", ".doc", ".docx", ".xlsx"}
MAX_UPLOAD_BYTES = 100 * 1024 * 1024
MAX_UPLOAD_BYTES = 50 * 1024 * 1024
UPLOAD_CHUNK_BYTES = 1024 * 1024
@@ -88,7 +88,7 @@ async def upload_doc(avatar_id: str, file: UploadFile = File(...), authorization
while chunk := await file.read(UPLOAD_CHUNK_BYTES):
file_size += len(chunk)
if file_size > MAX_UPLOAD_BYTES:
raise ValueError("文件不能超过 100MB")
raise ValueError("文件不能超过 50MB")
f.write(chunk)
except ValueError as exc:
if os.path.exists(path):
@@ -82,7 +82,7 @@ def test_upload_rejects_oversize_file_before_queuing_indexing(
payload = response.json()
assert payload["code"] == 400
assert payload["message"] == "文件不能超过 100MB"
assert payload["message"] == "文件不能超过 50MB"
enqueue.assert_not_called()
assert not list((tmp_path / context["avatar"].id).glob("*"))