Merge pull request #39 from Madhuvod/ai-startup-agency
project #4 - AI Startup org agency with Agency Swarm Framework
This commit is contained in:
commit
cf09119390
3 changed files with 410 additions and 0 deletions
84
ai_agent_tutorials/ai_startup_org_agents/README.md
Normal file
84
ai_agent_tutorials/ai_startup_org_agents/README.md
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
# AI Startup Services Agency 🚀
|
||||
|
||||
An intelligent multi-agent system that provides comprehensive startup analysis and strategic guidance for a startup you'd want to build using Agency Swarm framework and OpenAI's GPT models
|
||||
|
||||
## Demo:
|
||||
|
||||
|
||||
|
||||
https://github.com/user-attachments/assets/a0befa3a-f4c3-400d-9790-4b9e37254405
|
||||
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
### 🤖 Agency Swarm Agents
|
||||
|
||||
- **CEO Agent**: Strategic leader and final decision maker
|
||||
- Analyzes startup ideas using structured evaluation
|
||||
- Makes strategic decisions across product, technical, marketing, and financial domains
|
||||
- Uses AnalyzeStartupTool and MakeStrategicDecision tools
|
||||
|
||||
- **CTO Agent**: Technical architecture and feasibility expert
|
||||
- Evaluates technical requirements and feasibility
|
||||
- Provides architecture decisions
|
||||
- Uses QueryTechnicalRequirements and EvaluateTechnicalFeasibility tools
|
||||
|
||||
- **Product Manager Agent**: Product strategy specialist
|
||||
- Defines product strategy and roadmap
|
||||
- Coordinates between technical and marketing teams
|
||||
- Focuses on product-market fit
|
||||
|
||||
- **Developer Agent**: Technical implementation expert
|
||||
- Provides detailed technical implementation guidance
|
||||
- Suggests optimal tech stack and cloud solutions
|
||||
- Estimates development costs and timelines
|
||||
|
||||
- **Client Success Agent**: Marketing strategy leader
|
||||
- Develops go-to-market strategies
|
||||
- Plans customer acquisition approaches
|
||||
- Coordinates with product team
|
||||
|
||||
### Custom Tools
|
||||
|
||||
The agency uses specialized tools built with OpenAI Schema for structured analysis:
|
||||
- **Analysis Tools**: AnalyzeProjectRequirements for market evaluation and analysis of startup idea
|
||||
- **Technical Tools**: CreateTechnicalSpecification for technical assessment
|
||||
|
||||
### 🔄 Asynchronous Communication
|
||||
|
||||
The agency operates in async mode, enabling:
|
||||
- Parallel processing of analyses from different agents
|
||||
- Efficient multi-agent collaboration
|
||||
- Real-time communication between agents
|
||||
- Non-blocking operations for better performance
|
||||
|
||||
### 🔗 Agent Communication Flows
|
||||
- CEO ↔️ All Agents (Strategic Oversight)
|
||||
- CTO ↔️ Developer (Technical Implementation)
|
||||
- Product Manager ↔️ Marketing Manager (Go-to-Market Strategy)
|
||||
- Product Manager ↔️ Developer (Feature Implementation)
|
||||
- (and more!)
|
||||
|
||||
## How to Run
|
||||
|
||||
Follow the steps below to set up and run the application:
|
||||
Before anything else, Please get your OpenAI API Key here: https://platform.openai.com/api-keys
|
||||
|
||||
1. **Clone the Repository**:
|
||||
```bash
|
||||
git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
|
||||
cd ai_agent_tutorials
|
||||
```
|
||||
|
||||
2. **Install the dependencies**:
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
3. **Run the Streamlit app**:
|
||||
```bash
|
||||
streamlit run ai_startup_org_agents/agency.py
|
||||
```
|
||||
|
||||
4. **Enter your OpenAI API Key** in the sidebar when prompted and start analyzing your startup idea!
|
||||
323
ai_agent_tutorials/ai_startup_org_agents/agency.py
Normal file
323
ai_agent_tutorials/ai_startup_org_agents/agency.py
Normal file
|
|
@ -0,0 +1,323 @@
|
|||
from typing import List, Literal, Dict, Optional
|
||||
from agency_swarm import Agent, Agency, set_openai_key, BaseTool
|
||||
from pydantic import Field
|
||||
import streamlit as st
|
||||
from instructor import OpenAISchema
|
||||
import asyncio
|
||||
|
||||
# Tools
|
||||
class AnalyzeProjectRequirements(BaseTool):
|
||||
"""Tool for comprehensive project analysis"""
|
||||
project_description: str = Field(..., description="Client's project description")
|
||||
business_requirements: str = Field(..., description="Business requirements and goals")
|
||||
budget_constraints: Optional[str] = Field(None, description="Budget constraints if any")
|
||||
|
||||
def run(self):
|
||||
prompt = f"""
|
||||
Analyze this project request:
|
||||
Project: {self.project_description}
|
||||
Business Requirements: {self.business_requirements}
|
||||
Budget Constraints: {self.budget_constraints}
|
||||
|
||||
Provide a comprehensive analysis including:
|
||||
1. Project scope and complexity
|
||||
2. Estimated timeline
|
||||
3. Key deliverables
|
||||
4. Technical requirements
|
||||
5. Potential challenges
|
||||
"""
|
||||
return self._llm.invoke(prompt)
|
||||
|
||||
class CreateTechnicalSpecification(BaseTool):
|
||||
"""Tool for creating detailed technical specifications"""
|
||||
requirements: str = Field(..., description="Project requirements")
|
||||
tech_context: Optional[str] = Field(None, description="Additional technical context")
|
||||
|
||||
def run(self):
|
||||
prompt = f"""
|
||||
Create technical specifications for:
|
||||
Requirements: {self.requirements}
|
||||
Technical Context: {self.tech_context or 'None provided'}
|
||||
|
||||
Provide detailed technical analysis including:
|
||||
1. Architecture type and patterns
|
||||
2. Core technologies and frameworks
|
||||
3. API requirements
|
||||
4. Database design
|
||||
5. Security requirements
|
||||
6. Scalability considerations
|
||||
7. Development effort estimation
|
||||
"""
|
||||
return self._llm.invoke(prompt)
|
||||
|
||||
def init_session_state() -> None:
|
||||
"""Initialize session state variables"""
|
||||
if 'messages' not in st.session_state:
|
||||
st.session_state.messages = []
|
||||
if 'api_key' not in st.session_state:
|
||||
st.session_state.api_key = None
|
||||
|
||||
def main() -> None:
|
||||
st.set_page_config(page_title="AI Services Agency", layout="wide")
|
||||
init_session_state()
|
||||
|
||||
st.title("🚀 AI Services Agency")
|
||||
|
||||
# API Configuration
|
||||
with st.sidebar:
|
||||
st.header("🔑 API Configuration")
|
||||
openai_api_key = st.text_input(
|
||||
"OpenAI API Key",
|
||||
type="password",
|
||||
help="Enter your OpenAI API key to continue"
|
||||
)
|
||||
|
||||
if openai_api_key:
|
||||
st.session_state.api_key = openai_api_key
|
||||
st.success("API Key accepted!")
|
||||
else:
|
||||
st.warning("⚠️ Please enter your OpenAI API Key to proceed")
|
||||
st.markdown("[Get your API key here](https://platform.openai.com/api-keys)")
|
||||
return
|
||||
|
||||
# Initialize agents with the provided API key
|
||||
set_openai_key(st.session_state.api_key)
|
||||
api_headers = {"Authorization": f"Bearer {st.session_state.api_key}"}
|
||||
|
||||
# Project Input Form
|
||||
with st.form("project_form"):
|
||||
st.subheader("Project Details")
|
||||
|
||||
project_name = st.text_input("Project Name")
|
||||
project_description = st.text_area(
|
||||
"Project Description",
|
||||
help="Describe the project, its goals, and any specific requirements"
|
||||
)
|
||||
|
||||
col1, col2 = st.columns(2)
|
||||
with col1:
|
||||
project_type = st.selectbox(
|
||||
"Project Type",
|
||||
["Web Application", "Mobile App", "API Development",
|
||||
"Data Analytics", "AI/ML Solution", "Other"]
|
||||
)
|
||||
timeline = st.selectbox(
|
||||
"Expected Timeline",
|
||||
["1-2 months", "3-4 months", "5-6 months", "6+ months"]
|
||||
)
|
||||
|
||||
with col2:
|
||||
budget_range = st.selectbox(
|
||||
"Budget Range",
|
||||
["$10k-$25k", "$25k-$50k", "$50k-$100k", "$100k+"]
|
||||
)
|
||||
priority = st.selectbox(
|
||||
"Project Priority",
|
||||
["High", "Medium", "Low"]
|
||||
)
|
||||
|
||||
tech_requirements = st.text_area(
|
||||
"Technical Requirements (optional)",
|
||||
help="Any specific technical requirements or preferences"
|
||||
)
|
||||
|
||||
special_considerations = st.text_area(
|
||||
"Special Considerations (optional)",
|
||||
help="Any additional information or special requirements"
|
||||
)
|
||||
|
||||
submitted = st.form_submit_button("Analyze Project")
|
||||
|
||||
if submitted and project_name and project_description:
|
||||
try:
|
||||
# Set OpenAI key
|
||||
set_openai_key(st.session_state.api_key)
|
||||
|
||||
# Create agents
|
||||
ceo = Agent(
|
||||
name="Project Director",
|
||||
description="Experienced project director with expertise in technical project evaluation.",
|
||||
instructions="""
|
||||
- Lead project analysis and strategic planning
|
||||
- Evaluate project feasibility and resource requirements
|
||||
- Make high-level decisions on project direction
|
||||
""",
|
||||
tools=[AnalyzeProjectRequirements],
|
||||
api_headers=api_headers,
|
||||
temperature=0.7,
|
||||
max_prompt_tokens=25000
|
||||
)
|
||||
|
||||
cto = Agent(
|
||||
name="Technical Architect",
|
||||
description="Senior technical architect with deep expertise in system design.",
|
||||
instructions="""
|
||||
- Design technical architecture and evaluate feasibility
|
||||
- Make technology stack recommendations
|
||||
- Review technical specifications
|
||||
""",
|
||||
tools=[CreateTechnicalSpecification],
|
||||
api_headers=api_headers,
|
||||
temperature=0.5,
|
||||
max_prompt_tokens=25000
|
||||
)
|
||||
|
||||
product_manager = Agent(
|
||||
name="Product Manager",
|
||||
description="Experienced product manager focused on delivery excellence.",
|
||||
instructions="""
|
||||
- Manage project scope and timeline
|
||||
- Define product requirements
|
||||
- Ensure product quality
|
||||
""",
|
||||
api_headers=api_headers,
|
||||
temperature=0.4,
|
||||
max_prompt_tokens=25000
|
||||
)
|
||||
|
||||
developer = Agent(
|
||||
name="Lead Developer",
|
||||
description="Senior developer with full-stack expertise.",
|
||||
instructions="""
|
||||
- Plan technical implementation
|
||||
- Provide effort estimates
|
||||
- Review technical feasibility
|
||||
""",
|
||||
api_headers=api_headers,
|
||||
temperature=0.3,
|
||||
max_prompt_tokens=25000
|
||||
)
|
||||
|
||||
client_manager = Agent(
|
||||
name="Client Success Manager",
|
||||
description="Experienced client manager focused on project delivery.",
|
||||
instructions="""
|
||||
- Ensure client satisfaction
|
||||
- Manage expectations
|
||||
- Handle feedback
|
||||
""",
|
||||
api_headers=api_headers,
|
||||
temperature=0.6,
|
||||
max_prompt_tokens=25000
|
||||
)
|
||||
|
||||
# Create agency
|
||||
agency = Agency(
|
||||
[
|
||||
ceo, cto, product_manager, developer, client_manager,
|
||||
[ceo, cto],
|
||||
[ceo, product_manager],
|
||||
[ceo, developer],
|
||||
[ceo, client_manager],
|
||||
[cto, developer],
|
||||
[product_manager, developer],
|
||||
[product_manager, client_manager]
|
||||
],
|
||||
async_mode='threading',
|
||||
shared_files='shared_files'
|
||||
)
|
||||
|
||||
# Prepare project info
|
||||
project_info = {
|
||||
"name": project_name,
|
||||
"description": project_description,
|
||||
"type": project_type,
|
||||
"timeline": timeline,
|
||||
"budget": budget_range,
|
||||
"priority": priority,
|
||||
"technical_requirements": tech_requirements,
|
||||
"special_considerations": special_considerations
|
||||
}
|
||||
|
||||
st.session_state.messages.append({"role": "user", "content": str(project_info)})
|
||||
# Create tabs and run analysis
|
||||
with st.spinner("AI Services Agency is analyzing your project..."):
|
||||
try:
|
||||
# Get analysis from each agent using agency.get_completion()
|
||||
ceo_response = agency.get_completion(
|
||||
message=f"Analyze this project proposal: {str(project_info)}",
|
||||
recipient_agent=ceo,
|
||||
additional_instructions="Provide a strategic analysis of the project using the AnalyzeProjectRequirements tool to make best possible strategic decisions for the project."
|
||||
|
||||
)
|
||||
|
||||
cto_response = agency.get_completion(
|
||||
message=f"Analyze technical requirements: {str(project_info)}",
|
||||
recipient_agent=cto,
|
||||
additional_instructions="Evaluate technical feasibility using CreateTechnicalSpecification tool, eventually building a scalable and efficient tech product for the startup."
|
||||
)
|
||||
|
||||
pm_response = agency.get_completion(
|
||||
message=f"Analyze project management aspects: {str(project_info)}",
|
||||
recipient_agent=product_manager,
|
||||
additional_instructions="Focus on product-market fit and roadmap development, and coordinate with technical and marketing teams."
|
||||
)
|
||||
|
||||
developer_response = agency.get_completion(
|
||||
message=f"Analyze technical implementation based on CTO's specifications: {str(project_info)}",
|
||||
recipient_agent=developer,
|
||||
additional_instructions="Provide technical implementation details, optimal tech stack you would be using including the costs of cloud services (if any) and feasibility feedback, and coordinate with product manager and CTO to build the required products for the startup."
|
||||
)
|
||||
|
||||
client_response = agency.get_completion(
|
||||
message=f"Analyze client success aspects: {str(project_info)}",
|
||||
recipient_agent=client_manager,
|
||||
additional_instructions="Provide detailed go-to-market strategy and customer acquisition plan, and coordinate with product manager."
|
||||
)
|
||||
|
||||
# Create tabs for different analyses
|
||||
tabs = st.tabs([
|
||||
"CEO's Project Analysis",
|
||||
"CTO's Technical Specification",
|
||||
"Product Manager's Plan",
|
||||
"Developer's Implementation",
|
||||
"Client Success Strategy"
|
||||
])
|
||||
|
||||
with tabs[0]:
|
||||
st.markdown("## CEO's Strategic Analysis")
|
||||
st.markdown(ceo_response)
|
||||
st.session_state.messages.append({"role": "assistant", "content": ceo_response})
|
||||
|
||||
with tabs[1]:
|
||||
st.markdown("## CTO's Technical Specification")
|
||||
st.markdown(cto_response)
|
||||
st.session_state.messages.append({"role": "assistant", "content": cto_response})
|
||||
|
||||
with tabs[2]:
|
||||
st.markdown("## Product Manager's Plan")
|
||||
st.markdown(pm_response)
|
||||
st.session_state.messages.append({"role": "assistant", "content": pm_response})
|
||||
|
||||
with tabs[3]:
|
||||
st.markdown("## Lead Developer's Development Plan")
|
||||
st.markdown(developer_response)
|
||||
st.session_state.messages.append({"role": "assistant", "content": developer_response})
|
||||
|
||||
with tabs[4]:
|
||||
st.markdown("## Client Success Strategy")
|
||||
st.markdown(client_response)
|
||||
st.session_state.messages.append({"role": "assistant", "content": client_response})
|
||||
|
||||
except Exception as e:
|
||||
st.error(f"Error during analysis: {str(e)}")
|
||||
st.error("Please check your inputs and API key and try again.")
|
||||
|
||||
except Exception as e:
|
||||
st.error(f"Error during analysis: {str(e)}")
|
||||
st.error("Please check your API key and try again.")
|
||||
|
||||
# Add history management in sidebar
|
||||
with st.sidebar:
|
||||
st.subheader("Options")
|
||||
if st.checkbox("Show Analysis History"):
|
||||
for message in st.session_state.messages:
|
||||
with st.chat_message(message["role"]):
|
||||
st.markdown(message["content"])
|
||||
|
||||
if st.button("Clear History"):
|
||||
st.session_state.messages = []
|
||||
st.rerun()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
python-dotenv==1.0.0
|
||||
agency-swarm==0.4.1
|
||||
streamlit
|
||||
Loading…
Reference in a new issue