sapayth commited on
Commit
3434ea0
·
verified ·
1 Parent(s): 85f9084

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -25
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
@@ -7,10 +7,10 @@ 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_custom_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
@@ -33,29 +33,12 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
- @tool
37
- def calculator(expression: str) -> str:
38
- """A tool that evaluates mathematical expressions.
39
- Args:
40
- expression: A string containing a mathematical expression (e.g., '2 + 2', '5 * 10', 'sqrt(16)').
41
- """
42
- try:
43
- # Use Python's built-in eval function for simple calculations
44
- # This is safe as long as the agent is using it internally
45
- result = eval(expression, {"__builtins__": {}}, {"sqrt": lambda x: x**0.5})
46
- return f"Result of {expression} = {result}"
47
- except Exception as e:
48
- return f"Error calculating '{expression}': {str(e)}"
49
-
50
- final_answer = FinalAnswerTool()
51
-
52
- # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
53
- # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
54
 
 
55
  model = HfApiModel(
56
  max_tokens=2096,
57
  temperature=0.5,
58
- model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',# it is possible that this model may be overloaded
59
  custom_role_conversions=None,
60
  )
61
 
@@ -68,8 +51,8 @@ with open("prompts.yaml", 'r') as stream:
68
 
69
  agent = CodeAgent(
70
  model=model,
71
- tools=[final_answer, calculator], ## add your tools here (don't remove final answer)
72
- max_steps=3,
73
  verbosity_level=1,
74
  grammar=None,
75
  planning_interval=None,
 
1
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
2
  import datetime
3
  import requests
4
  import pytz
 
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_custom_tool(arg1:str, arg2:int)-> str: # it's important to specify the return type
13
+ # Keep this format for the tool description / args description but feel free to modify the tool
14
  """A tool that does nothing yet
15
  Args:
16
  arg1: the first argument
 
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ final_answer = FinalAnswerTool()
38
  model = HfApiModel(
39
  max_tokens=2096,
40
  temperature=0.5,
41
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
42
  custom_role_conversions=None,
43
  )
44
 
 
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,
58
  planning_interval=None,