aliman80 commited on
Commit
84787e4
·
verified ·
1 Parent(s): c06850c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -2
app.py CHANGED
@@ -4,7 +4,7 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
-
8
  from Gradio_UI import GradioUI
9
 
10
  # # Below is an example of a tool that does nothing. Amaze us with your creativity !
@@ -18,6 +18,31 @@ from Gradio_UI import GradioUI
18
  # """
19
  # return "What magic will you build ?"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  @tool
23
  def alarm_comparator_degrees(weather_average_degrees:float, optimal_fermentation_degrees:float)-> str: #it's import to specify the return type
@@ -138,7 +163,8 @@ agent = CodeAgent(
138
  get_current_time_in_timezone, # Your custom time tool
139
  daily_gold_oil_updates,
140
  daily_weather_search,
141
- alarm_comparator_degrees
 
142
  ],
143
  max_steps=6,
144
  verbosity_level=1,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from IPython.display import Audio
8
  from Gradio_UI import GradioUI
9
 
10
  # # Below is an example of a tool that does nothing. Amaze us with your creativity !
 
18
  # """
19
  # return "What magic will you build ?"
20
 
21
+ leak_warning_img = "leak_warning.png"
22
+ safe_status_img = "safe_status.png"
23
+ alarm_sound_file = "alarm_sound.wav"
24
+
25
+ @tool
26
+ def leakage_alarm_checker(current_leakage_level: float, safe_threshold: float):
27
+ """
28
+ Checks if the leakage level has exceeded a safe threshold and triggers an alarm.
29
+
30
+ Args:
31
+ current_leakage_level: The measured leakage level.
32
+ safe_threshold: The maximum allowable leakage before triggering an alert.
33
+ """
34
+ try:
35
+ dif_leakage = current_leakage_level - safe_threshold
36
+ if dif_leakage > 0:
37
+ alert_message = f"🚨 ALERT: Leakage level is {current_leakage_level} (Threshold: {safe_threshold}). IMMEDIATE ACTION REQUIRED!"
38
+ warning_image = Image.open(leak_warning_img)
39
+ return alert_message, warning_image, Audio(alarm_sound_file, autoplay=True)
40
+ else:
41
+ alert_message = f"✅ SAFE: Leakage level is {current_leakage_level}, within the safe limit of {safe_threshold}. System is operating normally."
42
+ safe_image = Image.open(safe_status_img)
43
+ return alert_message, safe_image, None
44
+ except Exception as e:
45
+ return f"Error processing leakage levels: {str(e)}", None, None
46
 
47
  @tool
48
  def alarm_comparator_degrees(weather_average_degrees:float, optimal_fermentation_degrees:float)-> str: #it's import to specify the return type
 
163
  get_current_time_in_timezone, # Your custom time tool
164
  daily_gold_oil_updates,
165
  daily_weather_search,
166
+ alarm_comparator_degrees,
167
+ leakage_alarm_checker
168
  ],
169
  max_steps=6,
170
  verbosity_level=1,