Spaces:
Sleeping
Sleeping
Create count_words.py
#7
by marcfulla - opened
- tools/count_words.py +11 -0
tools/count_words.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import tool
|
| 2 |
+
|
| 3 |
+
@tool
|
| 4 |
+
def count_words(text: str) -> str:
|
| 5 |
+
"""
|
| 6 |
+
Cuenta cuántas palabras hay en un texto.
|
| 7 |
+
Args:
|
| 8 |
+
text: El texto a analizar.
|
| 9 |
+
"""
|
| 10 |
+
num_words = len(text.split())
|
| 11 |
+
return f"El texto tiene {num_words} palabras."
|