Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- agents.py +50 -0
- app.py +190 -0
- config/agents.yaml +49 -0
- config/tasks.yaml +47 -0
agents.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
from typing import List
|
| 3 |
+
from pydantic import BaseModel, Field
|
| 4 |
+
from crewai import Agent, Task, Crew
|
| 5 |
+
|
| 6 |
+
class TaskEstimate(BaseModel):
|
| 7 |
+
task_name: str = Field(..., description="Name of the task")
|
| 8 |
+
estimated_time_hours: float = Field(..., description = "Estimated time to complete the task in hours")
|
| 9 |
+
required_resources: List[str] = Field(..., description = "List of resources required to complete the task")
|
| 10 |
+
|
| 11 |
+
class Milestone(BaseModel):
|
| 12 |
+
milestone_name: str = Field(..., description = "Name of the milestone")
|
| 13 |
+
tasks: List[str] = Field(..., description = "List of task IDs associated with this milestone")
|
| 14 |
+
|
| 15 |
+
class ProjectPlan(BaseModel):
|
| 16 |
+
tasks: List[TaskEstimate] = Field(..., description = "List of tasks with their estimates")
|
| 17 |
+
milestones: List[Milestone] = Field(..., description = "List of project milestones")
|
| 18 |
+
|
| 19 |
+
class ProjectPlanner:
|
| 20 |
+
|
| 21 |
+
def __init__(self, agents_config, tasks_config, llm):
|
| 22 |
+
|
| 23 |
+
# Creating Agents
|
| 24 |
+
project_planning_agent = Agent(config = agents_config['project_planning_agent'], llm = llm)
|
| 25 |
+
estimation_agent = Agent(config = agents_config['estimation_agent'], llm = llm)
|
| 26 |
+
resource_allocation_agent = Agent(config = agents_config['resource_allocation_agent'], llm = llm)
|
| 27 |
+
|
| 28 |
+
# Creating Tasks
|
| 29 |
+
task_breakdown = Task(config = tasks_config['task_breakdown'], agent = project_planning_agent)
|
| 30 |
+
time_resource_estimation = Task(config = tasks_config['time_resource_estimation'], agent = estimation_agent)
|
| 31 |
+
resource_allocation = Task(config = tasks_config['resource_allocation'], agent = resource_allocation_agent,
|
| 32 |
+
output_pydantic = ProjectPlan # This is the structured output we want
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
# Creating Crew
|
| 36 |
+
self.crew = Crew(
|
| 37 |
+
agents = [project_planning_agent, estimation_agent, resource_allocation_agent],
|
| 38 |
+
tasks = [task_breakdown, time_resource_estimation, resource_allocation],
|
| 39 |
+
verbose = True
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
def getPlanning(self, project_details):
|
| 43 |
+
|
| 44 |
+
results = self.crew.kickoff(inputs = project_details)
|
| 45 |
+
task_breakdown = results.pydantic.model_dump()['tasks']
|
| 46 |
+
df_tasks = pd.DataFrame(task_breakdown)
|
| 47 |
+
milestones = results.pydantic.model_dump()['milestones']
|
| 48 |
+
df_milestones = pd.DataFrame(milestones)
|
| 49 |
+
|
| 50 |
+
return df_tasks, df_milestones
|
app.py
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
import yaml
|
| 4 |
+
from crewai import LLM
|
| 5 |
+
from agents import *
|
| 6 |
+
|
| 7 |
+
# Streamlit Page Config
|
| 8 |
+
st.set_page_config(
|
| 9 |
+
page_title = "Project Planner",
|
| 10 |
+
page_icon = "🛠️",
|
| 11 |
+
layout = "wide",
|
| 12 |
+
initial_sidebar_state = "expanded")
|
| 13 |
+
|
| 14 |
+
# Logo
|
| 15 |
+
st.logo(
|
| 16 |
+
"https://cdn.prod.website-files.com/66cf2bfc3ed15b02da0ca770/66d07240057721394308addd_Logo%20(1).svg",
|
| 17 |
+
link = "https://www.crewai.com/",
|
| 18 |
+
size = "large"
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
col1, col2, col3 = st.columns([1, 9, 1])
|
| 22 |
+
with col2:
|
| 23 |
+
# Title and description
|
| 24 |
+
st.title("AI Project Planner, powered by :red[CrewAI]")
|
| 25 |
+
st.markdown("Create an detailed project plan with resource allocation and a timeline for tasks and milestones using AI agents.")
|
| 26 |
+
|
| 27 |
+
# Sidebar
|
| 28 |
+
with st.sidebar:
|
| 29 |
+
st.markdown("### ⚙️ Model API Configuration")
|
| 30 |
+
st.write("")
|
| 31 |
+
|
| 32 |
+
model_options = [
|
| 33 |
+
"gpt-4o-mini",
|
| 34 |
+
"gpt-4o",
|
| 35 |
+
"o1",
|
| 36 |
+
"o1-mini",
|
| 37 |
+
"o1-preview"
|
| 38 |
+
"o3-mini"
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
selected_model = st.selectbox("🤖 Select which LLM to use", model_options, key = "selected_model")
|
| 42 |
+
|
| 43 |
+
with st.expander("🔑 API Keys", expanded = True):
|
| 44 |
+
|
| 45 |
+
st.info("API keys are stored temporarily in memory and cleared when you close the browser.")
|
| 46 |
+
|
| 47 |
+
openai_api_key = st.text_input(
|
| 48 |
+
"OpenAI API Key",
|
| 49 |
+
type = "password",
|
| 50 |
+
placeholder = "Enter your OpenAI API key",
|
| 51 |
+
help = "Enter your OpenAI API key"
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
if openai_api_key:
|
| 55 |
+
os.environ["OPENAI_API_KEY"] = openai_api_key
|
| 56 |
+
|
| 57 |
+
# serper_api_key = st.text_input(
|
| 58 |
+
# "Serper API Key",
|
| 59 |
+
# type = "password",
|
| 60 |
+
# placeholder = "Enter your Serper API key",
|
| 61 |
+
# help = "Enter your Serper API key for web search capabilities"
|
| 62 |
+
# )
|
| 63 |
+
# if serper_api_key:
|
| 64 |
+
# os.environ["SERPER_API_KEY"] = serper_api_key
|
| 65 |
+
|
| 66 |
+
st.write("")
|
| 67 |
+
|
| 68 |
+
with st.expander("ℹ️ About", expanded=False):
|
| 69 |
+
st.markdown(
|
| 70 |
+
"""This Project Planner uses advanced AI Agents to help you:
|
| 71 |
+
- Strategically think and breakdown projects into actionable tasks and setting precise timelines.
|
| 72 |
+
- Provide highly accurate time, resource, and effort estimations for each task.
|
| 73 |
+
- Optimize the allocation of tasks for the project by balancing team members' skills, availability, and current workload.
|
| 74 |
+
|
| 75 |
+
Choose your preferred model and enter the required API keys to get started.""")
|
| 76 |
+
|
| 77 |
+
if not os.environ.get("OPENAI_API_KEY"):
|
| 78 |
+
st.warning("⚠️ Please enter your OpenAI API key in the sidebar to get started")
|
| 79 |
+
st.stop()
|
| 80 |
+
|
| 81 |
+
# if not os.environ.get("SERPER_API_KEY"):
|
| 82 |
+
# st.warning("⚠️ Please enter your Serper API key in the sidebar to get started")
|
| 83 |
+
# st.stop()
|
| 84 |
+
|
| 85 |
+
# Define file paths for YAML configurations
|
| 86 |
+
files = {
|
| 87 |
+
'agents': 'config/agents.yaml',
|
| 88 |
+
'tasks': 'config/tasks.yaml'
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
# Load configurations from YAML files
|
| 92 |
+
configs = {}
|
| 93 |
+
for config_type, file_path in files.items():
|
| 94 |
+
with open(file_path, 'r') as file:
|
| 95 |
+
configs[config_type] = yaml.safe_load(file)
|
| 96 |
+
|
| 97 |
+
# Assign loaded configurations to specific variables
|
| 98 |
+
agents_config = configs['agents']
|
| 99 |
+
tasks_config = configs['tasks']
|
| 100 |
+
|
| 101 |
+
llm = llm = LLM(model = f"openai/{selected_model}")
|
| 102 |
+
planner_crew = ProjectPlanner(agents_config, tasks_config, llm)
|
| 103 |
+
|
| 104 |
+
# Create two columns for the input section
|
| 105 |
+
input_col1, input_col2, input_col3 = st.columns([3, 3, 5])
|
| 106 |
+
|
| 107 |
+
with input_col1:
|
| 108 |
+
project_topic = st.text_area(
|
| 109 |
+
"Project Topic",
|
| 110 |
+
height = 80,
|
| 111 |
+
placeholder = "Enter the project topic (eg Website, Hiring, Building)"
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
with input_col2:
|
| 115 |
+
industry = st.text_area(
|
| 116 |
+
"Industry",
|
| 117 |
+
height = 80,
|
| 118 |
+
placeholder = "Enter the industry (eg Technology, Finance, Construction)"
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
with input_col3:
|
| 122 |
+
objective = st.text_area(
|
| 123 |
+
"Project Objective",
|
| 124 |
+
height = 80,
|
| 125 |
+
placeholder = "Enter the project objective (eg Build a website for a small business)"
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
input_col4, input_col5 = st.columns([3,2])
|
| 129 |
+
|
| 130 |
+
with input_col4:
|
| 131 |
+
project_requirements = st.text_area(
|
| 132 |
+
"Project Requirements (Brief bullet points)",
|
| 133 |
+
height = 190,
|
| 134 |
+
placeholder = """Enter bullet points of project requirements.
|
| 135 |
+
eg:
|
| 136 |
+
- Create a responsive design that works well on desktop and mobile devices
|
| 137 |
+
- Implement a modern, visually appealing user interface with a clean look
|
| 138 |
+
- Develop a user-friendly navigation system with intuitive menu structure
|
| 139 |
+
- Include an "About Us" page highlighting the company's history and values
|
| 140 |
+
- Design a "Services" page showcasing the business's offerings with descriptions"""
|
| 141 |
+
)
|
| 142 |
+
|
| 143 |
+
with input_col5:
|
| 144 |
+
team_members = st.text_area(
|
| 145 |
+
"Team Members",
|
| 146 |
+
height = 190,
|
| 147 |
+
placeholder = """Enter the Team Member names are their roles.
|
| 148 |
+
eg:
|
| 149 |
+
- John Doe (Project Manager)
|
| 150 |
+
- Jane Doe (Software Engineer)
|
| 151 |
+
- Bob Smith (Designer)
|
| 152 |
+
- Alice Johnson (QA Engineer)
|
| 153 |
+
- Tom Brown (QA Engineer)
|
| 154 |
+
"""
|
| 155 |
+
)
|
| 156 |
+
|
| 157 |
+
generate_button = st.button("🚀 Plan My Project", use_container_width = False, type = "primary")
|
| 158 |
+
|
| 159 |
+
if generate_button:
|
| 160 |
+
with st.spinner("Generating content... This may take a moment."):
|
| 161 |
+
try:
|
| 162 |
+
project_details = {
|
| 163 |
+
'project_type': project_topic,
|
| 164 |
+
'project_objectives': objective,
|
| 165 |
+
'industry': industry,
|
| 166 |
+
'team_members': team_members,
|
| 167 |
+
'project_requirements': project_requirements
|
| 168 |
+
}
|
| 169 |
+
df_tasks, df_milestones = planner_crew.getPlanning(project_details)
|
| 170 |
+
|
| 171 |
+
except Exception as e:
|
| 172 |
+
st.error(f"An error occurred: {str(e)}")
|
| 173 |
+
|
| 174 |
+
st.markdown("## Task Breakdown:")
|
| 175 |
+
st.dataframe(df_tasks)
|
| 176 |
+
|
| 177 |
+
st.divider()
|
| 178 |
+
|
| 179 |
+
st.markdown("## Milestone Details")
|
| 180 |
+
st.dataframe(df_milestones)
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
# Add footer
|
| 186 |
+
st.divider()
|
| 187 |
+
footer_col1, footer_col2, footer_col3 = st.columns([1, 2, 1])
|
| 188 |
+
with footer_col2:
|
| 189 |
+
st.caption("Made with ❤️ using [CrewAI](https://crewai.com) and [Streamlit](https://streamlit.io)")
|
| 190 |
+
st.caption("By [Sharan Shyamsundar](http://sharan1712.github.io/)")
|
config/agents.yaml
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
project_planning_agent:
|
| 2 |
+
role: >
|
| 3 |
+
The Ultimate Project Planner
|
| 4 |
+
goal: >
|
| 5 |
+
To meticulously break down the {project_type} project into
|
| 6 |
+
actionable tasks, ensuring no detail is overlooked, and setting
|
| 7 |
+
precise timelines that align with the {project_objectives}.
|
| 8 |
+
backstory: >
|
| 9 |
+
As a veteran project manager, you’ve led numerous successful
|
| 10 |
+
projects, particularly in {industry}. Your keen eye for detail
|
| 11 |
+
and strategic thinking have always ensured that projects are
|
| 12 |
+
delivered on time and within scope. Now, you're tasked with
|
| 13 |
+
planning the next groundbreaking {project_type} project.
|
| 14 |
+
allow_delegation: false
|
| 15 |
+
verbose: true
|
| 16 |
+
|
| 17 |
+
estimation_agent:
|
| 18 |
+
role: >
|
| 19 |
+
Expert Estimation Analyst
|
| 20 |
+
goal: >
|
| 21 |
+
Provide highly accurate time, resource, and effort estimations
|
| 22 |
+
for each task in the {project_type} project to ensure it is
|
| 23 |
+
delivered efficiently and on budget.
|
| 24 |
+
backstory: >
|
| 25 |
+
You are the go-to expert for project estimation in {industry}.
|
| 26 |
+
With a wealth of experience and access to vast historical data,
|
| 27 |
+
you can predict the resources required for any task with
|
| 28 |
+
remarkable accuracy.
|
| 29 |
+
Your precision ensures that the {project_type} project remains
|
| 30 |
+
feasible and avoids unnecessary delays or budget overruns.
|
| 31 |
+
allow_delegation: false
|
| 32 |
+
verbose: true
|
| 33 |
+
|
| 34 |
+
resource_allocation_agent:
|
| 35 |
+
role: >
|
| 36 |
+
Resource Allocation Strategist
|
| 37 |
+
goal: >
|
| 38 |
+
Optimize the allocation of tasks for the {project_type} project
|
| 39 |
+
by balancing team members' skills, availability, and current
|
| 40 |
+
workload to maximize efficiency and project success.
|
| 41 |
+
backstory: >
|
| 42 |
+
With a deep understanding of team dynamics and resource
|
| 43 |
+
management in {industry}, you have a track record of ensuring
|
| 44 |
+
that the right person is always assigned to the right task.
|
| 45 |
+
Your strategic thinking ensures that the {project_type} project
|
| 46 |
+
team is utilized to its full potential without overburdening
|
| 47 |
+
any individual.
|
| 48 |
+
allow_delegation: false
|
| 49 |
+
verbose: true
|
config/tasks.yaml
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
task_breakdown:
|
| 2 |
+
description: >
|
| 3 |
+
Carefully analyze the project_requirements for the {project_type}
|
| 4 |
+
project and break them down into individual tasks. Define each
|
| 5 |
+
task's scope in detail, set achievable timelines, and ensure that
|
| 6 |
+
all dependencies are accounted for:
|
| 7 |
+
|
| 8 |
+
{project_requirements}
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
Team members:
|
| 12 |
+
|
| 13 |
+
{team_members}
|
| 14 |
+
expected_output: >
|
| 15 |
+
A comprehensive list of tasks with detailed descriptions, timelines,
|
| 16 |
+
dependencies, and deliverables. Your final output MUST include a
|
| 17 |
+
Gantt chart or similar timeline visualization specific to the
|
| 18 |
+
{project_type} project.
|
| 19 |
+
|
| 20 |
+
time_resource_estimation:
|
| 21 |
+
description: >
|
| 22 |
+
Thoroughly evaluate each task in the {project_type} project to
|
| 23 |
+
estimate the time, resources, and effort required.
|
| 24 |
+
Use historical data, task complexity, and available resources to
|
| 25 |
+
provide a realistic estimation for each task.
|
| 26 |
+
expected_output: >
|
| 27 |
+
A detailed estimation report outlining the time, resources, and
|
| 28 |
+
effort required for each task in the {project_type} project.
|
| 29 |
+
Your final report MUST include a summary of any risks or
|
| 30 |
+
uncertainties associated with the estimations.
|
| 31 |
+
|
| 32 |
+
resource_allocation:
|
| 33 |
+
description: >
|
| 34 |
+
Strategically allocate tasks for the {project_type} project to
|
| 35 |
+
team members based on their skills, availability, and current
|
| 36 |
+
workload. Ensure that each task is assigned to the most suitable
|
| 37 |
+
team member and that the workload is evenly distributed.
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
Team members:
|
| 41 |
+
|
| 42 |
+
{team_members}
|
| 43 |
+
expected_output: >
|
| 44 |
+
A resource allocation chart showing which team members are
|
| 45 |
+
responsible for each task in the {project_type} project, along with
|
| 46 |
+
start and end dates. Your final output MUST also include a summary
|
| 47 |
+
explaining the rationale behind each allocation decision.
|