File size: 2,528 Bytes
7123080
7a87f10
 
ae5e9eb
7123080
 
7a87f10
7123080
 
ae5e9eb
7123080
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ae5e9eb
7123080
ae5e9eb
7123080
 
 
 
 
 
 
ae5e9eb
7123080
 
 
 
ae5e9eb
7123080
 
 
 
7a87f10
7123080
ae5e9eb
7123080
 
7a87f10
27dfb79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a87f10
27dfb79
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
71
72
73
74
75
76
77
78
79
from crewai import Agent, Task, Crew, LLM
import gradio as gr

def criar_crew(tema):
    
    groq_llm = LLM(model="groq/llama-3.3-70b-versatile")

    pesquisador = Agent(
        role="Pesquisador",
        goal="Buscar informações detalhadas sobre o assunto informado.",
        backstory="Um especialista em coleta de dados e análise de informações.",
        llm=groq_llm
    )
    redator = Agent(
        role="Redator",
        goal="Resumir as informações encontradas e criar um relatório.",
        backstory="Um redator experiente que transforma dados em textos claros.",
        llm=groq_llm
    )
    latex = Agent(
        role="Latex",
        goal="Crie um documento Latex.",
        backstory="Um criador de documentos Latex.",
        llm=groq_llm
    )
    tarefa_pesquisa = Task(
        description="Pesquise informações detalhadas sobre {}.".format(tema),
        agent=pesquisador,
        expected_output='Informações corretas e detalhadas sobre o assunto informado'
    )
    tarefa_redacao = Task(
        description="Com base nas informações fornecidas pelo pesquisador, crie um resumo claro e objetivo.",
        agent=redator,
        expected_output='Resumo claro e objetivo'
    )
    tarefa_latex = Task(
        description="Com base no resumo, crie um documento latex.",
        agent=latex,
        expected_output='Um documento Latex'
    )
    equipe = Crew(
        agents=[pesquisador, redator, latex],
        tasks=[tarefa_pesquisa, tarefa_redacao, tarefa_latex]
    )
    
    return equipe

def executar_crew(entrada):
    equipe = criar_crew(entrada)
    resultado = equipe.kickoff()
    return resultado

def interface_fn(tema):
    return executar_crew(tema)

principal = gr.Interface(
    fn=interface_fn,
    inputs=gr.Textbox(label="Informe o tema"),
    outputs=gr.Textbox(label="Saída documento no formato Latex", show_copy_button=True),
    title="Pesquisa e Relatório em Latex",
    description="Clique no botão para executar três agentes que irão pesquisar e criar um relatório em latex sobre o tema informado.",
    examples=[["Mudanças Climáticas"], ["Inteligência Artificial"], ["Economia Global"]],
)

arquitetura = gr.Blocks()

with arquitetura:
    gr.Markdown("## Arquitetura do Sistema")
    gr.Image(
        value="diagrama.png",
        label="Arquitetura interna dos agentes",
        interactive=False
    )

demo = gr.TabbedInterface([principal, arquitetura], ["Principal", "Arquitetura"])

if __name__ == "__main__":
    demo.launch()