ASD492 commited on
Commit
bd125ca
·
verified ·
1 Parent(s): 11be797

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -30
app.py CHANGED
@@ -6,27 +6,7 @@ import yaml
6
  from tools.final_answer import FinalAnswerTool
7
  from Gradio_UI import GradioUI
8
 
9
- @tool
10
- def my_custom_tool(arg1:str, arg2:int)-> str:
11
- """A tool that does nothing yet
12
- Args:
13
- arg1: the first argument
14
- arg2: the second argument
15
- """
16
- return "What magic will you build ?"
17
-
18
- @tool
19
- def get_current_time_in_timezone(timezone: str) -> str:
20
- """A tool that fetches the current local time in a specified timezone.
21
- Args:
22
- timezone: A string representing a valid timezone (e.g., 'America/New_York').
23
- """
24
- try:
25
- tz = pytz.timezone(timezone)
26
- local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
27
- return f"The current local time in {timezone} is: {local_time}"
28
- except Exception as e:
29
- return f"Error fetching time for timezone '{timezone}': {str(e)}"
30
 
31
  final_answer = FinalAnswerTool()
32
  model = HfApiModel(
@@ -39,22 +19,17 @@ model = HfApiModel(
39
  # Initialize the DuckDuckGo Search Tool
40
  duckduckgo_search_tool = DuckDuckGoSearchTool()
41
 
42
- # Attempt to load the Wikipedia tool from the smolagents tool hub
43
- try:
44
- wikipedia_tool = load_tool("wikipedia", trust_remote_code=True)
45
- except Exception as e:
46
- print(f"Could not load Wikipedia tool. You might need to find the correct tool ID in the smolagents tool hub. Error: {e}")
47
- wikipedia_tool = None
48
 
49
  with open("prompts.yaml", 'r') as stream:
50
  prompt_templates = yaml.safe_load(stream)
51
  tools_list = [final_answer, duckduckgo_search_tool]
52
- if wikipedia_tool:
53
- tools_list.append(wikipedia_tool)
54
 
55
  agent = CodeAgent(
56
  model=model,
57
- tools=tools_list, # Add the DuckDuckGo Search Tool and Wikipedia Tool here
58
  max_steps=6,
59
  verbosity_level=1,
60
  grammar=None,
 
6
  from tools.final_answer import FinalAnswerTool
7
  from Gradio_UI import GradioUI
8
 
9
+ # ... (Your existing my_custom_tool and get_current_time_in_timezone definitions)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  final_answer = FinalAnswerTool()
12
  model = HfApiModel(
 
19
  # Initialize the DuckDuckGo Search Tool
20
  duckduckgo_search_tool = DuckDuckGoSearchTool()
21
 
22
+ # Removed the attempt to load the Wikipedia tool
23
+ # The previous code to load the Wikipedia tool was here.
 
 
 
 
24
 
25
  with open("prompts.yaml", 'r') as stream:
26
  prompt_templates = yaml.safe_load(stream)
27
  tools_list = [final_answer, duckduckgo_search_tool]
28
+ # The conditional block to add the Wikipedia tool has been removed.
 
29
 
30
  agent = CodeAgent(
31
  model=model,
32
+ tools=tools_list, # Only includes final_answer and duckduckgo_search_tool now
33
  max_steps=6,
34
  verbosity_level=1,
35
  grammar=None,