File size: 2,791 Bytes
c43e87e
 
3a8748c
c43e87e
3a8748c
 
 
 
c43e87e
 
 
 
 
 
3a8748c
c43e87e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a8748c
c43e87e
3a8748c
c43e87e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a8748c
 
 
c43e87e
3a8748c
c43e87e
 
 
 
 
3a8748c
c43e87e
 
3a8748c
c43e87e
 
 
 
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
80
81
82
83
84
from crewai import Agent, Task, Crew, LLM
import gradio as gr
import os



def create_crew(topic):
    """Creates a CrewAI team with specialized agents for any research topic."""
    
    llm_model = LLM(model="groq/llama-3.3-70b-versatile")
    
    # Researcher Agent
    researcher = Agent(
        role="Researcher",
        goal=f"Gather comprehensive and accurate information on the topic: {topic}.",
        backstory="An expert in data collection, analysis, and extracting insights from various sources.",
        llm=llm_model
    )
    
    # Writer Agent
    writer = Agent(
        role="Writer",
        goal="Summarize research findings into a well-structured and coherent report.",
        backstory="A seasoned writer with expertise in transforming raw information into clear and concise text.",
        llm=llm_model
    )
    
    # LaTeX Document Creator Agent
    latex_creator = Agent(
        role="LaTeX Document Creator",
        goal="Convert the summarized report into a well-formatted LaTeX document.",
        backstory="A skilled document formatter who ensures professional presentation in LaTeX.",
        llm=llm_model
    )
    
    # Research Task
    research_task = Task(
        description=f"Conduct in-depth research on {topic}.",
        agent=researcher,
        expected_output=f'Detailed and accurate information on {topic}.'
    )
    
    # Writing Task
    writing_task = Task(
        description="Based on the research findings, generate a concise and well-structured summary.",
        agent=writer,
        expected_output='A clear and structured summary of the research findings.'
    )
    
    # LaTeX Document Creation Task
    latex_task = Task(
        description="Transform the research summary into a properly formatted LaTeX document.",
        agent=latex_creator,
        expected_output='A LaTeX document containing the summarized research.'
    )
    
    # Assemble the Crew
    crew_team = Crew(
        agents=[researcher, writer, latex_creator],
        tasks=[research_task, writing_task, latex_task]
    )
    
    return crew_team

def execute_crew(input_text):
    """Executes the CrewAI workflow for the given topic."""
    print("Executing CrewAI with input:", input_text)
    crew_team = create_crew(input_text)
    result = crew_team.kickoff()
    print("CrewAI Output:", result)
    return result

# Gradio Interface
interface = gr.Interface(
    fn=execute_crew,
    inputs=gr.Text(value="Enter a topic for research", interactive=True, placeholder="e.g., Quantum Computing"),
    outputs="text",
    title="Crew AI - Research and LaTeX Report Generator",
    description="Enter any topic, and the AI team will research and generate a LaTeX report based on it."
)

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