Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,41 @@ from Gradio_UI import GradioUI
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
-
"""A tool that
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
arg2: the second argument
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def get_ibge_news(qtd_noticias:int)-> str: #it's import to specify the return type
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
+
"""A tool that get recently news about IBGE
|
| 15 |
Args:
|
| 16 |
+
qtd_noticias: quantidade de notícias que você quer saber
|
|
|
|
| 17 |
"""
|
| 18 |
+
|
| 19 |
+
url = "http://servicodados.ibge.gov.br/api/v3/noticias/"
|
| 20 |
+
response = requests.get(url)
|
| 21 |
+
|
| 22 |
+
# Verificando se a requisição foi bem-sucedida
|
| 23 |
+
if response.status_code == 200:
|
| 24 |
+
|
| 25 |
+
dados = response.json() # Convertendo para JSON
|
| 26 |
+
|
| 27 |
+
todas_noticias = ""
|
| 28 |
+
i=0
|
| 29 |
+
|
| 30 |
+
for item in dados['items']:
|
| 31 |
+
todas_noticias += f"""
|
| 32 |
+
Noticia {i}
|
| 33 |
+
Data de Publicacao: {item['data_publicacao']}
|
| 34 |
+
Tipo: {item['tipo']}
|
| 35 |
+
Titulo: {item['titulo']}
|
| 36 |
+
"""
|
| 37 |
+
i+=1
|
| 38 |
+
|
| 39 |
+
return f"The last news are: {todas_noticias}"
|
| 40 |
+
|
| 41 |
+
else:
|
| 42 |
+
return f"Erro ao acessar a API: {response.status_code}")
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
|
| 47 |
|
| 48 |
@tool
|
| 49 |
def get_current_time_in_timezone(timezone: str) -> str:
|