From 85b36f673127b5d34a514c4954a5050082a4a51a Mon Sep 17 00:00:00 2001 From: Madhu Date: Sat, 7 Dec 2024 22:06:49 +0530 Subject: [PATCH 01/10] first version - yet to change and add a few features, fix bugs --- .../ai_startup_org_agents/.gitignore | 3 + .../ai_startup_org_agents/README.md | 1 + .../ai_startup_org_agents/main.py | 271 ++++++++++++++++++ .../ai_startup_org_agents/requirements.txt | 3 + .../shared_files/agency_manifesto.md | 42 +++ .../startup_analysis_templates.md | 25 ++ 6 files changed, 345 insertions(+) create mode 100644 ai_agent_tutorials/ai_startup_org_agents/.gitignore create mode 100644 ai_agent_tutorials/ai_startup_org_agents/README.md create mode 100644 ai_agent_tutorials/ai_startup_org_agents/main.py create mode 100644 ai_agent_tutorials/ai_startup_org_agents/requirements.txt create mode 100644 ai_agent_tutorials/ai_startup_org_agents/shared_files/agency_manifesto.md create mode 100644 ai_agent_tutorials/ai_startup_org_agents/shared_files/startup_analysis_templates.md diff --git a/ai_agent_tutorials/ai_startup_org_agents/.gitignore b/ai_agent_tutorials/ai_startup_org_agents/.gitignore new file mode 100644 index 0000000..19f4d17 --- /dev/null +++ b/ai_agent_tutorials/ai_startup_org_agents/.gitignore @@ -0,0 +1,3 @@ +.env +startup-org +settings.json diff --git a/ai_agent_tutorials/ai_startup_org_agents/README.md b/ai_agent_tutorials/ai_startup_org_agents/README.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/ai_agent_tutorials/ai_startup_org_agents/README.md @@ -0,0 +1 @@ + diff --git a/ai_agent_tutorials/ai_startup_org_agents/main.py b/ai_agent_tutorials/ai_startup_org_agents/main.py new file mode 100644 index 0000000..ba4fec5 --- /dev/null +++ b/ai_agent_tutorials/ai_startup_org_agents/main.py @@ -0,0 +1,271 @@ +from typing import List, Literal +from agency_swarm import Agent, Agency, set_openai_key, BaseTool +from pydantic import Field +import streamlit as st +from instructor import OpenAISchema +import asyncio + +# New Tools +class StartupAnalysis(OpenAISchema): + """Schema for startup analysis results""" + market_potential: Literal["high", "medium", "low"] + technical_complexity: Literal["high", "medium", "low"] + resource_requirements: Literal["high", "medium", "low"] + +class AnalyzeStartupTool(BaseTool): + """Tool to analyze startup ideas""" + startup_idea: str = Field(..., description="The startup idea to analyze") + target_market: str = Field(..., description="Target market description") + + def run(self): + # Tool implementation + analysis = StartupAnalysis( + market_potential="high", + technical_complexity="medium", + resource_requirements="low" + ) + return analysis.dict() + +class MakeStrategicDecision(BaseTool): + """Tool for CEO to make and track strategic decisions""" + decision: str = Field(..., description="The strategic decision to be recorded") + decision_type: Literal["product", "technical", "marketing", "financial"] = Field(..., description="Type of decision") + + def run(self): + analysis = self._shared_state.get("startup_analysis", None) + if analysis is None: + raise ValueError("Please analyze the startup idea first using QueryStartupIdea tool.") + + return f"Decision recorded: {self.decision} (Type: {self.decision_type}) based on analysis" + +class QueryTechnicalRequirements(BaseTool): + """Tool to analyze technical requirements""" + technology_stack: str = Field(..., description="Technology stack to analyze") + + def run(self): + if self._shared_state.get("tech_analysis", None) is not None: + raise ValueError("Technical analysis already exists. Please proceed with technical evaluation.") + + tech_analysis = { + "stack": self.technology_stack, + "feasibility": "high/medium/low", + "implementation_time": "estimate in months", + "potential_challenges": ["challenge1", "challenge2"] + } + + self._shared_state.set("tech_analysis", tech_analysis) + return "Technical requirements analyzed. Please proceed with technical evaluation." + +class EvaluateTechnicalFeasibility(BaseTool): + """Tool for CTO to evaluate technical feasibility""" + evaluation: str = Field(..., description="Technical evaluation details") + feasibility_score: Literal["high", "medium", "low"] = Field(..., description="Feasibility rating") + + def run(self): + tech_analysis = self._shared_state.get("tech_analysis", None) + if tech_analysis is None: + raise ValueError("Please analyze technical requirements first using QueryTechnicalRequirements tool.") + + return f"Technical evaluation completed: {self.evaluation} (Feasibility: {self.feasibility_score})" + +# Set API key directly + + +# Simplified API headers +api_headers = { + "Authorization": f"Bearer {openai_api_key}" +} + +# Define individual agents +ceo = Agent( + name="CEO", + description="Strategic leader and final decision maker for the startup", + instructions=""" + Analyze startup ideas and make strategic decisions. + Use the AnalyzeStartupTool to evaluate new ideas. + Coordinate with team members using the built-in SendMessage tool. + """, + tools=[AnalyzeStartupTool], + temperature=0.7 +) + +cto = Agent( + name="CTO", + description="Technical leader responsible for architecture and tech decisions", + instructions="Analyze technical requirements and evaluate feasibility. Always query requirements before evaluation.", + tools=[QueryTechnicalRequirements, EvaluateTechnicalFeasibility], + temperature=0.5, + max_prompt_tokens=25000, + api_headers=api_headers +) + +product_manager = Agent( + name="Product_Manager", + description="Product strategy and roadmap owner", + instructions="Define product strategy, create roadmap, and coordinate between technical and marketing teams.", + tools=[], # No specific tools needed for initial version + temperature=0.4, + max_prompt_tokens=25000, + api_headers=api_headers +) + +developer = Agent( + name="Developer", + description="Technical implementation specialist", + instructions="You are a full stack tech expert and developer. Implement technical solutions and provide feasibility feedback.", + tools=[], # No specific tools needed for initial version + temperature=0.3, + max_prompt_tokens=25000, + api_headers=api_headers +) + +marketing_manager = Agent( + name="Marketing_Manager", + description="Marketing strategy and growth leader", + instructions="Develop marketing strategies, analyze target audience, and coordinate with Product Manager.", + tools=[], # No specific tools needed for initial version + temperature=0.6, + max_prompt_tokens=25000, + api_headers=api_headers +) + +# IN Agency Swarm, communication flows are uniform, not sequential or hierarchical. +agency = Agency( + [ + ceo, cto, product_manager, developer, marketing_manager, + [ceo, cto], + [ceo, product_manager], + [ceo, developer], + [ceo, marketing_manager], + [cto, developer], + [product_manager, developer], + [product_manager, marketing_manager] + ], + async_mode='threading', # Keep this for backward compatibility + shared_files='shared_files' +) + +# Streamlit Interface +def init_session_state(): + """Initialize Streamlit session state variables.""" + if 'messages' not in st.session_state: + st.session_state.messages = [] + +def main(): + """Main Streamlit application.""" + st.set_page_config(page_title="AI Startup Organization Assistant", layout="wide") + init_session_state() + + st.title("🚀 AI Startup Organization Assistant") + + 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 not openai_api_key: + st.warning("⚠️ Please enter your OpenAI API Key to proceed") + st.markdown("[Get your API key here](https://platform.openai.com/api-keys)") + return + + st.success("API Key accepted!") + + # Input form + with st.form("startup_form"): + startup_idea = st.text_area("Describe your startup idea") + target_audience = st.text_area("Who is your target audience?") + goals = st.text_area("What are your business goals?") + technical_requirements = st.text_area("Any specific technical requirements? (optional)") + marketing_focus = st.text_area("Any specific marketing focus? (optional)") + submitted = st.form_submit_button("Get Comprehensive Analysis") + + if submitted and startup_idea and target_audience and goals: + query = { + "startup_idea": startup_idea, + "target_audience": target_audience, + "business_goals": goals, + "technical_requirements": technical_requirements, + "marketing_focus": marketing_focus + } + + st.session_state.messages.append({"role": "user", "content": str(query)}) + + with st.spinner("AI Startup Agency is analyzing your idea..."): + try: + # Getanalysis from each agent using proper agency.get_completion() + ceo_response = agency.get_completion( + message=f"Analyze this startup idea: {str(query)}", + recipient_agent=ceo, + additional_instructions="Provide a strategic analysis of the startup idea using the AnalyzeStartupTool." + ) + + cto_response = agency.get_completion( + message=f"Analyze technical requirements: {str(query)}", + recipient_agent=cto, + additional_instructions="Evaluate technical feasibility using QueryTechnicalRequirements and EvaluateTechnicalFeasibility tools." + ) + + pm_response = agency.get_completion( + message=f"Analyze product strategy: {str(query)}", + recipient_agent=product_manager, + additional_instructions="Focus on product-market fit and roadmap development." + ) + + marketing_response = agency.get_completion( + message=f"Develop marketing strategy: {str(query)}", + recipient_agent=marketing_manager, + additional_instructions="Provide detailed go-to-market strategy and customer acquisition plan." + ) + + # Create tabs for different analyses + tabs = st.tabs(["CEO Analysis", "Technical Analysis", "Product Strategy", "Marketing Strategy"]) + + with tabs[0]: + st.markdown("## CEO's Strategic Analysis") + st.markdown(ceo_response) + + with tabs[1]: + st.markdown("## Technical Feasibility (CTO)") + st.markdown(cto_response) + + with tabs[2]: + st.markdown("## Product Strategy") + st.markdown(pm_response) + + with tabs[3]: + st.markdown("## Marketing Strategy") + st.markdown(marketing_response) + + # Store complete analysis in session state + complete_analysis = { + "ceo_analysis": ceo_response, + "technical_analysis": cto_response, + "product_strategy": pm_response, + "marketing_strategy": marketing_response + } + + st.session_state.messages.append({ + "role": "assistant", + "content": str(complete_analysis) + }) + + except Exception as e: + st.error(f"Error during analysis: {str(e)}") + st.error("Please try again or contact support.") + + 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() diff --git a/ai_agent_tutorials/ai_startup_org_agents/requirements.txt b/ai_agent_tutorials/ai_startup_org_agents/requirements.txt new file mode 100644 index 0000000..4e4c6dd --- /dev/null +++ b/ai_agent_tutorials/ai_startup_org_agents/requirements.txt @@ -0,0 +1,3 @@ +python-dotenv==1.0.0 +agency-swarm +streamlit \ No newline at end of file diff --git a/ai_agent_tutorials/ai_startup_org_agents/shared_files/agency_manifesto.md b/ai_agent_tutorials/ai_startup_org_agents/shared_files/agency_manifesto.md new file mode 100644 index 0000000..f3fd6a2 --- /dev/null +++ b/ai_agent_tutorials/ai_startup_org_agents/shared_files/agency_manifesto.md @@ -0,0 +1,42 @@ +# AI Startup Agency Manifesto + +## Our Mission +To provide comprehensive, data-driven analysis and strategic guidance for startup ideas through collaborative AI agents. + +## Agent Responsibilities + +### CEO Agent +- Lead strategic decision-making +- Coordinate between all team members +- Ensure alignment with business goals +- Make final decisions on critical matters + +### CTO Agent +- Evaluate technical feasibility +- Guide technology stack decisions +- Assess technical risks +- Collaborate with Developer on implementation plans + +### Product Manager Agent +- Define product strategy +- Create and maintain product roadmap +- Balance user needs with technical constraints +- Coordinate between technical and marketing teams + +### Developer Agent +- Provide technical implementation insights +- Assess development complexity +- Suggest technical solutions +- Work closely with CTO on feasibility + +### Marketing Manager Agent +- Develop marketing strategies +- Analyze target audience +- Plan go-to-market approach +- Work with Product Manager on market fit + +## Communication Guidelines +- All agents should communicate clearly and concisely +- Use data to support recommendations +- Highlight risks and opportunities +- Maintain focus on startup success diff --git a/ai_agent_tutorials/ai_startup_org_agents/shared_files/startup_analysis_templates.md b/ai_agent_tutorials/ai_startup_org_agents/shared_files/startup_analysis_templates.md new file mode 100644 index 0000000..c24c3bf --- /dev/null +++ b/ai_agent_tutorials/ai_startup_org_agents/shared_files/startup_analysis_templates.md @@ -0,0 +1,25 @@ +# Startup Analysis Templates + +## Market Analysis Template +- Market Size: [TAM, SAM, SOM] +- Target Customer Segments: [Primary, Secondary] +- Competition Analysis: [Direct, Indirect] +- Market Trends: [Current, Emerging] + +## Technical Feasibility Template +- Technology Stack Requirements +- Development Timeline +- Resource Requirements +- Technical Risks and Mitigations + +## Financial Analysis Template +- Initial Investment Required +- Revenue Streams +- Cost Structure +- Break-even Analysis + +## Marketing Strategy Template +- Value Proposition +- Marketing Channels +- Customer Acquisition Strategy +- Growth Metrics From a479dad3ada2ad9ecd6150ffd088fc41c90c2c92 Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 8 Dec 2024 02:39:38 +0530 Subject: [PATCH 02/10] sequential - base structute --- .../ai_startup_org_agents/main.py | 187 +++++++++--------- 1 file changed, 99 insertions(+), 88 deletions(-) diff --git a/ai_agent_tutorials/ai_startup_org_agents/main.py b/ai_agent_tutorials/ai_startup_org_agents/main.py index ba4fec5..acbdc62 100644 --- a/ai_agent_tutorials/ai_startup_org_agents/main.py +++ b/ai_agent_tutorials/ai_startup_org_agents/main.py @@ -28,7 +28,7 @@ class AnalyzeStartupTool(BaseTool): class MakeStrategicDecision(BaseTool): """Tool for CEO to make and track strategic decisions""" - decision: str = Field(..., description="The strategic decision to be recorded") + decision: str = Field(..., description="The strategic decision to be recorded and taken for this particular startup idea") decision_type: Literal["product", "technical", "marketing", "financial"] = Field(..., description="Type of decision") def run(self): @@ -40,7 +40,7 @@ class MakeStrategicDecision(BaseTool): class QueryTechnicalRequirements(BaseTool): """Tool to analyze technical requirements""" - technology_stack: str = Field(..., description="Technology stack to analyze") + technology_stack: str = Field(..., description="Scalable technology stack to analyze and implement for this startup idea") def run(self): if self._shared_state.get("tech_analysis", None) is not None: @@ -68,95 +68,20 @@ class EvaluateTechnicalFeasibility(BaseTool): return f"Technical evaluation completed: {self.evaluation} (Feasibility: {self.feasibility_score})" -# Set API key directly - - -# Simplified API headers -api_headers = { - "Authorization": f"Bearer {openai_api_key}" -} - -# Define individual agents -ceo = Agent( - name="CEO", - description="Strategic leader and final decision maker for the startup", - instructions=""" - Analyze startup ideas and make strategic decisions. - Use the AnalyzeStartupTool to evaluate new ideas. - Coordinate with team members using the built-in SendMessage tool. - """, - tools=[AnalyzeStartupTool], - temperature=0.7 -) - -cto = Agent( - name="CTO", - description="Technical leader responsible for architecture and tech decisions", - instructions="Analyze technical requirements and evaluate feasibility. Always query requirements before evaluation.", - tools=[QueryTechnicalRequirements, EvaluateTechnicalFeasibility], - temperature=0.5, - max_prompt_tokens=25000, - api_headers=api_headers -) - -product_manager = Agent( - name="Product_Manager", - description="Product strategy and roadmap owner", - instructions="Define product strategy, create roadmap, and coordinate between technical and marketing teams.", - tools=[], # No specific tools needed for initial version - temperature=0.4, - max_prompt_tokens=25000, - api_headers=api_headers -) - -developer = Agent( - name="Developer", - description="Technical implementation specialist", - instructions="You are a full stack tech expert and developer. Implement technical solutions and provide feasibility feedback.", - tools=[], # No specific tools needed for initial version - temperature=0.3, - max_prompt_tokens=25000, - api_headers=api_headers -) - -marketing_manager = Agent( - name="Marketing_Manager", - description="Marketing strategy and growth leader", - instructions="Develop marketing strategies, analyze target audience, and coordinate with Product Manager.", - tools=[], # No specific tools needed for initial version - temperature=0.6, - max_prompt_tokens=25000, - api_headers=api_headers -) - -# IN Agency Swarm, communication flows are uniform, not sequential or hierarchical. -agency = Agency( - [ - ceo, cto, product_manager, developer, marketing_manager, - [ceo, cto], - [ceo, product_manager], - [ceo, developer], - [ceo, marketing_manager], - [cto, developer], - [product_manager, developer], - [product_manager, marketing_manager] - ], - async_mode='threading', # Keep this for backward compatibility - shared_files='shared_files' -) - # Streamlit Interface def init_session_state(): """Initialize Streamlit 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(): """Main Streamlit application.""" st.set_page_config(page_title="AI Startup Organization Assistant", layout="wide") init_session_state() - st.title("🚀 AI Startup Organization Assistant") + st.title("🚀 AI Startup Organization Agency") with st.sidebar: st.header("🔑 API Configuration") @@ -166,16 +91,91 @@ def main(): help="Enter your OpenAI API key to continue" ) - if not openai_api_key: + 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 st.success("API Key accepted!") + + # 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}"} + # Define individual agents + ceo = Agent( + name="CEO", + description="Strategic leader and final decision maker for the startup", + instructions=""" + Analyze the given startup idea and take the authority of a CEO of the startup to make strategic decisions. + Use the AnalyzeStartupTool to evaluate the startup idea, and use the MakeStrategicDecision tool to make strategic decisions. + Coordinate with team members using the built-in SendMessage tool. + """, + tools=[AnalyzeStartupTool, MakeStrategicDecision], + temperature=0.7, + max_prompt_tokens=25000, + api_headers=api_headers + ) + + cto = Agent( + name="CTO", + description="Technical leader responsible for architecture and tech decisions", + instructions="Analyze technical requirements and evaluate feasibility. Always query requirements before evaluation", + tools=[QueryTechnicalRequirements, EvaluateTechnicalFeasibility], + temperature=0.5, + max_prompt_tokens=25000, + api_headers=api_headers + ) + + product_manager = Agent( + name="Product_Manager", + description="Product strategy and roadmap owner", + instructions="Define product strategy, create roadmap, and coordinate between technical and marketing teams.", + temperature=0.4, + max_prompt_tokens=25000, + api_headers=api_headers + ) + + developer = Agent( + name="Developer", + description="Technical implementation specialist", + instructions="You are a full stack tech expert and developer. Implement technical solutions and provide feasibility feedback.", + temperature=0.3, + max_prompt_tokens=25000, + api_headers=api_headers + ) + + marketing_manager = Agent( + name="Marketing_Manager", + description="Marketing strategy and growth leader", + instructions="Develop marketing strategies, analyze target audience, and coordinate with Product Manager.", + temperature=0.6, + max_prompt_tokens=25000, + api_headers=api_headers + ) + + # Initialize agency with communication paths + agency = Agency( + [ + ceo, cto, product_manager, developer, marketing_manager, + [ceo, cto], + [ceo, product_manager], + [ceo, developer], + [ceo, marketing_manager], + [cto, developer], + [product_manager, developer], + [product_manager, marketing_manager] + ], + async_mode='threading', + shared_files='shared_files' + ) + # Input form with st.form("startup_form"): - startup_idea = st.text_area("Describe your startup idea") + startup_idea = st.text_area("Describe your startup idea in a sentence or two") target_audience = st.text_area("Who is your target audience?") goals = st.text_area("What are your business goals?") technical_requirements = st.text_area("Any specific technical requirements? (optional)") @@ -199,29 +199,35 @@ def main(): ceo_response = agency.get_completion( message=f"Analyze this startup idea: {str(query)}", recipient_agent=ceo, - additional_instructions="Provide a strategic analysis of the startup idea using the AnalyzeStartupTool." + additional_instructions="Provide a strategic analysis of the startup idea using the AnalyzeStartupTool and use MakeStrategicDecision tool to make best possible strategic decisions for the startup." ) cto_response = agency.get_completion( message=f"Analyze technical requirements: {str(query)}", recipient_agent=cto, - additional_instructions="Evaluate technical feasibility using QueryTechnicalRequirements and EvaluateTechnicalFeasibility tools." + additional_instructions="Evaluate technical feasibility using QueryTechnicalRequirements and EvaluateTechnicalFeasibility tools, eventually building a scalable and efficient tech product for the startup." ) pm_response = agency.get_completion( message=f"Analyze product strategy: {str(query)}", recipient_agent=product_manager, - additional_instructions="Focus on product-market fit and roadmap development." + 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 and the tech stack decided by CTO to build required products for the startup: {str(query)}", + 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." ) marketing_response = agency.get_completion( message=f"Develop marketing strategy: {str(query)}", recipient_agent=marketing_manager, - additional_instructions="Provide detailed go-to-market strategy and customer acquisition plan." + 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 Analysis", "Technical Analysis", "Product Strategy", "Marketing Strategy"]) + tabs = st.tabs(["CEO Analysis", "Technical Analysis", "Product Strategy", "Marketing Strategy", "Developer's Feedback"]) with tabs[0]: st.markdown("## CEO's Strategic Analysis") @@ -239,12 +245,17 @@ def main(): st.markdown("## Marketing Strategy") st.markdown(marketing_response) + with tabs[4]: + st.markdown("## Developer's Feedback") + st.markdown(developer_response) + # Store complete analysis in session state complete_analysis = { "ceo_analysis": ceo_response, "technical_analysis": cto_response, "product_strategy": pm_response, - "marketing_strategy": marketing_response + "marketing_strategy": marketing_response, + "developer_feedback": developer_response } st.session_state.messages.append({ From 6033ed7e5f19a564c895201b7aa17e622f604f90 Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 8 Dec 2024 03:53:51 +0530 Subject: [PATCH 03/10] sequential - final structure --- .../ai_startup_org_agents/.gitignore | 1 + .../ai_startup_org_agents/README.md | 77 +++++++++++++++++++ .../ai_startup_org_agents/main.py | 77 ++++++++++++++----- .../ai_startup_org_agents/requirements.txt | 2 +- .../shared_files/agency_manifesto.md | 42 ---------- .../startup_analysis_templates.md | 25 ------ 6 files changed, 138 insertions(+), 86 deletions(-) delete mode 100644 ai_agent_tutorials/ai_startup_org_agents/shared_files/agency_manifesto.md delete mode 100644 ai_agent_tutorials/ai_startup_org_agents/shared_files/startup_analysis_templates.md diff --git a/ai_agent_tutorials/ai_startup_org_agents/.gitignore b/ai_agent_tutorials/ai_startup_org_agents/.gitignore index 19f4d17..c79c89c 100644 --- a/ai_agent_tutorials/ai_startup_org_agents/.gitignore +++ b/ai_agent_tutorials/ai_startup_org_agents/.gitignore @@ -1,3 +1,4 @@ .env startup-org settings.json +shared_files \ No newline at end of file diff --git a/ai_agent_tutorials/ai_startup_org_agents/README.md b/ai_agent_tutorials/ai_startup_org_agents/README.md index 8b13789..3341890 100644 --- a/ai_agent_tutorials/ai_startup_org_agents/README.md +++ b/ai_agent_tutorials/ai_startup_org_agents/README.md @@ -1 +1,78 @@ +# AI Startup Organization 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: + +## 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 + +- **Marketing Manager Agent**: Marketing strategy leader + - Develops go-to-market strategies + - Plans customer acquisition approaches + - Coordinates with product team + +### 🔄 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/main.py + ``` + +4. **Enter your OpenAI API Key** in the sidebar when prompted and start analyzing your startup idea! + +## Project Structure + +ai_startup_org_agents/ +├── main.py # Main application file with agents and tools +├── requirements.txt # Project dependencies +└── README.md # Project documentation diff --git a/ai_agent_tutorials/ai_startup_org_agents/main.py b/ai_agent_tutorials/ai_startup_org_agents/main.py index acbdc62..0841f5c 100644 --- a/ai_agent_tutorials/ai_startup_org_agents/main.py +++ b/ai_agent_tutorials/ai_startup_org_agents/main.py @@ -5,12 +5,13 @@ import streamlit as st from instructor import OpenAISchema import asyncio -# New Tools +# Custom Tools - Startup Analysis, Strategic Decision, Technical Requirements, Technical Feasibility class StartupAnalysis(OpenAISchema): """Schema for startup analysis results""" market_potential: Literal["high", "medium", "low"] technical_complexity: Literal["high", "medium", "low"] resource_requirements: Literal["high", "medium", "low"] + rationale: str = Field(description="Explanation for the analysis") class AnalyzeStartupTool(BaseTool): """Tool to analyze startup ideas""" @@ -18,25 +19,45 @@ class AnalyzeStartupTool(BaseTool): target_market: str = Field(..., description="Target market description") def run(self): - # Tool implementation - analysis = StartupAnalysis( - market_potential="high", - technical_complexity="medium", - resource_requirements="low" - ) - return analysis.dict() + """Run startup analysis based on CEO's evaluation""" + prompt = f""" + Analyze this startup idea: + Idea: {self.startup_idea} + Target Market: {self.target_market} + + Provide a comprehensive analysis including: + 1. Market potential (high/medium/low) + 2. Technical complexity (high/medium/low) + 3. Resource requirements (high/medium/low) + 4. A brief rationale for your decisions + + Format your response as a StartupAnalysis object. + """ + response = self._llm.invoke(prompt) + analysis = StartupAnalysis.from_response(response) + + # Store analysis in shared state for other tools to access + self._shared_state.set("startup_analysis", analysis) + return analysis class MakeStrategicDecision(BaseTool): """Tool for CEO to make and track strategic decisions""" - decision: str = Field(..., description="The strategic decision to be recorded and taken for this particular startup idea") + decision: str = Field(..., description="The strategic decision to be made for this startup idea") decision_type: Literal["product", "technical", "marketing", "financial"] = Field(..., description="Type of decision") def run(self): - analysis = self._shared_state.get("startup_analysis", None) - if analysis is None: - raise ValueError("Please analyze the startup idea first using QueryStartupIdea tool.") + """Execute and record strategic decision""" + analysis = self._shared_state.get("startup_analysis") + if not analysis: + return "Please analyze the startup idea first using AnalyzeStartupTool" - return f"Decision recorded: {self.decision} (Type: {self.decision_type}) based on analysis" + decision_record = { + "decision": self.decision, + "type": self.decision_type, + "based_on_analysis": analysis + } + + return f"Strategic decision recorded: {self.decision} (Type: {self.decision_type})" class QueryTechnicalRequirements(BaseTool): """Tool to analyze technical requirements""" @@ -110,9 +131,28 @@ def main(): name="CEO", description="Strategic leader and final decision maker for the startup", instructions=""" - Analyze the given startup idea and take the authority of a CEO of the startup to make strategic decisions. - Use the AnalyzeStartupTool to evaluate the startup idea, and use the MakeStrategicDecision tool to make strategic decisions. - Coordinate with team members using the built-in SendMessage tool. + You are an experienced CEO with deep expertise in evaluating startup ideas. + Your role involves two main responsibilities: + + 1. ANALYZING STARTUP IDEAS: + When analyzing startup ideas, carefully consider: + - Market Potential (high/medium/low): market size, growth, competition, accessibility + - Technical Complexity (high/medium/low): tech stack, scalability, timeline + - Resource Requirements (high/medium/low): capital, team, marketing costs + + 2. MAKING STRATEGIC DECISIONS: + After analysis, you should make clear strategic decisions: + - Product decisions: features, roadmap, priorities + - Technical decisions: architecture, stack choices + - Marketing decisions: go-to-market strategy, channels + - Financial decisions: funding, resource allocation + + Process: + 1. First use AnalyzeStartupTool to evaluate the idea + 2. Then use MakeStrategicDecision to record your strategic choices + 3. Always base decisions on your previous analysis + + Provide clear, actionable insights and decisions. """, tools=[AnalyzeStartupTool, MakeStrategicDecision], temperature=0.7, @@ -157,7 +197,7 @@ def main(): api_headers=api_headers ) - # Initialize agency with communication paths + # Initializing the agency with communication paths agency = Agency( [ ceo, cto, product_manager, developer, marketing_manager, @@ -169,7 +209,7 @@ def main(): [product_manager, developer], [product_manager, marketing_manager] ], - async_mode='threading', + async_mode='threading', # Runs agent tasks in separate threads for concurrent execution shared_files='shared_files' ) @@ -280,3 +320,4 @@ def main(): if __name__ == "__main__": main() + diff --git a/ai_agent_tutorials/ai_startup_org_agents/requirements.txt b/ai_agent_tutorials/ai_startup_org_agents/requirements.txt index 4e4c6dd..ffde40e 100644 --- a/ai_agent_tutorials/ai_startup_org_agents/requirements.txt +++ b/ai_agent_tutorials/ai_startup_org_agents/requirements.txt @@ -1,3 +1,3 @@ python-dotenv==1.0.0 -agency-swarm +agency-swarm==0.4.1 streamlit \ No newline at end of file diff --git a/ai_agent_tutorials/ai_startup_org_agents/shared_files/agency_manifesto.md b/ai_agent_tutorials/ai_startup_org_agents/shared_files/agency_manifesto.md deleted file mode 100644 index f3fd6a2..0000000 --- a/ai_agent_tutorials/ai_startup_org_agents/shared_files/agency_manifesto.md +++ /dev/null @@ -1,42 +0,0 @@ -# AI Startup Agency Manifesto - -## Our Mission -To provide comprehensive, data-driven analysis and strategic guidance for startup ideas through collaborative AI agents. - -## Agent Responsibilities - -### CEO Agent -- Lead strategic decision-making -- Coordinate between all team members -- Ensure alignment with business goals -- Make final decisions on critical matters - -### CTO Agent -- Evaluate technical feasibility -- Guide technology stack decisions -- Assess technical risks -- Collaborate with Developer on implementation plans - -### Product Manager Agent -- Define product strategy -- Create and maintain product roadmap -- Balance user needs with technical constraints -- Coordinate between technical and marketing teams - -### Developer Agent -- Provide technical implementation insights -- Assess development complexity -- Suggest technical solutions -- Work closely with CTO on feasibility - -### Marketing Manager Agent -- Develop marketing strategies -- Analyze target audience -- Plan go-to-market approach -- Work with Product Manager on market fit - -## Communication Guidelines -- All agents should communicate clearly and concisely -- Use data to support recommendations -- Highlight risks and opportunities -- Maintain focus on startup success diff --git a/ai_agent_tutorials/ai_startup_org_agents/shared_files/startup_analysis_templates.md b/ai_agent_tutorials/ai_startup_org_agents/shared_files/startup_analysis_templates.md deleted file mode 100644 index c24c3bf..0000000 --- a/ai_agent_tutorials/ai_startup_org_agents/shared_files/startup_analysis_templates.md +++ /dev/null @@ -1,25 +0,0 @@ -# Startup Analysis Templates - -## Market Analysis Template -- Market Size: [TAM, SAM, SOM] -- Target Customer Segments: [Primary, Secondary] -- Competition Analysis: [Direct, Indirect] -- Market Trends: [Current, Emerging] - -## Technical Feasibility Template -- Technology Stack Requirements -- Development Timeline -- Resource Requirements -- Technical Risks and Mitigations - -## Financial Analysis Template -- Initial Investment Required -- Revenue Streams -- Cost Structure -- Break-even Analysis - -## Marketing Strategy Template -- Value Proposition -- Marketing Channels -- Customer Acquisition Strategy -- Growth Metrics From d02f722af205031f1a035c7412e7f801777e9513 Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 8 Dec 2024 03:55:46 +0530 Subject: [PATCH 04/10] readme update --- ai_agent_tutorials/ai_startup_org_agents/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ai_agent_tutorials/ai_startup_org_agents/README.md b/ai_agent_tutorials/ai_startup_org_agents/README.md index 3341890..e1a22b1 100644 --- a/ai_agent_tutorials/ai_startup_org_agents/README.md +++ b/ai_agent_tutorials/ai_startup_org_agents/README.md @@ -33,6 +33,12 @@ An intelligent multi-agent system that provides comprehensive startup analysis a - Plans customer acquisition approaches - Coordinates with product team +### Custom Tools + +The agency uses specialized tools built with OpenAI Schema for structured analysis: +- **Analysis Tools**: AnalyzeStartupTool for market evaluation, MakeStrategicDecision for decision tracking +- **Technical Tools**: QueryTechnicalRequirements and EvaluateTechnicalFeasibility for technical assessment + ### 🔄 Asynchronous Communication The agency operates in async mode, enabling: @@ -47,6 +53,7 @@ The agency operates in async mode, enabling: - 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: @@ -69,10 +76,3 @@ Before anything else, Please get your OpenAI API Key here: https://platform.open ``` 4. **Enter your OpenAI API Key** in the sidebar when prompted and start analyzing your startup idea! - -## Project Structure - -ai_startup_org_agents/ -├── main.py # Main application file with agents and tools -├── requirements.txt # Project dependencies -└── README.md # Project documentation From 58516a5a90f67e95fad3729a8bf7c669c0e279f3 Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 8 Dec 2024 03:56:57 +0530 Subject: [PATCH 05/10] Remove .gitignore from tracking --- ai_agent_tutorials/ai_startup_org_agents/.gitignore | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 ai_agent_tutorials/ai_startup_org_agents/.gitignore diff --git a/ai_agent_tutorials/ai_startup_org_agents/.gitignore b/ai_agent_tutorials/ai_startup_org_agents/.gitignore deleted file mode 100644 index c79c89c..0000000 --- a/ai_agent_tutorials/ai_startup_org_agents/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.env -startup-org -settings.json -shared_files \ No newline at end of file From 8ff18fe18b295e870bc94c1153b9e5423e883e21 Mon Sep 17 00:00:00 2001 From: Madhu Shantan Date: Sun, 8 Dec 2024 04:01:16 +0530 Subject: [PATCH 06/10] added a short video demo --- ai_agent_tutorials/ai_startup_org_agents/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ai_agent_tutorials/ai_startup_org_agents/README.md b/ai_agent_tutorials/ai_startup_org_agents/README.md index e1a22b1..3b12ea1 100644 --- a/ai_agent_tutorials/ai_startup_org_agents/README.md +++ b/ai_agent_tutorials/ai_startup_org_agents/README.md @@ -4,6 +4,10 @@ An intelligent multi-agent system that provides comprehensive startup analysis a ## Demo: + +https://github.com/user-attachments/assets/64a240b1-4597-48b0-84b2-9230753e1228 + + ## Features ### 🤖 Agency Swarm Agents From de76dbb77288f819a5c02a0d5d7595c1c9c3c62f Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 8 Dec 2024 17:04:56 +0530 Subject: [PATCH 07/10] new - format --- .../ai_startup_org_agents/.gitignore | 4 + .../ai_startup_org_agents/agency.py | 344 ++++++++++++++++++ 2 files changed, 348 insertions(+) create mode 100644 ai_agent_tutorials/ai_startup_org_agents/.gitignore create mode 100644 ai_agent_tutorials/ai_startup_org_agents/agency.py diff --git a/ai_agent_tutorials/ai_startup_org_agents/.gitignore b/ai_agent_tutorials/ai_startup_org_agents/.gitignore new file mode 100644 index 0000000..c79c89c --- /dev/null +++ b/ai_agent_tutorials/ai_startup_org_agents/.gitignore @@ -0,0 +1,4 @@ +.env +startup-org +settings.json +shared_files \ No newline at end of file diff --git a/ai_agent_tutorials/ai_startup_org_agents/agency.py b/ai_agent_tutorials/ai_startup_org_agents/agency.py new file mode 100644 index 0000000..c35cc64 --- /dev/null +++ b/ai_agent_tutorials/ai_startup_org_agents/agency.py @@ -0,0 +1,344 @@ +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 + +# Schema Classes +class ProjectRequirements(OpenAISchema): + """Schema for project requirements analysis""" + project_scope: str + complexity: Literal["high", "medium", "low"] + estimated_timeline: str + key_deliverables: List[str] + technical_requirements: List[str] + budget_range: str + potential_challenges: List[str] + +class TechnicalSpecification(OpenAISchema): + """Schema for technical architecture and specifications""" + architecture_type: str + core_technologies: List[str] + api_requirements: List[str] + database_design: Dict[str, List[str]] + security_requirements: List[str] + scalability_considerations: List[str] + estimated_development_hours: int + +# 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() \ No newline at end of file From db37632d1f2348428c47a64e78d2211c34e7a46c Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 8 Dec 2024 17:06:03 +0530 Subject: [PATCH 08/10] new - format --- .../ai_startup_org_agents/.gitignore | 4 - .../ai_startup_org_agents/main.py | 323 ------------------ 2 files changed, 327 deletions(-) delete mode 100644 ai_agent_tutorials/ai_startup_org_agents/.gitignore delete mode 100644 ai_agent_tutorials/ai_startup_org_agents/main.py diff --git a/ai_agent_tutorials/ai_startup_org_agents/.gitignore b/ai_agent_tutorials/ai_startup_org_agents/.gitignore deleted file mode 100644 index c79c89c..0000000 --- a/ai_agent_tutorials/ai_startup_org_agents/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.env -startup-org -settings.json -shared_files \ No newline at end of file diff --git a/ai_agent_tutorials/ai_startup_org_agents/main.py b/ai_agent_tutorials/ai_startup_org_agents/main.py deleted file mode 100644 index 0841f5c..0000000 --- a/ai_agent_tutorials/ai_startup_org_agents/main.py +++ /dev/null @@ -1,323 +0,0 @@ -from typing import List, Literal -from agency_swarm import Agent, Agency, set_openai_key, BaseTool -from pydantic import Field -import streamlit as st -from instructor import OpenAISchema -import asyncio - -# Custom Tools - Startup Analysis, Strategic Decision, Technical Requirements, Technical Feasibility -class StartupAnalysis(OpenAISchema): - """Schema for startup analysis results""" - market_potential: Literal["high", "medium", "low"] - technical_complexity: Literal["high", "medium", "low"] - resource_requirements: Literal["high", "medium", "low"] - rationale: str = Field(description="Explanation for the analysis") - -class AnalyzeStartupTool(BaseTool): - """Tool to analyze startup ideas""" - startup_idea: str = Field(..., description="The startup idea to analyze") - target_market: str = Field(..., description="Target market description") - - def run(self): - """Run startup analysis based on CEO's evaluation""" - prompt = f""" - Analyze this startup idea: - Idea: {self.startup_idea} - Target Market: {self.target_market} - - Provide a comprehensive analysis including: - 1. Market potential (high/medium/low) - 2. Technical complexity (high/medium/low) - 3. Resource requirements (high/medium/low) - 4. A brief rationale for your decisions - - Format your response as a StartupAnalysis object. - """ - response = self._llm.invoke(prompt) - analysis = StartupAnalysis.from_response(response) - - # Store analysis in shared state for other tools to access - self._shared_state.set("startup_analysis", analysis) - return analysis - -class MakeStrategicDecision(BaseTool): - """Tool for CEO to make and track strategic decisions""" - decision: str = Field(..., description="The strategic decision to be made for this startup idea") - decision_type: Literal["product", "technical", "marketing", "financial"] = Field(..., description="Type of decision") - - def run(self): - """Execute and record strategic decision""" - analysis = self._shared_state.get("startup_analysis") - if not analysis: - return "Please analyze the startup idea first using AnalyzeStartupTool" - - decision_record = { - "decision": self.decision, - "type": self.decision_type, - "based_on_analysis": analysis - } - - return f"Strategic decision recorded: {self.decision} (Type: {self.decision_type})" - -class QueryTechnicalRequirements(BaseTool): - """Tool to analyze technical requirements""" - technology_stack: str = Field(..., description="Scalable technology stack to analyze and implement for this startup idea") - - def run(self): - if self._shared_state.get("tech_analysis", None) is not None: - raise ValueError("Technical analysis already exists. Please proceed with technical evaluation.") - - tech_analysis = { - "stack": self.technology_stack, - "feasibility": "high/medium/low", - "implementation_time": "estimate in months", - "potential_challenges": ["challenge1", "challenge2"] - } - - self._shared_state.set("tech_analysis", tech_analysis) - return "Technical requirements analyzed. Please proceed with technical evaluation." - -class EvaluateTechnicalFeasibility(BaseTool): - """Tool for CTO to evaluate technical feasibility""" - evaluation: str = Field(..., description="Technical evaluation details") - feasibility_score: Literal["high", "medium", "low"] = Field(..., description="Feasibility rating") - - def run(self): - tech_analysis = self._shared_state.get("tech_analysis", None) - if tech_analysis is None: - raise ValueError("Please analyze technical requirements first using QueryTechnicalRequirements tool.") - - return f"Technical evaluation completed: {self.evaluation} (Feasibility: {self.feasibility_score})" - -# Streamlit Interface -def init_session_state(): - """Initialize Streamlit 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(): - """Main Streamlit application.""" - st.set_page_config(page_title="AI Startup Organization Assistant", layout="wide") - init_session_state() - - st.title("🚀 AI Startup Organization Agency") - - 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 - - st.success("API Key accepted!") - - # 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}"} - - # Define individual agents - ceo = Agent( - name="CEO", - description="Strategic leader and final decision maker for the startup", - instructions=""" - You are an experienced CEO with deep expertise in evaluating startup ideas. - Your role involves two main responsibilities: - - 1. ANALYZING STARTUP IDEAS: - When analyzing startup ideas, carefully consider: - - Market Potential (high/medium/low): market size, growth, competition, accessibility - - Technical Complexity (high/medium/low): tech stack, scalability, timeline - - Resource Requirements (high/medium/low): capital, team, marketing costs - - 2. MAKING STRATEGIC DECISIONS: - After analysis, you should make clear strategic decisions: - - Product decisions: features, roadmap, priorities - - Technical decisions: architecture, stack choices - - Marketing decisions: go-to-market strategy, channels - - Financial decisions: funding, resource allocation - - Process: - 1. First use AnalyzeStartupTool to evaluate the idea - 2. Then use MakeStrategicDecision to record your strategic choices - 3. Always base decisions on your previous analysis - - Provide clear, actionable insights and decisions. - """, - tools=[AnalyzeStartupTool, MakeStrategicDecision], - temperature=0.7, - max_prompt_tokens=25000, - api_headers=api_headers - ) - - cto = Agent( - name="CTO", - description="Technical leader responsible for architecture and tech decisions", - instructions="Analyze technical requirements and evaluate feasibility. Always query requirements before evaluation", - tools=[QueryTechnicalRequirements, EvaluateTechnicalFeasibility], - temperature=0.5, - max_prompt_tokens=25000, - api_headers=api_headers - ) - - product_manager = Agent( - name="Product_Manager", - description="Product strategy and roadmap owner", - instructions="Define product strategy, create roadmap, and coordinate between technical and marketing teams.", - temperature=0.4, - max_prompt_tokens=25000, - api_headers=api_headers - ) - - developer = Agent( - name="Developer", - description="Technical implementation specialist", - instructions="You are a full stack tech expert and developer. Implement technical solutions and provide feasibility feedback.", - temperature=0.3, - max_prompt_tokens=25000, - api_headers=api_headers - ) - - marketing_manager = Agent( - name="Marketing_Manager", - description="Marketing strategy and growth leader", - instructions="Develop marketing strategies, analyze target audience, and coordinate with Product Manager.", - temperature=0.6, - max_prompt_tokens=25000, - api_headers=api_headers - ) - - # Initializing the agency with communication paths - agency = Agency( - [ - ceo, cto, product_manager, developer, marketing_manager, - [ceo, cto], - [ceo, product_manager], - [ceo, developer], - [ceo, marketing_manager], - [cto, developer], - [product_manager, developer], - [product_manager, marketing_manager] - ], - async_mode='threading', # Runs agent tasks in separate threads for concurrent execution - shared_files='shared_files' - ) - - # Input form - with st.form("startup_form"): - startup_idea = st.text_area("Describe your startup idea in a sentence or two") - target_audience = st.text_area("Who is your target audience?") - goals = st.text_area("What are your business goals?") - technical_requirements = st.text_area("Any specific technical requirements? (optional)") - marketing_focus = st.text_area("Any specific marketing focus? (optional)") - submitted = st.form_submit_button("Get Comprehensive Analysis") - - if submitted and startup_idea and target_audience and goals: - query = { - "startup_idea": startup_idea, - "target_audience": target_audience, - "business_goals": goals, - "technical_requirements": technical_requirements, - "marketing_focus": marketing_focus - } - - st.session_state.messages.append({"role": "user", "content": str(query)}) - - with st.spinner("AI Startup Agency is analyzing your idea..."): - try: - # Getanalysis from each agent using proper agency.get_completion() - ceo_response = agency.get_completion( - message=f"Analyze this startup idea: {str(query)}", - recipient_agent=ceo, - additional_instructions="Provide a strategic analysis of the startup idea using the AnalyzeStartupTool and use MakeStrategicDecision tool to make best possible strategic decisions for the startup." - ) - - cto_response = agency.get_completion( - message=f"Analyze technical requirements: {str(query)}", - recipient_agent=cto, - additional_instructions="Evaluate technical feasibility using QueryTechnicalRequirements and EvaluateTechnicalFeasibility tools, eventually building a scalable and efficient tech product for the startup." - ) - - pm_response = agency.get_completion( - message=f"Analyze product strategy: {str(query)}", - 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 and the tech stack decided by CTO to build required products for the startup: {str(query)}", - 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." - ) - - marketing_response = agency.get_completion( - message=f"Develop marketing strategy: {str(query)}", - recipient_agent=marketing_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 Analysis", "Technical Analysis", "Product Strategy", "Marketing Strategy", "Developer's Feedback"]) - - with tabs[0]: - st.markdown("## CEO's Strategic Analysis") - st.markdown(ceo_response) - - with tabs[1]: - st.markdown("## Technical Feasibility (CTO)") - st.markdown(cto_response) - - with tabs[2]: - st.markdown("## Product Strategy") - st.markdown(pm_response) - - with tabs[3]: - st.markdown("## Marketing Strategy") - st.markdown(marketing_response) - - with tabs[4]: - st.markdown("## Developer's Feedback") - st.markdown(developer_response) - - # Store complete analysis in session state - complete_analysis = { - "ceo_analysis": ceo_response, - "technical_analysis": cto_response, - "product_strategy": pm_response, - "marketing_strategy": marketing_response, - "developer_feedback": developer_response - } - - st.session_state.messages.append({ - "role": "assistant", - "content": str(complete_analysis) - }) - - except Exception as e: - st.error(f"Error during analysis: {str(e)}") - st.error("Please try again or contact support.") - - 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() - From df0d83e86e9cd89c1a483a33126e296ed34e5c06 Mon Sep 17 00:00:00 2001 From: Madhu Date: Sun, 8 Dec 2024 21:09:15 +0530 Subject: [PATCH 09/10] readme changes --- .../ai_startup_org_agents/README.md | 10 ++++----- .../ai_startup_org_agents/agency.py | 21 ------------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/ai_agent_tutorials/ai_startup_org_agents/README.md b/ai_agent_tutorials/ai_startup_org_agents/README.md index 3b12ea1..531bbee 100644 --- a/ai_agent_tutorials/ai_startup_org_agents/README.md +++ b/ai_agent_tutorials/ai_startup_org_agents/README.md @@ -1,4 +1,4 @@ -# AI Startup Organization Agency 🚀 +# 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 @@ -32,7 +32,7 @@ https://github.com/user-attachments/assets/64a240b1-4597-48b0-84b2-9230753e1228 - Suggests optimal tech stack and cloud solutions - Estimates development costs and timelines -- **Marketing Manager Agent**: Marketing strategy leader +- **Client Success Agent**: Marketing strategy leader - Develops go-to-market strategies - Plans customer acquisition approaches - Coordinates with product team @@ -40,8 +40,8 @@ https://github.com/user-attachments/assets/64a240b1-4597-48b0-84b2-9230753e1228 ### Custom Tools The agency uses specialized tools built with OpenAI Schema for structured analysis: -- **Analysis Tools**: AnalyzeStartupTool for market evaluation, MakeStrategicDecision for decision tracking -- **Technical Tools**: QueryTechnicalRequirements and EvaluateTechnicalFeasibility for technical assessment +- **Analysis Tools**: AnalyzeProjectRequirements for market evaluation and analysis of startup idea +- **Technical Tools**: CreateTechnicalSpecification for technical assessment ### 🔄 Asynchronous Communication @@ -76,7 +76,7 @@ Before anything else, Please get your OpenAI API Key here: https://platform.open 3. **Run the Streamlit app**: ```bash - streamlit run ai_startup_org_agents/main.py + 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! diff --git a/ai_agent_tutorials/ai_startup_org_agents/agency.py b/ai_agent_tutorials/ai_startup_org_agents/agency.py index c35cc64..f76ee98 100644 --- a/ai_agent_tutorials/ai_startup_org_agents/agency.py +++ b/ai_agent_tutorials/ai_startup_org_agents/agency.py @@ -5,27 +5,6 @@ import streamlit as st from instructor import OpenAISchema import asyncio -# Schema Classes -class ProjectRequirements(OpenAISchema): - """Schema for project requirements analysis""" - project_scope: str - complexity: Literal["high", "medium", "low"] - estimated_timeline: str - key_deliverables: List[str] - technical_requirements: List[str] - budget_range: str - potential_challenges: List[str] - -class TechnicalSpecification(OpenAISchema): - """Schema for technical architecture and specifications""" - architecture_type: str - core_technologies: List[str] - api_requirements: List[str] - database_design: Dict[str, List[str]] - security_requirements: List[str] - scalability_considerations: List[str] - estimated_development_hours: int - # Tools class AnalyzeProjectRequirements(BaseTool): """Tool for comprehensive project analysis""" From 53004e5467ccefdfce6824bf9fdf80adb1a1ec7b Mon Sep 17 00:00:00 2001 From: Madhu Shantan Date: Sun, 8 Dec 2024 21:23:58 +0530 Subject: [PATCH 10/10] Updated README.md --- ai_agent_tutorials/ai_startup_org_agents/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ai_agent_tutorials/ai_startup_org_agents/README.md b/ai_agent_tutorials/ai_startup_org_agents/README.md index 531bbee..b136061 100644 --- a/ai_agent_tutorials/ai_startup_org_agents/README.md +++ b/ai_agent_tutorials/ai_startup_org_agents/README.md @@ -5,7 +5,9 @@ An intelligent multi-agent system that provides comprehensive startup analysis a ## Demo: -https://github.com/user-attachments/assets/64a240b1-4597-48b0-84b2-9230753e1228 + +https://github.com/user-attachments/assets/a0befa3a-f4c3-400d-9790-4b9e37254405 + ## Features