File size: 2,148 Bytes
c19d193
dcf90f7
6aae614
9b5b26a
2d006cd
819bbe5
92b4fd5
0b75bc8
b3c8907
 
e4438bc
3c1ee24
0b75bc8
8ca14db
2d006cd
b444264
8ca14db
 
2d006cd
 
8ca14db
 
2d006cd
8ca14db
2d006cd
 
8ca14db
2d006cd
8ca14db
c291fc7
0b75bc8
6aae614
ae7a494
c291fc7
9382038
c291fc7
9382038
e121372
9382038
 
615afaf
3b293d2
13d500a
8c01ffb
9382038
dcf90f7
861422e
dcf90f7
c291fc7
8c01ffb
8fe992b
b3c8907
 
3c1ee24
b3c8907
 
 
 
 
c291fc7
b3c8907
c291fc7
b3c8907
8c01ffb
861422e
8fe992b
 
c291fc7
dcf90f7
8c01ffb
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
import yaml
from smolagents import CodeAgent, HfApiModel
from tools.final_answer import FinalAnswerTool
from Gradio_UI import GradioUI
import os
from tools.graph_plotter_tool import plot_function_graph
from tools.table_generator_tool import generate_data_table 

from tools.statistical_graph_generator import plot_bar_chart, plot_pie_chart, plot_histogram, plot_line_chart
from tools.statistical_graph_analyzer import analyze_dataset
from tools.media_graph_critic import critique_media_graph
from tools.parabola_plotter_tool import plot_parabola_graph
#Tentar implementar Langfuse
#from openinference.instrumentation.smolagents import SmolAgentsInstrumentor

#from langfuse import Langfuse

#print("Configurando a observabilidade com Langfuse...")

# Pega as chaves diretamente das variáveis de ambiente (Secrets do Space)
#os.environ["LANGFUSE_PUBLIC_KEY"] = os.environ.get('LANGFUSE_PUBLIC_KEY')
#os.environ["LANGFUSE_SECRET_KEY"] = os.environ.get('LANGFUSE_SECRET_KEY')
# Inicializa o Langfuse
#langfuse = Langfuse()

# "Instrumenta" a biblioteca smolagents
#SmolAgentsInstrumentor().instrument()

#print("Observabilidade configurada com sucesso.")


final_answer = FinalAnswerTool()

# Configuração do Modelo

#testar outros modelos: meta-llama/Llama-3.1-70B-Instruct e Gemma 3-27B

model = HfApiModel(
    # AUMENTAR OS TOKENS para acomodar respostas mais longas com várias questões
    max_tokens=4096, 
    temperature=0.6,
    model_id='Qwen/Qwen2.5-VL-32B-Instruct',
)

# Carregar nosso novo prompt especializado em gerar questões.
with open("prompts.yaml", 'r', encoding='utf-8') as stream:
    prompt_templates = yaml.safe_load(stream)

# Criação do Agente
agent = CodeAgent(
    model=model,
    tools=[
        final_answer,
        plot_parabola_graph,
        plot_bar_chart,
        plot_pie_chart,
        plot_histogram,
        plot_line_chart,
        analyze_dataset,
        generate_data_table,
        critique_media_graph
    ],  
    max_steps=5, 
    verbosity_level=1,
    prompt_templates=prompt_templates
)

# Interface Gráfica
# Lança a interface Gradio para interagir com o agente.
GradioUI(agent).launch()