Update server_fastapi.py. Avoid loading the model repeatedly. Add logger (#145)

* Update server_fastapi.py. Avoid loading the model repeatedly. Add loguru logger.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Sora
2023-11-03 13:09:58 +08:00
committed by GitHub
parent 7737079323
commit 25ea864b56
3 changed files with 92 additions and 55 deletions

View File

@@ -20,7 +20,7 @@ def translate(Sentence: str, to_Language: str = "jp", from_Language: str = ""):
appid = config.translate_config.app_key
key = config.translate_config.secret_key
if appid == "" or key == "":
return "开发者config.yml中配置app_key与secret_key"
return "请开发者config.yml中配置app_key与secret_key"
url = "https://fanyi-api.baidu.com/api/trans/vip/translate"
texts = Sentence.split("\n")
outTexts = []