Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,6 @@ from smolagents import (
|
|
| 9 |
DuckDuckGoSearchTool,
|
| 10 |
VisitWebpageTool,
|
| 11 |
PythonInterpreterTool,
|
| 12 |
-
tool
|
| 13 |
)
|
| 14 |
|
| 15 |
|
|
@@ -17,28 +16,6 @@ from smolagents import (
|
|
| 17 |
# --- Constants ---
|
| 18 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 19 |
|
| 20 |
-
# Mes outils
|
| 21 |
-
|
| 22 |
-
@tool
|
| 23 |
-
def reverse_text_tool(text: str) -> str:
|
| 24 |
-
"""Reverse text and word order"""
|
| 25 |
-
words = text.split(" ")[::-1]
|
| 26 |
-
return " ".join([word[::-1] for word in words])
|
| 27 |
-
|
| 28 |
-
@tool
|
| 29 |
-
def clean_answer_tool(answer: str) -> str:
|
| 30 |
-
"""Clean answer"""
|
| 31 |
-
if answer.endswith('.'):
|
| 32 |
-
answer = answer[:-1]
|
| 33 |
-
return answer.replace("St.", "Saint").strip()
|
| 34 |
-
|
| 35 |
-
@tool
|
| 36 |
-
def extract_numbers_tool(text: str) -> str:
|
| 37 |
-
"""Extract numbers from text"""
|
| 38 |
-
import re
|
| 39 |
-
numbers = re.findall(r'\d+\.?\d*', text)
|
| 40 |
-
return ', '.join(numbers)
|
| 41 |
-
|
| 42 |
|
| 43 |
# ----- THIS IS WHERE YOU CAN BUILD WHAT YOU WANT ------
|
| 44 |
|
|
@@ -54,12 +31,10 @@ class BasicAgent:
|
|
| 54 |
self.agent = CodeAgent(
|
| 55 |
model=self.model,
|
| 56 |
tools=[
|
| 57 |
-
DuckDuckGoSearchTool(),
|
| 58 |
-
VisitWebpageTool(),
|
| 59 |
-
PythonInterpreterTool(),
|
| 60 |
-
|
| 61 |
-
clean_answer_tool,
|
| 62 |
-
extract_numbers_tool,
|
| 63 |
],
|
| 64 |
max_steps=15,
|
| 65 |
verbosity_level=1,
|
|
|
|
| 9 |
DuckDuckGoSearchTool,
|
| 10 |
VisitWebpageTool,
|
| 11 |
PythonInterpreterTool,
|
|
|
|
| 12 |
)
|
| 13 |
|
| 14 |
|
|
|
|
| 16 |
# --- Constants ---
|
| 17 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# ----- THIS IS WHERE YOU CAN BUILD WHAT YOU WANT ------
|
| 21 |
|
|
|
|
| 31 |
self.agent = CodeAgent(
|
| 32 |
model=self.model,
|
| 33 |
tools=[
|
| 34 |
+
DuckDuckGoSearchTool(), # ✅ Cherche sur le web
|
| 35 |
+
VisitWebpageTool(), # ✅ Lit les pages
|
| 36 |
+
PythonInterpreterTool(), # ✅ Fait des calculs
|
| 37 |
+
# ❌ SUPPRIME LES 3 OUTILS INUTILES
|
|
|
|
|
|
|
| 38 |
],
|
| 39 |
max_steps=15,
|
| 40 |
verbosity_level=1,
|