keynes42 commited on
Commit
9126d5d
·
verified ·
1 Parent(s): 67b6988

Update custom_tools.py

Browse files
Files changed (1) hide show
  1. custom_tools.py +7 -2
custom_tools.py CHANGED
@@ -3,6 +3,10 @@ from bs4 import BeautifulSoup
3
  from typing import List, Dict, Any
4
  from functools import lru_cache
5
  from smolagents import Tool, WebSearchTool, WikipediaSearchTool, PythonInterpreterTool
 
 
 
 
6
 
7
  class WebpageStructureAnalyzerTool(Tool):
8
  """
@@ -17,8 +21,9 @@ class WebpageStructureAnalyzerTool(Tool):
17
  "a webpage's layout *before* trying to write specific 'bs4' code "
18
  "to extract detailed information."
19
  )
 
20
 
21
- def run(self, url: str) -> str:
22
  """
23
  Executes the webpage structure analysis.
24
 
@@ -29,7 +34,7 @@ class WebpageStructureAnalyzerTool(Tool):
29
  A string containing the structure summary or an error message.
30
  """
31
  # Ensure the core function is accessible here
32
- return analyze_webpage_structure(url)
33
 
34
  class CachedWebSearchTool(WebSearchTool):
35
  @lru_cache(maxsize=128)
 
3
  from typing import List, Dict, Any
4
  from functools import lru_cache
5
  from smolagents import Tool, WebSearchTool, WikipediaSearchTool, PythonInterpreterTool
6
+ from pydantic import BaseModel, Field
7
+
8
+ class WebpageStructureInputs(BaseModel):
9
+ url: str = Field(description="The URL of the webpage to analyze.")
10
 
11
  class WebpageStructureAnalyzerTool(Tool):
12
  """
 
21
  "a webpage's layout *before* trying to write specific 'bs4' code "
22
  "to extract detailed information."
23
  )
24
+ inputs: Type[BaseModel] = WebpageStructureInputs
25
 
26
+ def run(self, inputs: WebpageStructureInputs) -> str:
27
  """
28
  Executes the webpage structure analysis.
29
 
 
34
  A string containing the structure summary or an error message.
35
  """
36
  # Ensure the core function is accessible here
37
+ return analyze_webpage_structure(inputs.url)
38
 
39
  class CachedWebSearchTool(WebSearchTool):
40
  @lru_cache(maxsize=128)