Erik commited on
Commit
af81e0d
·
verified ·
1 Parent(s): 9a8c112

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -6
app.py CHANGED
@@ -4,19 +4,32 @@ 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 !
11
  @tool
12
- def my_cutom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -34,6 +47,8 @@ def get_current_time_in_timezone(timezone: str) -> str:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
 
 
 
37
  final_answer = FinalAnswerTool()
38
  model = HfApiModel(
39
  max_tokens=2096,
@@ -51,7 +66,7 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer], ## add your tools here (don't remove final answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from termcolor import colored
8
 
9
  from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
+ def compare_degrees(current_weather:float, optimal_fermentation_degrees:float)-> str: #it's import to specify the return type
14
  #Keep this format for the description / args / args description but feel free to modify the tool
15
+ """A tool that compares the actual weathers degrees and the optimal fermentation degrees of a product in order to flag with an alert!!
16
  Args:
17
+ current_weather: A float representing the degrees of current weather.
18
+ optimal_fermentation_degrees: A float representing the degrees that should be the fermentation process.
19
  """
20
+ try:
21
+ dif_degrees = current_weather-optimal_fermentation_degrees
22
+ if abs(dif_degrees) >= 1.5:
23
+ if dif_degrees<0:
24
+ return colored(f"RED LIGHT - the difference degrees between optimal and current weather are {dif_degrees}ºC - YOU SHOULD INCREASE THE HEATER BY {dif_degrees}ºC!", 'red')
25
+ else:
26
+ return colored(f"RED LIGHT - the difference degrees between optimal and current weather are {dif_degrees}ºC - YOU SHOULD DECREASE THE HEATER BY {dif_degrees}ºC!", 'red')
27
+ else:
28
+ return colored(f"GREEN LIGHT - the difference degrees between optimal and current weather are {dif_degrees} - which is in range!", 'green')
29
+ return str(degrees_observation)
30
+ except Exception as e:
31
+ return colored(f"Error fetching {str(current_weather)} and {str(optimal_fermentation_degrees)}.", 'yellow')
32
+
33
 
34
  @tool
35
  def get_current_time_in_timezone(timezone: str) -> str:
 
47
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
48
 
49
 
50
+ search_info_tool = DuckDuckGoSearchTool()
51
+
52
  final_answer = FinalAnswerTool()
53
  model = HfApiModel(
54
  max_tokens=2096,
 
66
 
67
  agent = CodeAgent(
68
  model=model,
69
+ tools=[search_info_tool, compare_degrees, image_generation_tool, final_answer], ## add your tools here (don't remove final answer)
70
  max_steps=6,
71
  verbosity_level=1,
72
  grammar=None,