acumplid commited on
Commit
5688ad2
1 Parent(s): 88b2c32

Implement detecting max input characters

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -8,7 +8,7 @@ from meteocat_appv4 import generate
8
 
9
  load_dotenv()
10
 
11
-
12
  SHOW_MODEL_PARAMETERS_IN_UI = os.environ.get("SHOW_MODEL_PARAMETERS_IN_UI", default=True)
13
  MAX_NEW_TOKENS = int(os.environ.get("MAX_NEW_TOKENS", default=200))
14
 
@@ -30,14 +30,9 @@ def submit_input(input_, repetition_penalty, temperature):
30
 
31
 
32
  def change_interactive(text):
33
- input_state = text
34
- intput_length = len(input_state.strip())
35
- if intput_length > MAX_NEW_TOKENS :
36
- return gr.update(interactive = True), gr.update(interactive = False)
37
- elif input_state.strip() != "":
38
- return gr.update(interactive = True), gr.update(interactive = True)
39
- else:
40
- return gr.update(interactive = False), gr.update(interactive = False)
41
 
42
  def clean():
43
  return (
 
8
 
9
  load_dotenv()
10
 
11
+ MAX_INPUT_CHARACTERS= int(os.environ.get("MAX_INPUT_CHARACTERS", default=200))
12
  SHOW_MODEL_PARAMETERS_IN_UI = os.environ.get("SHOW_MODEL_PARAMETERS_IN_UI", default=True)
13
  MAX_NEW_TOKENS = int(os.environ.get("MAX_NEW_TOKENS", default=200))
14
 
 
30
 
31
 
32
  def change_interactive(text):
33
+ if len(text.strip()) > MAX_INPUT_CHARACTERS:
34
+ return gr.update(interactive = True), gr.update(interactive = False)
35
+ return gr.update(interactive = True), gr.update(interactive = True)
 
 
 
 
 
36
 
37
  def clean():
38
  return (