hanyullai commited on
Commit
5ee2bac
1 Parent(s): 1a4ddbc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -39,7 +39,10 @@ def predict(text, seed, out_seq_length, min_gen_length, sampling_strategy,
39
  'Content-Type': 'application/json'
40
  }
41
 
42
- response = requests.request("POST", url, headers=headers, data=payload, timeout=(20, 100)).json()
 
 
 
43
 
44
  if response['status'] == 1:
45
  return 'Please give smaller text than max_tokens or give larger max_tokens.'
 
39
  'Content-Type': 'application/json'
40
  }
41
 
42
+ try:
43
+ response = requests.request("POST", url, headers=headers, data=payload, timeout=(20, 100)).json()
44
+ except Exception as e:
45
+ print('Timeout! Please wait a few minutes and retry')
46
 
47
  if response['status'] == 1:
48
  return 'Please give smaller text than max_tokens or give larger max_tokens.'