Skip to content

Commit 2f9b134

Browse files
committed
fix: 修复文件上传API中的jsonl文件类型不支持的问题;fix: #300
- 添加了 allow_jsonl的参数在Graph的接口处
1 parent c0e4f6f commit 2f9b134

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

server/routers/knowledge_router.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,16 +565,23 @@ async def get_knowledge_base_query_params(db_id: str, current_user: User = Depen
565565

566566
@knowledge.post("/files/upload")
567567
async def upload_file(
568-
file: UploadFile = File(...), db_id: str | None = Query(None), current_user: User = Depends(get_admin_user)
568+
file: UploadFile = File(...),
569+
db_id: str | None = Query(None),
570+
allow_jsonl: bool = Query(False),
571+
current_user: User = Depends(get_admin_user),
569572
):
570573
"""上传文件"""
571574
if not file.filename:
572575
raise HTTPException(status_code=400, detail="No selected file")
573576

574577
logger.debug(f"Received upload file with filename: {file.filename}")
575578

576-
if not is_supported_file_extension(file.filename):
577-
ext = os.path.splitext(file.filename)[1].lower()
579+
ext = os.path.splitext(file.filename)[1].lower()
580+
581+
if ext == ".jsonl":
582+
if allow_jsonl is not True or db_id is not None:
583+
raise HTTPException(status_code=400, detail=f"Unsupported file type: {ext}")
584+
elif not is_supported_file_extension(file.filename):
578585
raise HTTPException(status_code=400, detail=f"Unsupported file type: {ext}")
579586

580587
# 根据db_id获取上传路径,如果db_id为None则使用默认路径

web/src/views/GraphView.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@
9595
name="file"
9696
:fileList="fileList"
9797
:max-count="1"
98-
action="/api/knowledge/files/upload"
98+
accept=".jsonl"
99+
action="/api/knowledge/files/upload?allow_jsonl=true"
99100
:headers="getAuthHeaders()"
100101
@change="handleFileUpload"
101102
@drop="handleDrop"

0 commit comments

Comments
 (0)