phenomenon1981 commited on
Commit
cc86085
1 Parent(s): 7ad90c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -10
app.py CHANGED
@@ -19,6 +19,7 @@ def restart_script_periodically():
19
  restart_thread = Thread(target=restart_script_periodically, daemon=True)
20
  restart_thread.start()
21
 
 
22
 
23
  def add_random_noise(prompt, noise_level=0.07):
24
  # Get the percentage of characters to add as noise
@@ -37,51 +38,65 @@ def add_random_noise(prompt, noise_level=0.07):
37
 
38
  def send_it1(inputs, noise_level, proc1=proc1):
39
  prompt_with_noise = add_random_noise(inputs, noise_level)
40
- time.sleep(2)
 
 
41
  output1 = proc1(prompt_with_noise)
42
  return output1
43
 
44
  def send_it2(inputs, noise_level, proc1=proc1):
45
  prompt_with_noise = add_random_noise(inputs, noise_level)
46
- time.sleep(2)
 
 
47
  output2 = proc1(prompt_with_noise)
48
  return output2
49
 
50
  def send_it3(inputs, noise_level, proc1=proc1):
51
  prompt_with_noise = add_random_noise(inputs, noise_level)
52
- time.sleep(2)
 
 
53
  output3 = proc1(prompt_with_noise)
54
  return output3
55
 
56
  def send_it4(inputs, noise_level, proc1=proc1):
57
  prompt_with_noise = add_random_noise(inputs, noise_level)
58
- time.sleep(2)
 
 
59
  output4 = proc1(prompt_with_noise)
60
  return output4
61
 
62
  def send_it5(inputs, noise_level, proc1=proc1):
63
  prompt_with_noise = add_random_noise(inputs, noise_level)
64
- time.sleep(2)
 
 
65
  output5 = proc1(prompt_with_noise)
66
  return output5
67
 
68
  def send_it6(inputs, noise_level, proc1=proc1):
69
  prompt_with_noise = add_random_noise(inputs, noise_level)
70
- time.sleep(2)
 
 
71
  output6 = proc1(prompt_with_noise)
72
- time.sleep(5)
73
  return output6
74
 
75
  def send_it7(inputs, noise_level, proc1=proc1):
76
  prompt_with_noise = add_random_noise(inputs, noise_level)
77
- time.sleep(2)
 
 
78
  output7 = proc1(prompt_with_noise)
79
  return output7
80
-
81
 
82
  def send_it8(inputs, noise_level, proc1=proc1):
83
  prompt_with_noise = add_random_noise(inputs, noise_level)
84
- time.sleep(2)
 
 
85
  output8 = proc1(prompt_with_noise)
86
  return output8
87
 
 
19
  restart_thread = Thread(target=restart_script_periodically, daemon=True)
20
  restart_thread.start()
21
 
22
+ queue_threshold = 100
23
 
24
  def add_random_noise(prompt, noise_level=0.07):
25
  # Get the percentage of characters to add as noise
 
38
 
39
  def send_it1(inputs, noise_level, proc1=proc1):
40
  prompt_with_noise = add_random_noise(inputs, noise_level)
41
+ while queue.qsize() >= queue_threshold:
42
+ time.sleep(2)
43
+ queue.put(prompt_with_noise)
44
  output1 = proc1(prompt_with_noise)
45
  return output1
46
 
47
  def send_it2(inputs, noise_level, proc1=proc1):
48
  prompt_with_noise = add_random_noise(inputs, noise_level)
49
+ while queue.qsize() >= queue_threshold:
50
+ time.sleep(2)
51
+ queue.put(prompt_with_noise)
52
  output2 = proc1(prompt_with_noise)
53
  return output2
54
 
55
  def send_it3(inputs, noise_level, proc1=proc1):
56
  prompt_with_noise = add_random_noise(inputs, noise_level)
57
+ while queue.qsize() >= queue_threshold:
58
+ time.sleep(2)
59
+ queue.put(prompt_with_noise)
60
  output3 = proc1(prompt_with_noise)
61
  return output3
62
 
63
  def send_it4(inputs, noise_level, proc1=proc1):
64
  prompt_with_noise = add_random_noise(inputs, noise_level)
65
+ while queue.qsize() >= queue_threshold:
66
+ time.sleep(2)
67
+ queue.put(prompt_with_noise)
68
  output4 = proc1(prompt_with_noise)
69
  return output4
70
 
71
  def send_it5(inputs, noise_level, proc1=proc1):
72
  prompt_with_noise = add_random_noise(inputs, noise_level)
73
+ while queue.qsize() >= queue_threshold:
74
+ time.sleep(2)
75
+ queue.put(prompt_with_noise)
76
  output5 = proc1(prompt_with_noise)
77
  return output5
78
 
79
  def send_it6(inputs, noise_level, proc1=proc1):
80
  prompt_with_noise = add_random_noise(inputs, noise_level)
81
+ while queue.qsize() >= queue_threshold:
82
+ time.sleep(2)
83
+ queue.put(prompt_with_noise)
84
  output6 = proc1(prompt_with_noise)
 
85
  return output6
86
 
87
  def send_it7(inputs, noise_level, proc1=proc1):
88
  prompt_with_noise = add_random_noise(inputs, noise_level)
89
+ while queue.qsize() >= queue_threshold:
90
+ time.sleep(2)
91
+ queue.put(prompt_with_noise)
92
  output7 = proc1(prompt_with_noise)
93
  return output7
 
94
 
95
  def send_it8(inputs, noise_level, proc1=proc1):
96
  prompt_with_noise = add_random_noise(inputs, noise_level)
97
+ while queue.qsize() >= queue_threshold:
98
+ time.sleep(2)
99
+ queue.put(prompt_with_noise)
100
  output8 = proc1(prompt_with_noise)
101
  return output8
102