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 6 additions and 2 deletions
Showing only changes of commit 28553aba15 - 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) os.makedirs(UPLOAD_DIR, exist_ok=True)
ALLOWED_EXT = {".md", ".txt", ".pdf", ".doc", ".docx", ".xlsx"} ALLOWED_EXT = {".md", ".txt", ".pdf", ".doc", ".docx", ".xlsx"}
MAX_UPLOAD_BYTES = 10 * 1024 * 1024 MAX_UPLOAD_BYTES = 20 * 1024 * 1024
class QAIn(BaseModel): class QAIn(BaseModel):
@@ -82,7 +82,7 @@ async def upload_doc(avatar_id: str, file: UploadFile = File(...), authorization
path = os.path.join(avatar_dir, stored) path = os.path.join(avatar_dir, stored)
content = await file.read() content = await file.read()
if len(content) > MAX_UPLOAD_BYTES: if len(content) > MAX_UPLOAD_BYTES:
return fail("文件不能超过 10MB", code=400) return fail("文件不能超过 20MB", code=400)
with open(path, "wb") as f: with open(path, "wb") as f:
f.write(content) f.write(content)
doc = KnowledgeDoc( doc = KnowledgeDoc(
+4
View File
@@ -23,6 +23,10 @@ http {
root /usr/share/nginx/html; root /usr/share/nginx/html;
index index.html; index index.html;
# Keep the application gateway aligned with the production edge gateway.
# Without this Nginx rejects ordinary PDF uploads with HTTP 413 before
# FastAPI can return its user-facing file-size validation message.
client_max_body_size 20m;
# SPA 兜底(hash 路由下深链接也可正常加载) # SPA 兜底(hash 路由下深链接也可正常加载)
location / { location / {