fix: 修复文件上传API中的jsonl文件类型不支持的问题;fix: #300

- 添加了 allow_jsonl的参数在Graph的接口处
This commit is contained in:
Wenjie Zhang 2025-10-17 12:15:40 +08:00
parent c0e4f6f8e7
commit 2f9b134242
2 changed files with 12 additions and 4 deletions

View File

@ -565,7 +565,10 @@ async def get_knowledge_base_query_params(db_id: str, current_user: User = Depen
@knowledge.post("/files/upload")
async def upload_file(
file: UploadFile = File(...), db_id: str | None = Query(None), current_user: User = Depends(get_admin_user)
file: UploadFile = File(...),
db_id: str | None = Query(None),
allow_jsonl: bool = Query(False),
current_user: User = Depends(get_admin_user),
):
"""上传文件"""
if not file.filename:
@ -573,8 +576,12 @@ async def upload_file(
logger.debug(f"Received upload file with filename: {file.filename}")
if not is_supported_file_extension(file.filename):
ext = os.path.splitext(file.filename)[1].lower()
ext = os.path.splitext(file.filename)[1].lower()
if ext == ".jsonl":
if allow_jsonl is not True or db_id is not None:
raise HTTPException(status_code=400, detail=f"Unsupported file type: {ext}")
elif not is_supported_file_extension(file.filename):
raise HTTPException(status_code=400, detail=f"Unsupported file type: {ext}")
# 根据db_id获取上传路径如果db_id为None则使用默认路径

View File

@ -95,7 +95,8 @@
name="file"
:fileList="fileList"
:max-count="1"
action="/api/knowledge/files/upload"
accept=".jsonl"
action="/api/knowledge/files/upload?allow_jsonl=true"
:headers="getAuthHeaders()"
@change="handleFileUpload"
@drop="handleDrop"