aaabulkhair commited on
Commit
d717ca6
·
verified ·
1 Parent(s): 4bdd7cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -4,20 +4,19 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
-
8
  from Gradio_UI import GradioUI
9
 
10
 
11
  @tool
12
  def get_current_time_in_timezone(timezone: str) -> str:
13
  """
14
- A tool that fetches the current local time in a specified timezone.
15
 
16
  Args:
17
- timezone (str): A valid timezone string (e.g., 'America/New_York').
18
 
19
  Returns:
20
- str: A message with the current local time in the given timezone or an error message if the timezone is invalid.
21
  """
22
  try:
23
  tz = pytz.timezone(timezone)
@@ -29,14 +28,14 @@ def get_current_time_in_timezone(timezone: str) -> str:
29
  @tool
30
  def calculator_tool(expression: str) -> str:
31
  """
32
- A calculator tool that evaluates a mathematical expression.
33
 
34
  Args:
35
- expression (str): A string representing a mathematical expression.
36
- Supported operators: +, -, *, /, **, and %.
37
 
38
  Returns:
39
- str: The result of the calculation as a string, or an error message if evaluation fails.
40
  """
41
  try:
42
  # Evaluate the expression in a restricted environment for safety.
@@ -52,11 +51,11 @@ final_answer = FinalAnswerTool()
52
  model = HfApiModel(
53
  max_tokens=2096,
54
  temperature=0.5,
55
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct', # It is possible that this model may be overloaded.
56
  custom_role_conversions=None,
57
  )
58
 
59
- # Import tool from Hub
60
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
61
 
62
  with open("prompts.yaml", 'r') as stream:
@@ -64,7 +63,7 @@ with open("prompts.yaml", 'r') as stream:
64
 
65
  agent = CodeAgent(
66
  model=model,
67
- tools=[final_answer, calculator_tool], # Added our calculator tool along with final_answer.
68
  max_steps=6,
69
  verbosity_level=1,
70
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
  from Gradio_UI import GradioUI
8
 
9
 
10
  @tool
11
  def get_current_time_in_timezone(timezone: str) -> str:
12
  """
13
+ Fetches the current local time for the specified timezone.
14
 
15
  Args:
16
+ timezone: A valid timezone string.
17
 
18
  Returns:
19
+ A string message with the current local time, or an error message.
20
  """
21
  try:
22
  tz = pytz.timezone(timezone)
 
28
  @tool
29
  def calculator_tool(expression: str) -> str:
30
  """
31
+ Evaluates a mathematical expression.
32
 
33
  Args:
34
+ expression: A string representing a mathematical expression.
35
+ Supported operators: +, -, *, /, **, and %.
36
 
37
  Returns:
38
+ A string representing the result of the calculation, or an error message if evaluation fails.
39
  """
40
  try:
41
  # Evaluate the expression in a restricted environment for safety.
 
51
  model = HfApiModel(
52
  max_tokens=2096,
53
  temperature=0.5,
54
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
55
  custom_role_conversions=None,
56
  )
57
 
58
+ # Import tool from Hub (e.g., text-to-image)
59
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
60
 
61
  with open("prompts.yaml", 'r') as stream:
 
63
 
64
  agent = CodeAgent(
65
  model=model,
66
+ tools=[final_answer, calculator_tool], # Added final_answer and our calculator tool
67
  max_steps=6,
68
  verbosity_level=1,
69
  grammar=None,