mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-10 08:38:28 +00:00
fix: [language] catch libretranslate exception
This commit is contained in:
parent
aa56e71631
commit
4c1d058e6d
1 changed files with 5 additions and 2 deletions
|
@ -349,9 +349,12 @@ class LanguagesDetector:
|
||||||
try:
|
try:
|
||||||
# [{"confidence": 0.6, "language": "en"}]
|
# [{"confidence": 0.6, "language": "en"}]
|
||||||
resp = self.lt.detect(content)
|
resp = self.lt.detect(content)
|
||||||
except: # TODO ERROR MESSAGE
|
except Exception as e: # TODO ERROR MESSAGE
|
||||||
resp = []
|
raise Exception(f'libretranslate error: {e}')
|
||||||
|
# resp = []
|
||||||
if resp:
|
if resp:
|
||||||
|
if isinstance(resp, dict):
|
||||||
|
raise Exception(f'libretranslate error {resp}')
|
||||||
for language in resp:
|
for language in resp:
|
||||||
if language.confidence >= self.min_probability:
|
if language.confidence >= self.min_probability:
|
||||||
languages.append(language)
|
languages.append(language)
|
||||||
|
|
Loading…
Reference in a new issue