qwikQ8 commited on
Commit
be3c9b2
·
verified ·
1 Parent(s): aa9257e

Update app2.py

Browse files

Added search tool and added CodeAgent

Files changed (1) hide show
  1. app2.py +13 -3
app2.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
@@ -34,8 +34,16 @@ 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
 
 
 
 
 
 
 
 
39
  # 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:
40
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
41
 
@@ -55,15 +63,17 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
62
  planning_interval=None,
 
 
63
  name=None,
64
  description=None,
65
  prompt_templates=prompt_templates
66
  )
67
 
68
 
69
- GradioUI(agent).launch()
 
1
+ from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool, Tool
2
  import datetime
3
  import requests
4
  import pytz
 
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
 
37
+ # Initialize the final answer tool
38
  final_answer = FinalAnswerTool()
39
 
40
+ # Initialize the web search tool
41
+ search_tool = DuckDuckGoSearchTool()
42
+
43
+ # Initialize the weather tool
44
+ weather_info_tool = WeatherInfoTool()
45
+
46
+
47
  # 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:
48
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
49
 
 
63
 
64
  agent = CodeAgent(
65
  model=model,
66
+ tools=[final_answer, search_tool], ## add your tools here (don't remove final answer)
67
  max_steps=6,
68
  verbosity_level=1,
69
  grammar=None,
70
  planning_interval=None,
71
+ add_base_tools=True, # Add any additional base tools
72
+ #planning_interval=3, # Enable planning every 3 steps
73
  name=None,
74
  description=None,
75
  prompt_templates=prompt_templates
76
  )
77
 
78
 
79
+ GradioUI(agent).launch()