Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
from typing import List
|
| 8 |
|
| 9 |
class WebSearchTool:
|
| 10 |
"""Outil qui permet de faire une recherche sur un site web donné en utilisant DuckDuckGo."""
|
|
@@ -13,7 +13,15 @@ class WebSearchTool:
|
|
| 13 |
self.duckduckgo_search_tool = load_tool("smolagents:DuckDuckGoSearchTool")
|
| 14 |
|
| 15 |
def search(self, query: str, max_results: int = 5) -> List[str]:
|
| 16 |
-
"""Effectue une recherche sur DuckDuckGo et retourne les résultats limités à `max_results`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# Utiliser l'outil DuckDuckGoSearchTool pour effectuer la recherche
|
| 19 |
results = self.duckduckgo_search_tool(query, max_results=max_results)
|
|
@@ -22,9 +30,30 @@ class WebSearchTool:
|
|
| 22 |
|
| 23 |
# Maintenant, on ajoute cette fonction d'outil à notre agent
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
@tool
|
| 26 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 27 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
try:
|
| 29 |
tz = pytz.timezone(timezone)
|
| 30 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from typing import List
|
| 8 |
|
| 9 |
class WebSearchTool:
|
| 10 |
"""Outil qui permet de faire une recherche sur un site web donné en utilisant DuckDuckGo."""
|
|
|
|
| 13 |
self.duckduckgo_search_tool = load_tool("smolagents:DuckDuckGoSearchTool")
|
| 14 |
|
| 15 |
def search(self, query: str, max_results: int = 5) -> List[str]:
|
| 16 |
+
"""Effectue une recherche sur DuckDuckGo et retourne les résultats limités à `max_results`.
|
| 17 |
+
|
| 18 |
+
Args:
|
| 19 |
+
query (str): La requête de recherche.
|
| 20 |
+
max_results (int, optional): Le nombre maximum de résultats à retourner. Par défaut est 5.
|
| 21 |
+
|
| 22 |
+
Returns:
|
| 23 |
+
List[str]: Une liste des snippets des résultats de recherche.
|
| 24 |
+
"""
|
| 25 |
|
| 26 |
# Utiliser l'outil DuckDuckGoSearchTool pour effectuer la recherche
|
| 27 |
results = self.duckduckgo_search_tool(query, max_results=max_results)
|
|
|
|
| 30 |
|
| 31 |
# Maintenant, on ajoute cette fonction d'outil à notre agent
|
| 32 |
|
| 33 |
+
@tool
|
| 34 |
+
def my_custom_tool(arg1: str, arg2: int) -> str:
|
| 35 |
+
"""A tool that does nothing yet
|
| 36 |
+
Args:
|
| 37 |
+
arg1: the first argument
|
| 38 |
+
arg2: the second argument
|
| 39 |
+
"""
|
| 40 |
+
return "What magic will you build ?"
|
| 41 |
+
|
| 42 |
+
# Ajoutons une description détaillée pour l'argument 'timezone'
|
| 43 |
@tool
|
| 44 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 45 |
+
"""Récupère le temps local actuel dans un fuseau horaire spécifié.
|
| 46 |
+
|
| 47 |
+
Args:
|
| 48 |
+
timezone (str): Le fuseau horaire pour lequel récupérer le temps. Par exemple, 'UTC', 'Europe/Paris', etc.
|
| 49 |
+
|
| 50 |
+
Returns:
|
| 51 |
+
str: La chaîne représentant l'heure locale au format "AAAA-MM-JJ HH:MM:SS".
|
| 52 |
+
|
| 53 |
+
Raises:
|
| 54 |
+
Exception: Si le fuseau horaire spécifié est incorrect.
|
| 55 |
+
"""
|
| 56 |
+
|
| 57 |
try:
|
| 58 |
tz = pytz.timezone(timezone)
|
| 59 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|