Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,27 +4,35 @@ 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 compare_degrees(current_weather:float, optimal_fermentation_degrees:float)-> 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 compares the actual weathers degrees and the optimal fermentation degrees of a product in order to flag with an alert!!
|
|
|
|
| 15 |
Args:
|
| 16 |
current_weather: A float representing the degrees of current weather.
|
| 17 |
optimal_fermentation_degrees: A float representing the degrees that should be the fermentation process.
|
| 18 |
"""
|
| 19 |
try:
|
| 20 |
-
dif_degrees = current_weather-optimal_fermentation_degrees
|
| 21 |
if abs(dif_degrees) >= 1.5:
|
| 22 |
-
if dif_degrees<0:
|
| 23 |
-
return f"RED LIGHT - the difference degrees between optimal and current weather are {dif_degrees}ºC - YOU SHOULD INCREASE THE HEATER BY {dif_degrees}ºC!"
|
| 24 |
else:
|
| 25 |
-
return f"RED LIGHT - the difference degrees between optimal and current weather are {dif_degrees}ºC - YOU SHOULD DECREASE THE HEATER BY {dif_degrees}ºC!"
|
| 26 |
else:
|
| 27 |
-
return f"GREEN LIGHT - the difference degrees between optimal and current weather are {dif_degrees} -
|
| 28 |
except Exception as e:
|
| 29 |
return f"Error fetching {str(current_weather)} and {str(optimal_fermentation_degrees)}."
|
| 30 |
|
|
@@ -48,14 +56,15 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 48 |
search_info_tool = DuckDuckGoSearchTool()
|
| 49 |
|
| 50 |
final_answer = FinalAnswerTool()
|
|
|
|
| 51 |
model = HfApiModel(
|
| 52 |
-
max_tokens=2096,
|
| 53 |
-
temperature=0.5,
|
| 54 |
-
model_id=
|
| 55 |
-
custom_role_conversions=None,
|
|
|
|
| 56 |
)
|
| 57 |
|
| 58 |
-
|
| 59 |
# Import tool from Hub
|
| 60 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 61 |
|
|
@@ -71,7 +80,7 @@ agent = CodeAgent(
|
|
| 71 |
planning_interval=None,
|
| 72 |
name=None,
|
| 73 |
description=None,
|
| 74 |
-
prompt_templates=prompt_templates
|
| 75 |
)
|
| 76 |
|
| 77 |
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from dotenv import load_dotenv
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
+
|
| 11 |
+
load_dotenv()
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 15 |
+
|
| 16 |
+
|
| 17 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 18 |
@tool
|
| 19 |
def compare_degrees(current_weather:float, optimal_fermentation_degrees:float)-> str: #it's import to specify the return type
|
| 20 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 21 |
"""A tool that compares the actual weathers degrees and the optimal fermentation degrees of a product in order to flag with an alert!!
|
| 22 |
+
|
| 23 |
Args:
|
| 24 |
current_weather: A float representing the degrees of current weather.
|
| 25 |
optimal_fermentation_degrees: A float representing the degrees that should be the fermentation process.
|
| 26 |
"""
|
| 27 |
try:
|
| 28 |
+
dif_degrees = current_weather - optimal_fermentation_degrees
|
| 29 |
if abs(dif_degrees) >= 1.5:
|
| 30 |
+
if dif_degrees < 0:
|
| 31 |
+
return f"RED LIGHT - the difference degrees between optimal and current weather are {str(dif_degrees)}ºC - YOU SHOULD INCREASE THE HEATER BY {str(dif_degrees)}ºC!"
|
| 32 |
else:
|
| 33 |
+
return f"RED LIGHT - the difference degrees between optimal and current weather are {str(dif_degrees)}ºC - YOU SHOULD DECREASE THE HEATER BY {str(dif_degrees)}ºC!"
|
| 34 |
else:
|
| 35 |
+
return f"GREEN LIGHT - the difference degrees between optimal and current weather are {str(dif_degrees)} - DEGREES FOR FERMENTATION IN RANGE!"
|
| 36 |
except Exception as e:
|
| 37 |
return f"Error fetching {str(current_weather)} and {str(optimal_fermentation_degrees)}."
|
| 38 |
|
|
|
|
| 56 |
search_info_tool = DuckDuckGoSearchTool()
|
| 57 |
|
| 58 |
final_answer = FinalAnswerTool()
|
| 59 |
+
|
| 60 |
model = HfApiModel(
|
| 61 |
+
max_tokens=2096,
|
| 62 |
+
temperature=0.5,
|
| 63 |
+
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 64 |
+
custom_role_conversions=None,
|
| 65 |
+
token=HF_TOKEN,
|
| 66 |
)
|
| 67 |
|
|
|
|
| 68 |
# Import tool from Hub
|
| 69 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 70 |
|
|
|
|
| 80 |
planning_interval=None,
|
| 81 |
name=None,
|
| 82 |
description=None,
|
| 83 |
+
prompt_templates=prompt_templates.
|
| 84 |
)
|
| 85 |
|
| 86 |
|