sequential - base structute

This commit is contained in:
Madhu
2024-12-08 02:39:38 +05:30
parent 85b36f6731
commit a479dad3ad

View File

@@ -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({