优化添加文件时,前后端的报错
This commit is contained in:
parent
14dfe60333
commit
aebad0ae5d
@ -171,11 +171,15 @@ async def get_graph_nodes(kgdb_name: str, num: int):
|
||||
@data.post("/graph/add-by-jsonl")
|
||||
async def add_graph_entity(file_path: str = Body(...), kgdb_name: Optional[str] = Body(None)):
|
||||
if not config.enable_knowledge_graph:
|
||||
raise HTTPException(status_code=400, detail="Knowledge graph is not enabled")
|
||||
return {"message": "知识图谱未启用", "status": "failed"}
|
||||
|
||||
if not file_path.endswith('.jsonl'):
|
||||
raise HTTPException(status_code=400, detail="file_path must be a jsonl file")
|
||||
return {"message": "文件格式错误,请上传jsonl文件", "status": "failed"}
|
||||
|
||||
await graph_base.jsonl_file_add_entity(file_path, kgdb_name)
|
||||
return {"message": "Entity successfully added"}
|
||||
try:
|
||||
await graph_base.jsonl_file_add_entity(file_path, kgdb_name)
|
||||
return {"message": "实体添加成功", "status": "success"}
|
||||
except Exception as e:
|
||||
logger.error(f"添加实体失败: {e}, {traceback.format_exc()}")
|
||||
return {"message": f"添加实体失败: {e}", "status": "failed"}
|
||||
|
||||
|
||||
@ -198,10 +198,15 @@ const addDocumentByFile = () => {
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then((data) => {
|
||||
message.success(data.message);
|
||||
state.showModal = false;
|
||||
if (data.status === 'success') {
|
||||
message.success(data.message);
|
||||
state.showModal = false;
|
||||
} else {
|
||||
throw new Error(data.message);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
message.error(error.message);
|
||||
})
|
||||
.finally(() => state.precessing = false)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user