hanyullai commited on
Commit
6a7022c
1 Parent(s): 38e35dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -12,6 +12,9 @@ def predict(text, seed, out_seq_length, min_gen_length, sampling_strategy,
12
  temperature, topk, topp):
13
  global APIKEY
14
  global APISECRET
 
 
 
15
 
16
  url = 'https://wudao.aminer.cn/os/api/api/v2/completions_130B'
17
 
@@ -36,14 +39,12 @@ def predict(text, seed, out_seq_length, min_gen_length, sampling_strategy,
36
  'Content-Type': 'application/json'
37
  }
38
 
39
- response = requests.request("POST", url, headers=headers, data=payload)
40
-
41
- print(response.json())
42
 
43
- if response.json()['status'] == 1:
44
  return 'Please give smaller text than max_tokens or give larger max_tokens.'
45
 
46
- answer = response.json()['result']['output']['raw']
47
  if isinstance(answer, list):
48
  answer = answer[0]
49
 
 
12
  temperature, topk, topp):
13
  global APIKEY
14
  global APISECRET
15
+
16
+ if text == '':
17
+ return 'Input should not be empty!'
18
 
19
  url = 'https://wudao.aminer.cn/os/api/api/v2/completions_130B'
20
 
 
39
  'Content-Type': 'application/json'
40
  }
41
 
42
+ response = requests.request("POST", url, headers=headers, data=payload).json()
 
 
43
 
44
+ if response['status'] == 1:
45
  return 'Please give smaller text than max_tokens or give larger max_tokens.'
46
 
47
+ answer = response['result']['output']['raw']
48
  if isinstance(answer, list):
49
  answer = answer[0]
50