File size: 6,519 Bytes
18ba7f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import streamlit as st
import os
import yaml
from crewai import LLM
from agents import *

# Streamlit Page Config
st.set_page_config(
    page_title = "Project Planner", 
    page_icon = "๐Ÿ› ๏ธ", 
    layout = "wide",
    initial_sidebar_state = "expanded")

# Logo
st.logo(
    "https://cdn.prod.website-files.com/66cf2bfc3ed15b02da0ca770/66d07240057721394308addd_Logo%20(1).svg",
    link = "https://www.crewai.com/",
    size = "large"
)

col1, col2, col3 = st.columns([1, 9, 1])
with col2:
    # Title and description
    st.title("AI Project Planner, powered by :red[CrewAI]")
    st.markdown("Create an detailed project plan with resource allocation and a timeline for tasks and milestones using AI agents.")
    
# Sidebar
with st.sidebar:
    st.markdown("### โš™๏ธ Model API Configuration")
    st.write("")
    
    model_options = [
        "gpt-4o-mini",
        "gpt-4o",
        "o1",
        "o1-mini", 
        "o1-preview"
        "o3-mini"
    ]
    
    selected_model = st.selectbox("๐Ÿค– Select which LLM to use", model_options, key = "selected_model")
    
    with st.expander("๐Ÿ”‘ API Keys", expanded = True):
        
        st.info("API keys are stored temporarily in memory and cleared when you close the browser.")
        
        openai_api_key = st.text_input(
            "OpenAI API Key",
            type = "password",
            placeholder = "Enter your OpenAI API key",
            help = "Enter your OpenAI API key"
        )
        
        if openai_api_key:
            os.environ["OPENAI_API_KEY"] = openai_api_key
            
        # serper_api_key = st.text_input(
        #     "Serper API Key",
        #     type = "password",
        #     placeholder = "Enter your Serper API key",
        #     help = "Enter your Serper API key for web search capabilities"
        #     )
        # if serper_api_key:
        #     os.environ["SERPER_API_KEY"] = serper_api_key
    
    st.write("")
    
    with st.expander("โ„น๏ธ About", expanded=False):
        st.markdown(
            """This Project Planner uses advanced AI Agents to help you:

                - Strategically think and breakdown projects into actionable tasks and setting precise timelines.

                - Provide highly accurate time, resource, and effort estimations for each task.

                - Optimize the allocation of tasks for the project by balancing team members' skills, availability, and current workload.

                

                Choose your preferred model and enter the required API keys to get started.""")
        
if not os.environ.get("OPENAI_API_KEY"):
    st.warning("โš ๏ธ Please enter your OpenAI API key in the sidebar to get started")
    st.stop()

# if not os.environ.get("SERPER_API_KEY"):
#     st.warning("โš ๏ธ Please enter your Serper API key in the sidebar to get started")
#     st.stop()

# Define file paths for YAML configurations
files = {
    'agents': 'config/agents.yaml',
    'tasks': 'config/tasks.yaml'
}

# Load configurations from YAML files
configs = {}
for config_type, file_path in files.items():
    with open(file_path, 'r') as file:
        configs[config_type] = yaml.safe_load(file)

# Assign loaded configurations to specific variables
agents_config = configs['agents']
tasks_config = configs['tasks']

llm = llm = LLM(model = f"openai/{selected_model}")
planner_crew = ProjectPlanner(agents_config, tasks_config, llm)    

# Create two columns for the input section
input_col1, input_col2, input_col3 = st.columns([3, 3, 5])

with input_col1:
    project_topic = st.text_area(
        "Project Topic",
        height = 80,
        placeholder = "Enter the project topic (eg Website, Hiring, Building)"                
    )

with input_col2:
    industry = st.text_area(
        "Industry",
        height = 80,
        placeholder = "Enter the industry (eg Technology, Finance, Construction)"                
    )

with input_col3:
    objective = st.text_area(
        "Project Objective",
        height = 80,
        placeholder = "Enter the project objective (eg Build a website for a small business)"                
    )
    
input_col4, input_col5 = st.columns([3,2])

with input_col4:
    project_requirements = st.text_area(
        "Project Requirements (Brief bullet points)",
        height = 190,
        placeholder = """Enter bullet points of project requirements.

        eg: 

        - Create a responsive design that works well on desktop and mobile devices

        - Implement a modern, visually appealing user interface with a clean look

        - Develop a user-friendly navigation system with intuitive menu structure

        - Include an "About Us" page highlighting the company's history and values

        - Design a "Services" page showcasing the business's offerings with descriptions"""
    )
    
with input_col5:
    team_members = st.text_area(
        "Team Members",
        height = 190,
        placeholder = """Enter the Team Member names are their roles.

        eg:

        - John Doe (Project Manager)

        - Jane Doe (Software Engineer)

        - Bob Smith (Designer)

        - Alice Johnson (QA Engineer)

        - Tom Brown (QA Engineer)

        """
    )
    
generate_button = st.button("๐Ÿš€ Plan My Project", use_container_width = False, type = "primary")

if generate_button:
    with st.spinner("Generating content... This may take a moment."):
        try:
            project_details = {
                'project_type': project_topic,
                'project_objectives': objective,
                'industry': industry,
                'team_members': team_members,
                'project_requirements': project_requirements
                }
            df_tasks, df_milestones = planner_crew.getPlanning(project_details)

        except Exception as e:
            st.error(f"An error occurred: {str(e)}")
    
    st.markdown("## Task Breakdown:")
    st.dataframe(df_tasks)
    
    st.divider()
    
    st.markdown("## Milestone Details")
    st.dataframe(df_milestones)    
    



# Add footer
st.divider()
footer_col1, footer_col2, footer_col3 = st.columns([1, 2, 1])
with footer_col2:
    st.caption("Made with โค๏ธ using [CrewAI](https://crewai.com) and [Streamlit](https://streamlit.io)")
    st.caption("By [Sharan Shyamsundar](http://sharan1712.github.io/)")