Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from crewai import Agent, Task, Crew, LLM
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
def create_crew():
|
5 |
+
"""Creates a CrewAI team with specialized agents."""
|
6 |
+
|
7 |
+
llm_model = LLM(model="groq/llama-3.3-70b-versatile")
|
8 |
+
|
9 |
+
# Researcher Agent
|
10 |
+
researcher = Agent(
|
11 |
+
role="Researcher",
|
12 |
+
goal="Gather comprehensive and accurate information on a given topic.",
|
13 |
+
backstory="An expert in data collection, analysis, and extracting insights from various sources.",
|
14 |
+
llm=llm_model
|
15 |
+
)
|
16 |
+
|
17 |
+
# Writer Agent
|
18 |
+
writer = Agent(
|
19 |
+
role="Writer",
|
20 |
+
goal="Summarize research findings into a well-structured and coherent report.",
|
21 |
+
backstory="A seasoned writer with expertise in transforming raw information into clear and concise text.",
|
22 |
+
llm=llm_model
|
23 |
+
)
|
24 |
+
|
25 |
+
# LaTeX Document Creator Agent
|
26 |
+
latex_creator = Agent(
|
27 |
+
role="LaTeX Document Creator",
|
28 |
+
goal="Convert the summarized report into a well-formatted LaTeX document.",
|
29 |
+
backstory="A skilled document formatter who ensures professional presentation in LaTeX.",
|
30 |
+
llm=llm_model
|
31 |
+
)
|
32 |
+
|
33 |
+
# Research Task
|
34 |
+
research_task = Task(
|
35 |
+
description="Conduct in-depth research on Machine Learning for effort estimation.",
|
36 |
+
agent=researcher,
|
37 |
+
expected_output='Detailed and accurate information on Machine Learning in effort estimation.'
|
38 |
+
)
|
39 |
+
|
40 |
+
# Writing Task
|
41 |
+
writing_task = Task(
|
42 |
+
description="Based on the research findings, generate a concise and well-structured summary.",
|
43 |
+
agent=writer,
|
44 |
+
expected_output='A clear and structured summary of the research findings.'
|
45 |
+
)
|
46 |
+
|
47 |
+
# LaTeX Document Creation Task
|
48 |
+
latex_task = Task(
|
49 |
+
description="Transform the research summary into a properly formatted LaTeX document.",
|
50 |
+
agent=latex_creator,
|
51 |
+
expected_output='A LaTeX document containing the summarized research.'
|
52 |
+
)
|
53 |
+
|
54 |
+
# Assemble the Crew
|
55 |
+
crew_team = Crew(
|
56 |
+
agents=[researcher, writer, latex_creator],
|
57 |
+
tasks=[research_task, writing_task, latex_task]
|
58 |
+
)
|
59 |
+
|
60 |
+
return crew_team
|
61 |
+
|
62 |
+
def execute_crew(input_text):
|
63 |
+
"""Executes the CrewAI workflow."""
|
64 |
+
crew_team = create_crew()
|
65 |
+
result = crew_team.kickoff()
|
66 |
+
return result
|
67 |
+
|
68 |
+
# Gradio Interface
|
69 |
+
interface = gr.Interface(
|
70 |
+
fn=execute_crew,
|
71 |
+
inputs=gr.Text(value="Conduct in-depth research on Machine Learning for effort estimation.", interactive=False),
|
72 |
+
outputs="text",
|
73 |
+
title="Crew AI - Research and LaTeX Report Generator",
|
74 |
+
description="Click the button to execute the AI team that will research and generate a LaTeX report on Machine Learning for effort estimation."
|
75 |
+
)
|
76 |
+
|
77 |
+
if __name__ == "__main__":
|
78 |
+
interface.launch()
|