File size: 2,449 Bytes
dc784c4
375679c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41c1966
 
 
 
375679c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dc784c4
375679c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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

@tool
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

@tool
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()