fix: 修复文件上传API中的jsonl文件类型不支持的问题;fix: #300
- 添加了 allow_jsonl的参数在Graph的接口处
This commit is contained in:
parent
c0e4f6f8e7
commit
2f9b134242
@ -565,7 +565,10 @@ async def get_knowledge_base_query_params(db_id: str, current_user: User = Depen
|
|||||||
|
|
||||||
@knowledge.post("/files/upload")
|
@knowledge.post("/files/upload")
|
||||||
async def upload_file(
|
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:
|
if not file.filename:
|
||||||
@ -573,8 +576,12 @@ async def upload_file(
|
|||||||
|
|
||||||
logger.debug(f"Received upload file with filename: {file.filename}")
|
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}")
|
raise HTTPException(status_code=400, detail=f"Unsupported file type: {ext}")
|
||||||
|
|
||||||
# 根据db_id获取上传路径,如果db_id为None则使用默认路径
|
# 根据db_id获取上传路径,如果db_id为None则使用默认路径
|
||||||
|
|||||||
@ -95,7 +95,8 @@
|
|||||||
name="file"
|
name="file"
|
||||||
:fileList="fileList"
|
:fileList="fileList"
|
||||||
:max-count="1"
|
:max-count="1"
|
||||||
action="/api/knowledge/files/upload"
|
accept=".jsonl"
|
||||||
|
action="/api/knowledge/files/upload?allow_jsonl=true"
|
||||||
:headers="getAuthHeaders()"
|
:headers="getAuthHeaders()"
|
||||||
@change="handleFileUpload"
|
@change="handleFileUpload"
|
||||||
@drop="handleDrop"
|
@drop="handleDrop"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user