Wind-xixi commited on
Commit
6dcfc9d
·
verified ·
1 Parent(s): bdb326c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -9,7 +9,7 @@ app = FastAPI()
9
 
10
  # 初始化 SentenceExtractor
11
  extractor = SentenceExtractor(
12
- eval_keywords_path="evaluation_keywords2.json",
13
  model_path="distilled_model.onnx"
14
  )
15
 
@@ -37,9 +37,12 @@ async def evaluate_file(file: UploadFile = File(...)):
37
  }
38
  for i, item in enumerate(result["scored_sentences"], 1):
39
  formatted_result["句子评分"].append({
40
- f"句子{i}": f"{item['sentence']} - {item['grade']}"
41
  })
42
 
 
 
 
43
  return JSONResponse(content=formatted_result)
44
 
45
  except Exception as e:
@@ -47,4 +50,6 @@ async def evaluate_file(file: UploadFile = File(...)):
47
 
48
  if __name__ == "__main__":
49
  port = int(os.getenv("PORT", 7860))
50
- uvicorn.run(app, host="0.0.0.0", port=port)
 
 
 
9
 
10
  # 初始化 SentenceExtractor
11
  extractor = SentenceExtractor(
12
+ eval_keywords_path="evaluation_keywords2.json", # 相对路径将被转换为绝对路径
13
  model_path="distilled_model.onnx"
14
  )
15
 
 
37
  }
38
  for i, item in enumerate(result["scored_sentences"], 1):
39
  formatted_result["句子评分"].append({
40
+ f"句子{i}": f"{item['sentence']} - {item['grade']} ({item.get('source','?')})"
41
  })
42
 
43
+ # 附加调试信息便于客户端确认
44
+ formatted_result["_debug"] = result.get("debug", {})
45
+
46
  return JSONResponse(content=formatted_result)
47
 
48
  except Exception as e:
 
50
 
51
  if __name__ == "__main__":
52
  port = int(os.getenv("PORT", 7860))
53
+ uvicorn.run(app, host="0.0.0.0", port=port)
54
+
55
+