Spaces:
Running
Running
import json | |
import os | |
import requests | |
from modules import log_module | |
activo = False | |
user_text = "Leyendo pagina web" | |
info = { | |
"type": "function", | |
"function":{ | |
"name": "leer_pagina_web", | |
"description": "Un portal hacia Internet. Úsalo cuando necesites obtener contenido específico de un sitio web. La entrada debe ser una URL (por ejemplo, https://www.google.com). La salida será la respuesta en texto de la solicitud GET.", | |
"parameters": { | |
"type": "object", | |
"properties": { | |
"url": { | |
"type": "string", | |
"description": "el url a consultar", | |
}, | |
}, | |
"required": ["url"], | |
} | |
} | |
} | |
def ejecutar(url): | |
try: | |
req = requests.get(url=url, timeout=5) | |
retorno = { | |
"data": req.text | |
} | |
return json.dumps(retorno) | |
except Exception as e: | |
log_module.logger.error(repr(e)) | |
return json.dumps({"status": "api failed"}) | |