-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
112 lines (90 loc) · 5.81 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import streamlit as st
import google.generativeai as genai
import pandas as pd
from dotenv import load_dotenv
import os
# Load environment variables
load_dotenv()
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
# Load datasets
# Load datasets
founder_profiles = pd.read_csv("founder_profiles.csv", encoding="ISO-8859-1")
investor_data = pd.read_csv("investor_data.csv", encoding="ISO-8859-1")
market_data = pd.read_csv("market_data.csv", encoding="ISO-8859-1")
# Initialize Gemini model
model = genai.GenerativeModel("gemini-pro")
# Streamlit UI
st.set_page_config(page_title="AI Startup Assistant", layout="wide")
st.title("🚀 AI-Powered Startup Assistant")
st.write("An AI assistant designed to help solo founders like Alex navigate the startup journey.")
# Sidebar settings
st.sidebar.header("Customize Your Experience")
st.sidebar.subheader("Startup Stage")
startup_stage = st.sidebar.selectbox("Select Your Stage", ["Idea Validation", "MVP Development", "Fundraising", "Scaling"])
st.sidebar.subheader("Challenges")
challenge_type = st.sidebar.selectbox("Biggest Challenge Right Now", ["Finding a Co-founder", "Market Research", "Investor Connections", "Product Development", "Growth Strategies"])
st.sidebar.subheader("Your Startup Idea")
startup_idea = st.sidebar.text_area("Describe your startup idea")
# Function to validate startup idea using AI with market trends
def validate_idea(idea, stage, challenge):
market_trends = market_data[market_data['Description'].str.contains(idea, case=False, na=False)]
trends_summary = market_trends[['Company', 'Categories', 'Status']].to_dict(orient='records') if not market_trends.empty else "No directly matching trends found."
prompt = f"Analyze this startup idea: {idea}. Based on market trends: {trends_summary}, is it viable? Suggest improvements. Consider the startup stage: {stage} and challenge: {challenge}."
response = model.generate_content(prompt)
return response.text
# Function to find best co-founder match based on Standardized Major
def find_best_cofounder(idea, challenge):
idea_keywords = idea.lower().split()
founder_profiles['match_score'] = founder_profiles.apply(
lambda row: sum(keyword in str(row['Standardized Major']).lower() for keyword in idea_keywords) if pd.notna(row['Standardized Major']) else 0, axis=1)
relevant_founders = founder_profiles.sort_values(by='match_score', ascending=False).head(3)
if not relevant_founders.empty:
result = []
for _, row in relevant_founders.iterrows():
reason = f"{row['Full Name']} is a great fit because they have a background in {row['Standardized Major']} with experience at {row['Primary Company']}. This aligns with the challenge: {challenge}."
result.append({"Full Name": row['Full Name'], "Primary Company": row['Primary Company'], "Standardized Major": row['Standardized Major'], "Years of Employment": row['Years of Employment'], "Reason": reason, "LinkedIN": row['LinkedIn']})
return pd.DataFrame(result)
return pd.DataFrame(columns=["Full Name", "Primary Company", "Standardized Major", "Years of Employment", "Reason", "LinkedIn"])
# Function to find best investor match based on funding_round_type and raised_amount_usd
def find_best_investor(idea, challenge):
idea_keywords = idea.lower().split()
investor_data_filtered = investor_data.dropna(subset=['funding_round_type', 'raised_amount_usd'])
investor_data_filtered['match_score'] = investor_data_filtered.apply(
lambda row: sum(keyword in str(row['funding_round_type']).lower() for keyword in idea_keywords), axis=1)
relevant_investors = investor_data_filtered.sort_values(by=['match_score', 'raised_amount_usd'], ascending=[False, False]).head(3)
if not relevant_investors.empty:
result = []
for _, row in relevant_investors.iterrows():
reason = f"{row['investor_name']} is a strong match because they have invested in {row['company_name']} under funding type {row['funding_round_type']} with an amount of {row['raised_amount_usd']} USD. This is aligned with the challenge: {challenge}."
result.append({"Investor Name": row['investor_name'], "Funding Round Type": row['funding_round_type'], "Raised Amount (USD)": row['raised_amount_usd'], "Reason": reason})
return pd.DataFrame(result)
return pd.DataFrame(columns=["Investor Name", "Funding Round Type", "Raised Amount (USD)", "Reason"])
# Chat history
if "messages" not in st.session_state:
st.session_state.messages = []
# Display chat history
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# User input
prompt = st.chat_input("Ask me anything about your startup journey!")
if prompt:
st.session_state.messages.append({"role": "user", "content": prompt})
with st.chat_message("user"):
st.markdown(prompt)
# Generate AI response
response = model.generate_content(f"Startup Stage: {startup_stage}\nChallenge: {challenge_type}\nStartup Idea: {startup_idea}\nQuestion: {prompt}")
reply = response.text
st.session_state.messages.append({"role": "assistant", "content": reply})
with st.chat_message("assistant"):
st.markdown(reply)
st.sidebar.subheader("Additional Features")
if st.sidebar.button("Validate Startup Idea"):
st.write("### Market Validation Insights:")
st.write(validate_idea(startup_idea, startup_stage, challenge_type))
if st.sidebar.button("Find Best Co-founder"):
st.write("### Recommended Co-founders:")
st.dataframe(find_best_cofounder(startup_idea, challenge_type))
if st.sidebar.button("Find Best Investor"):
st.write("### Recommended Investors:")
st.dataframe(find_best_investor(startup_idea, challenge_type))