File size: 1,583 Bytes
c4a2f74
 
e02d9a1
c4a2f74
 
 
 
e02d9a1
c4a2f74
 
 
 
 
 
 
e02d9a1
 
 
c4a2f74
 
e02d9a1
c4a2f74
 
 
 
 
 
 
e02d9a1
c4a2f74
 
 
e02d9a1
c4a2f74
 
e02d9a1
 
 
 
 
 
 
 
c4a2f74
 
 
 
 
e02d9a1
 
c4a2f74
 
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
import yaml
import os
from smolagents import CodeAgent, InferenceClientModel, GradioUI

# Get current directory path
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))

# Importa herramientas personalizadas
from tools.web_search import DuckDuckGoSearchTool as WebSearch
from tools.visit_webpage import VisitWebpageTool as VisitWebpage
from tools.suggest_menu import SimpleTool as SuggestMenu
from tools.catering_service_tool import SimpleTool as CateringServiceTool
from tools.superhero_party_theme_generator import SuperheroPartyThemeTool as SuperheroPartyThemeGenerator
from tools.final_answer import FinalAnswerTool as FinalAnswer

# Usa modelo público y gratuito
model = InferenceClientModel(
    model_id="mistralai/Mistral-7B-Instruct-v0.2"
)

# Instancia las herramientas
web_search = WebSearch()
visit_webpage = VisitWebpage()
suggest_menu = SuggestMenu()
catering_service_tool = CateringServiceTool()
superhero_party_theme_generator = SuperheroPartyThemeGenerator()
final_answer = FinalAnswer()

# Carga los prompts desde YAML
with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
    prompt_templates = yaml.safe_load(stream)

# Instancia el agente
agent = CodeAgent(
    model=model,
    tools=[
        web_search,
        visit_webpage,
        suggest_menu,
        catering_service_tool,
        superhero_party_theme_generator,
        final_answer
    ],
    managed_agents=[],
    max_steps=10,
    verbosity_level=2,
    prompt_templates=prompt_templates
)

# Inicia la interfaz Gradio
if __name__ == "__main__":
    GradioUI(agent).launch()