Spaces:
Runtime error
Runtime error
Download app.py from TurismoparalaVida/First_agent_template: direct link, hf CLI and curl.
- Browser
- Download file 2.45 kB
-
https://huggingface.co/spaces/TurismoparalaVida/First_agent_template/resolve/main/app.py
- Command line
-
hf download hf://spaces/TurismoparalaVida/First_agent_template/app.py
-
curl -L -o app.py https://huggingface.co/spaces/TurismoparalaVida/First_agent_template/resolve/main/app.py
2.45 kB
| from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool | |
| import datetime | |
| import requests | |
| import pytz | |
| import yaml | |
| from tools.final_answer import FinalAnswerTool | |
| from Gradio_UI import GradioUI | |
| def cotizar_evento_all_inclusive(numero_asistentes: int) -> str: | |
| """Una herramienta que calcula el costo total de un evento corporativo campestre 'Todo Incluido' (All-Inclusive). | |
| Args: | |
| numero_asistentes: El número total de colaboradores o personas que asistirán al evento. | |
| """ | |
| tarifa_por_persona = 270182 | |
| subtotal = numero_asistentes * tarifa_por_persona | |
| iva = subtotal * 0.19 | |
| total_con_iva = subtotal + iva | |
| resultado = ( | |
| f"Cotización estimada para {numero_asistentes} personas:\\n" | |
| f"- Subtotal: ${subtotal:,.0f} COP\\n" | |
| f"- IVA (19%): ${iva:,.0f} COP\\n" | |
| f"- Total a pagar: ${total_con_iva:,.0f} COP\\n\\n" | |
| f"El paquete incluye: Sede exclusiva por 12 horas, transporte de turismo, " | |
| f"producción técnica con DJ, catering en 4 tiempos, 3 cervezas por persona y staff logístico." | |
| ) | |
| return resultado | |
| def get_current_time_in_timezone(timezone: str) -> str: | |
| """Una herramienta que obtiene la hora local actual en una zona horaria especificada. | |
| Args: | |
| timezone: Una cadena que representa una zona horaria válida (por ejemplo, 'America/New_York'). | |
| """ | |
| try: | |
| tz = pytz.timezone(timezone) | |
| local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S") | |
| return f"La hora local actual en {timezone} es: {local_time}" | |
| except Exception as e: | |
| return f"Error al obtener la hora para la zona horaria '{timezone}': {str(e)}" | |
| final_answer = FinalAnswerTool() | |
| model = HfApiModel( | |
| max_tokens=2096, | |
| temperature=0.5, | |
| model_id='Qwen/Qwen2.5-Coder-32B-Instruct', | |
| custom_role_conversions=None, | |
| ) | |
| # Importar herramienta desde Hub | |
| image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True) | |
| with open("prompts.yaml", 'r') as stream: | |
| prompt_templates = yaml.safe_load(stream) | |
| agent = CodeAgent( | |
| model=model, | |
| tools=[final_answer, cotizar_evento_all_inclusive, get_current_time_in_timezone, image_generation_tool], | |
| max_steps=6, | |
| verbosity_level=1, | |
| grammar=None, | |
| planning_interval=None, | |
| name=None, | |
| description=None, | |
| prompt_templates=prompt_templates | |
| ) | |
| GradioUI(agent).launch() |