PolPC13 commited on
Commit
9f77c23
·
1 Parent(s): 14fdbf2

Added ddgs.

Browse files
Files changed (3) hide show
  1. app.py +7 -12
  2. requirements.txt +1 -0
  3. tools/web_search.py +4 -4
app.py CHANGED
@@ -1,19 +1,14 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool
 
 
 
2
  import yaml
3
  from tools.final_answer import FinalAnswerTool
4
  from tools.exchange_rates import ExchangeRatesTool
5
- from tools.get_current_time import GetCurrentTimeTool
6
-
7
  from Gradio_UI import GradioUI
8
 
9
-
10
- # Nota: Para la parte de "actualización cada X tiempo", el agente llamará a este tool
11
- # cuando lo necesite. Si se quisiera un cache persistente, se podría usar la librería
12
- # 'cachetools' o 'functools.lru_cache' con un tiempo de vida (TTL) en la capa de la aplicación.
13
-
14
-
15
- exchange_rates = ExchangeRatesTool()
16
- get_current_time = GetCurrentTimeTool()
17
  final_answer = FinalAnswerTool()
18
 
19
  # 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:
@@ -35,7 +30,7 @@ with open("prompts.yaml", 'r') as stream:
35
 
36
  agent = CodeAgent(
37
  model=model,
38
- tools=[final_answer, exchange_rates, get_current_time], ## add your tools here (don't remove final answer)
39
  max_steps=6,
40
  verbosity_level=1,
41
  grammar=None,
 
1
+ from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
+ import datetime
3
+ import requests
4
+ import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
  from tools.exchange_rates import ExchangeRatesTool
8
+ from tools.web_search import ddgs
9
+ from tools.visit_webpage import VisitWebpageTool
10
  from Gradio_UI import GradioUI
11
 
 
 
 
 
 
 
 
 
12
  final_answer = FinalAnswerTool()
13
 
14
  # 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:
 
30
 
31
  agent = CodeAgent(
32
  model=model,
33
+ tools=[final_answer, ddgs, VisitWebpageTool, ExchangeRatesTool], ## add your tools here (don't remove final answer)
34
  max_steps=6,
35
  verbosity_level=1,
36
  grammar=None,
requirements.txt CHANGED
@@ -3,3 +3,4 @@ smolagents==1.13.0
3
  requests
4
  duckduckgo_search
5
  pandas
 
 
3
  requests
4
  duckduckgo_search
5
  pandas
6
+ ddgs
tools/web_search.py CHANGED
@@ -1,8 +1,8 @@
1
  from typing import Any, Optional
2
  from smolagents.tools import Tool
3
- import duckduckgo_search
4
 
5
- class DuckDuckGoSearchTool(Tool):
6
  name = "web_search"
7
  description = "Performs a duckduckgo web search based on your query (think a Google search) then returns the top search results."
8
  inputs = {'query': {'type': 'string', 'description': 'The search query to perform.'}}
@@ -12,10 +12,10 @@ class DuckDuckGoSearchTool(Tool):
12
  super().__init__()
13
  self.max_results = max_results
14
  try:
15
- from duckduckgo_search import DDGS
16
  except ImportError as e:
17
  raise ImportError(
18
- "You must install package `duckduckgo_search` to run this tool: for instance run `pip install duckduckgo-search`."
19
  ) from e
20
  self.ddgs = DDGS(**kwargs)
21
 
 
1
  from typing import Any, Optional
2
  from smolagents.tools import Tool
3
+ import ddgs
4
 
5
+ class ddgs(Tool):
6
  name = "web_search"
7
  description = "Performs a duckduckgo web search based on your query (think a Google search) then returns the top search results."
8
  inputs = {'query': {'type': 'string', 'description': 'The search query to perform.'}}
 
12
  super().__init__()
13
  self.max_results = max_results
14
  try:
15
+ from ddgs import DDGS
16
  except ImportError as e:
17
  raise ImportError(
18
+ "You must install package `duckduckgo_search` to run this tool: for instance run `pip install ddgs`."
19
  ) from e
20
  self.ddgs = DDGS(**kwargs)
21