freemt commited on
Commit
238bf96
·
1 Parent(s): fc353d3

Update using blocks

Browse files
Files changed (1) hide show
  1. app_blocks.py +11 -1
app_blocks.py CHANGED
@@ -24,6 +24,12 @@ def opusmt(
24
  except Exception:
25
  to_lang = "auto"
26
 
 
 
 
 
 
 
27
  logger.debug("%s, %s, %s", text[:100], from_lang, to_lang)
28
  if to_lang in ["auto"]:
29
  if from_lang in ["zh"]:
@@ -42,7 +48,11 @@ def opusmt(
42
  )
43
  except Exception as e:
44
  logger.error(e)
45
- res = f"errors: {e}"
 
 
 
 
46
  return res
47
 
48
 
 
24
  except Exception:
25
  to_lang = "auto"
26
 
27
+ # if empty, set to auto
28
+ if not from_lang:
29
+ from_lang = "auto"
30
+ if not to_lang:
31
+ to_lang = "auto"
32
+
33
  logger.debug("%s, %s, %s", text[:100], from_lang, to_lang)
34
  if to_lang in ["auto"]:
35
  if from_lang in ["zh"]:
 
48
  )
49
  except Exception as e:
50
  logger.error(e)
51
+ if "Helsinki" in str(e):
52
+ res = "errors occur"
53
+ else:
54
+ res = f"errors: {e}"
55
+
56
  return res
57
 
58