anugrahap commited on
Commit
027f46b
·
1 Parent(s): 7173081

Revise the error of adding new error message for empty temperature sampling and repetition penalty (3)

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -27,7 +27,7 @@ def single_generation(text,min_length,max_length,temperature,top_k,top_p,num_bea
27
  error_numbeams_type=TypeError(f"ERROR: number of beams must be an integer not {type(num_beams)}")
28
  error_topk_type=TypeError(f"ERROR: top k must be an integer not {type(top_k)}")
29
  error_minmax_type=TypeError(f"ERROR: min length and max length must be an integer not {type(min_length)} and {type(max_length)}")
30
- error_empty_temprep=TypeError("ERROR: temperature and repetition penalty cannot be zero!")
31
  error_empty_text=ValueError("ERROR: Input Text cannot be empty!")
32
  error_unknown=TypeError("Unknown Error.")
33
 
@@ -38,7 +38,7 @@ def single_generation(text,min_length,max_length,temperature,top_k,top_p,num_bea
38
  if min_length <= max_length:
39
  if temperature > 0:
40
  if repetition_penalty >= 1:
41
- if temperature and repetition_penalty !='':
42
  result = generator(text,
43
  min_length=min_length,
44
  max_length=max_length,
@@ -51,7 +51,7 @@ def single_generation(text,min_length,max_length,temperature,top_k,top_p,num_bea
51
  no_repeat_ngram_size=2,
52
  num_return_sequences=1)
53
  return result[0]["generated_text"]
54
- elif temperature and repetition_penalty =='':
55
  return error_empty_temprep
56
  elif repetition_penalty < 1:
57
  return error_rep
 
27
  error_numbeams_type=TypeError(f"ERROR: number of beams must be an integer not {type(num_beams)}")
28
  error_topk_type=TypeError(f"ERROR: top k must be an integer not {type(top_k)}")
29
  error_minmax_type=TypeError(f"ERROR: min length and max length must be an integer not {type(min_length)} and {type(max_length)}")
30
+ error_empty_temprep=TypeError("ERROR: temperature and repetition penalty cannot be empty!")
31
  error_empty_text=ValueError("ERROR: Input Text cannot be empty!")
32
  error_unknown=TypeError("Unknown Error.")
33
 
 
38
  if min_length <= max_length:
39
  if temperature > 0:
40
  if repetition_penalty >= 1:
41
+ if temperature and repetition_penalty is not None:
42
  result = generator(text,
43
  min_length=min_length,
44
  max_length=max_length,
 
51
  no_repeat_ngram_size=2,
52
  num_return_sequences=1)
53
  return result[0]["generated_text"]
54
+ elif temperature and repetition_penalty is None:
55
  return error_empty_temprep
56
  elif repetition_penalty < 1:
57
  return error_rep