Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,186 +1,30 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import os
|
| 3 |
-
import json
|
| 4 |
import pandas as pd
|
| 5 |
-
from phase1_agents import search_company, scrape_website, process_company_description
|
| 6 |
-
from phase2_agents import get_industry_trends, get_ai_use_cases
|
| 7 |
-
from phase3_agents import generate_ai_strategy, suggest_ai_integration, identify_revenue_opportunities, generate_report
|
| 8 |
-
from bni_agent import get_bni_benefits
|
| 9 |
-
from rag_agent import recommend_bni_connections
|
| 10 |
-
|
| 11 |
-
# File Paths for Storing User Data
|
| 12 |
-
CSV_FILE = "user_data.csv"
|
| 13 |
-
JSON_FILE = "user_data.json"
|
| 14 |
-
|
| 15 |
-
# Function to Save Data to CSV
|
| 16 |
-
def save_data_csv(data):
|
| 17 |
-
df = pd.DataFrame([data])
|
| 18 |
-
if os.path.exists(CSV_FILE):
|
| 19 |
-
df.to_csv(CSV_FILE, mode='a', header=False, index=False)
|
| 20 |
-
else:
|
| 21 |
-
df.to_csv(CSV_FILE, index=False)
|
| 22 |
-
|
| 23 |
-
# Function to Save Data to JSON
|
| 24 |
-
def save_data_json(data):
|
| 25 |
-
if os.path.exists(JSON_FILE):
|
| 26 |
-
with open(JSON_FILE, "r") as file:
|
| 27 |
-
existing_data = json.load(file)
|
| 28 |
-
else:
|
| 29 |
-
existing_data = []
|
| 30 |
-
|
| 31 |
-
existing_data.append(data)
|
| 32 |
-
with open(JSON_FILE, "w") as file:
|
| 33 |
-
json.dump(existing_data, file, indent=4)
|
| 34 |
-
|
| 35 |
-
# Streamlit UI
|
| 36 |
-
def main():
|
| 37 |
-
st.title("π Visionary AI - AI Strategy Generator")
|
| 38 |
-
st.write("π This tool provides an AI-driven business strategy report tailored for your company.")
|
| 39 |
-
st.write("π Powered by **State-of-the-Art Reasoning Models** for AI integration insights.")
|
| 40 |
-
|
| 41 |
-
# Initialize Session State Variables
|
| 42 |
-
session_keys = ["company_data", "industry_trends", "ai_use_cases", "ai_strategy",
|
| 43 |
-
"ai_integration", "revenue_opportunities", "bni_benefits", "bni_connections"]
|
| 44 |
-
|
| 45 |
-
for key in session_keys:
|
| 46 |
-
if key not in st.session_state:
|
| 47 |
-
st.session_state[key] = None
|
| 48 |
-
|
| 49 |
-
# Collect User Information
|
| 50 |
-
name = st.text_input("π€ Your Name")
|
| 51 |
-
email = st.text_input("π§ Email")
|
| 52 |
-
mobile = st.text_input("π± Mobile Number")
|
| 53 |
-
company_name = st.text_input("π’ Company Name")
|
| 54 |
-
company_industry = st.text_input("πΌ Industry (e.g., Healthcare, Finance, IT)")
|
| 55 |
-
|
| 56 |
-
# Select Company Data Input Method
|
| 57 |
-
st.subheader("π Provide Company Information")
|
| 58 |
-
input_method = st.radio("Choose a method to provide company details:",
|
| 59 |
-
["Company Website", "Web Search", "Manual Description"])
|
| 60 |
-
|
| 61 |
-
progress_bar = st.progress(0)
|
| 62 |
-
|
| 63 |
-
# Handle Company Data Input
|
| 64 |
-
if input_method == "Company Website":
|
| 65 |
-
website_url = st.text_input("π Enter Company Website URL")
|
| 66 |
-
if st.button("π Scrape Website"):
|
| 67 |
-
progress_bar.progress(10)
|
| 68 |
-
st.session_state.company_data = scrape_website(website_url)
|
| 69 |
-
progress_bar.progress(30)
|
| 70 |
-
|
| 71 |
-
elif input_method == "Web Search":
|
| 72 |
-
if st.button("π Search Company Online"):
|
| 73 |
-
progress_bar.progress(10)
|
| 74 |
-
st.session_state.company_data = search_company(company_name)
|
| 75 |
-
progress_bar.progress(30)
|
| 76 |
-
|
| 77 |
-
elif input_method == "Manual Description":
|
| 78 |
-
company_description = st.text_area("π Enter Company Description")
|
| 79 |
-
if st.button("β Process Description"):
|
| 80 |
-
progress_bar.progress(10)
|
| 81 |
-
st.session_state.company_data = process_company_description(company_description)
|
| 82 |
-
progress_bar.progress(30)
|
| 83 |
-
|
| 84 |
-
# Automated Processing of All Phases
|
| 85 |
-
if st.session_state.company_data:
|
| 86 |
-
st.subheader("β
Company Information Extracted")
|
| 87 |
-
st.write(st.session_state.company_data)
|
| 88 |
-
progress_bar.progress(40)
|
| 89 |
-
|
| 90 |
-
# Industry Analysis
|
| 91 |
-
if st.button("π¬ Analyze Industry & AI Trends"):
|
| 92 |
-
progress_bar.progress(50)
|
| 93 |
-
st.session_state.industry_trends = get_industry_trends(company_industry)
|
| 94 |
-
st.session_state.ai_use_cases = get_ai_use_cases(company_industry)
|
| 95 |
-
progress_bar.progress(60)
|
| 96 |
-
|
| 97 |
-
if st.session_state.industry_trends:
|
| 98 |
-
st.subheader("π Industry Trends & AI Use Cases")
|
| 99 |
-
st.write(st.session_state.industry_trends)
|
| 100 |
-
st.write(st.session_state.ai_use_cases)
|
| 101 |
-
progress_bar.progress(70)
|
| 102 |
-
|
| 103 |
-
# AI Strategy & Implementation
|
| 104 |
-
if st.button("π€ Generate AI Strategy"):
|
| 105 |
-
progress_bar.progress(75)
|
| 106 |
-
st.session_state.ai_strategy = generate_ai_strategy(st.session_state.company_data,
|
| 107 |
-
st.session_state.industry_trends,
|
| 108 |
-
st.session_state.ai_use_cases)
|
| 109 |
-
st.session_state.ai_integration = suggest_ai_integration(st.session_state.company_data,
|
| 110 |
-
st.session_state.ai_strategy)
|
| 111 |
-
st.session_state.revenue_opportunities = identify_revenue_opportunities(st.session_state.company_data,
|
| 112 |
-
st.session_state.ai_strategy)
|
| 113 |
-
progress_bar.progress(85)
|
| 114 |
-
|
| 115 |
-
if st.session_state.ai_strategy:
|
| 116 |
-
st.subheader("π AI Strategy & Implementation Plan")
|
| 117 |
-
st.write(st.session_state.ai_strategy)
|
| 118 |
-
st.write(st.session_state.ai_integration)
|
| 119 |
-
st.write(st.session_state.revenue_opportunities)
|
| 120 |
-
progress_bar.progress(90)
|
| 121 |
-
|
| 122 |
-
# BNI Benefits & Recommendations
|
| 123 |
-
if st.button("π Discover BNI Benefits"):
|
| 124 |
-
progress_bar.progress(92)
|
| 125 |
-
st.session_state.bni_benefits = get_bni_benefits(st.session_state.company_data)
|
| 126 |
-
st.session_state.bni_connections = recommend_bni_connections(st.session_state.company_data)
|
| 127 |
-
progress_bar.progress(95)
|
| 128 |
-
|
| 129 |
-
if st.session_state.bni_benefits:
|
| 130 |
-
st.subheader("π BNI Membership Benefits for Your Business")
|
| 131 |
-
st.write(st.session_state.bni_benefits)
|
| 132 |
-
|
| 133 |
-
if st.session_state.bni_connections:
|
| 134 |
-
st.subheader("π€ Recommended BNI Pearl Chapter Connections")
|
| 135 |
-
st.write(st.session_state.bni_connections)
|
| 136 |
-
progress_bar.progress(98)
|
| 137 |
-
|
| 138 |
-
# Generate Final Report
|
| 139 |
-
if st.button("π Generate Final Report"):
|
| 140 |
-
report_filename = generate_report(company_name, st.session_state.ai_strategy,
|
| 141 |
-
st.session_state.ai_integration, st.session_state.revenue_opportunities)
|
| 142 |
-
st.success(f"π Report Generated: **{report_filename}**")
|
| 143 |
-
progress_bar.progress(100)
|
| 144 |
-
|
| 145 |
-
# Footer
|
| 146 |
-
st.markdown("---")
|
| 147 |
-
st.markdown("π **Developed by [Aditya Ghadge](https://www.linkedin.com/in/aditya-ghadge-a82b30240/) for Giant Analytics**")
|
| 148 |
-
|
| 149 |
-
if __name__ == "__main__":
|
| 150 |
-
main()
|
| 151 |
-
import streamlit as st
|
| 152 |
import os
|
| 153 |
-
import json
|
| 154 |
-
import pandas as pd
|
| 155 |
from phase1_agents import search_company, scrape_website, process_company_description
|
| 156 |
from phase2_agents import get_industry_trends, get_ai_use_cases
|
| 157 |
from phase3_agents import generate_ai_strategy, suggest_ai_integration, identify_revenue_opportunities, generate_report
|
| 158 |
from bni_agent import get_bni_benefits
|
| 159 |
from rag_agent import recommend_bni_connections
|
| 160 |
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
df
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
existing_data = []
|
| 180 |
-
|
| 181 |
-
existing_data.append(data)
|
| 182 |
-
with open(JSON_FILE, "w") as file:
|
| 183 |
-
json.dump(existing_data, file, indent=4)
|
| 184 |
|
| 185 |
# Streamlit UI
|
| 186 |
def main():
|
|
@@ -191,7 +35,7 @@ def main():
|
|
| 191 |
# Initialize Session State Variables
|
| 192 |
session_keys = ["company_data", "industry_trends", "ai_use_cases", "ai_strategy",
|
| 193 |
"ai_integration", "revenue_opportunities", "bni_benefits", "bni_connections"]
|
| 194 |
-
|
| 195 |
for key in session_keys:
|
| 196 |
if key not in st.session_state:
|
| 197 |
st.session_state[key] = None
|
|
@@ -231,18 +75,17 @@ def main():
|
|
| 231 |
st.session_state.company_data = process_company_description(company_description)
|
| 232 |
progress_bar.progress(30)
|
| 233 |
|
| 234 |
-
#
|
| 235 |
if st.session_state.company_data:
|
| 236 |
st.subheader("β
Company Information Extracted")
|
| 237 |
st.write(st.session_state.company_data)
|
| 238 |
progress_bar.progress(40)
|
| 239 |
|
| 240 |
# Industry Analysis
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
progress_bar.progress(60)
|
| 246 |
|
| 247 |
if st.session_state.industry_trends:
|
| 248 |
st.subheader("π Industry Trends & AI Use Cases")
|
|
@@ -251,16 +94,15 @@ def main():
|
|
| 251 |
progress_bar.progress(70)
|
| 252 |
|
| 253 |
# AI Strategy & Implementation
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
progress_bar.progress(85)
|
| 264 |
|
| 265 |
if st.session_state.ai_strategy:
|
| 266 |
st.subheader("π AI Strategy & Implementation Plan")
|
|
@@ -269,12 +111,15 @@ def main():
|
|
| 269 |
st.write(st.session_state.revenue_opportunities)
|
| 270 |
progress_bar.progress(90)
|
| 271 |
|
| 272 |
-
# BNI Benefits & Recommendations
|
| 273 |
-
|
| 274 |
-
progress_bar.progress(92)
|
| 275 |
st.session_state.bni_benefits = get_bni_benefits(st.session_state.company_data)
|
| 276 |
st.session_state.bni_connections = recommend_bni_connections(st.session_state.company_data)
|
| 277 |
progress_bar.progress(95)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
|
| 279 |
if st.session_state.bni_benefits:
|
| 280 |
st.subheader("π BNI Membership Benefits for Your Business")
|
|
@@ -285,16 +130,26 @@ def main():
|
|
| 285 |
st.write(st.session_state.bni_connections)
|
| 286 |
progress_bar.progress(98)
|
| 287 |
|
| 288 |
-
# Generate Final Report
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
|
| 295 |
# Footer
|
| 296 |
st.markdown("---")
|
| 297 |
st.markdown("π **Developed by [Aditya Ghadge](https://www.linkedin.com/in/aditya-ghadge-a82b30240/) for Giant Analytics**")
|
| 298 |
|
| 299 |
if __name__ == "__main__":
|
| 300 |
-
main()
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import os
|
|
|
|
|
|
|
| 4 |
from phase1_agents import search_company, scrape_website, process_company_description
|
| 5 |
from phase2_agents import get_industry_trends, get_ai_use_cases
|
| 6 |
from phase3_agents import generate_ai_strategy, suggest_ai_integration, identify_revenue_opportunities, generate_report
|
| 7 |
from bni_agent import get_bni_benefits
|
| 8 |
from rag_agent import recommend_bni_connections
|
| 9 |
|
| 10 |
+
from datasets import load_dataset, Dataset
|
| 11 |
+
from huggingface_hub import HfApi
|
| 12 |
+
|
| 13 |
+
# Hugging Face Dataset Name (Replace with your actual dataset)
|
| 14 |
+
HF_DATASET_NAME = "GiantAnalytics/visionary-ai-user-data"
|
| 15 |
+
|
| 16 |
+
# Function to Save Data to Hugging Face Dataset
|
| 17 |
+
def save_data_hf(data):
|
| 18 |
+
try:
|
| 19 |
+
dataset = load_dataset(HF_DATASET_NAME)
|
| 20 |
+
df = pd.DataFrame(dataset["train"])
|
| 21 |
+
new_df = pd.DataFrame([data])
|
| 22 |
+
df = pd.concat([df, new_df], ignore_index=True)
|
| 23 |
+
new_dataset = Dataset.from_pandas(df)
|
| 24 |
+
new_dataset.push_to_hub(HF_DATASET_NAME, split="train")
|
| 25 |
+
print("β
Data saved successfully to Hugging Face Dataset")
|
| 26 |
+
except Exception as e:
|
| 27 |
+
print(f"β Failed to save data: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# Streamlit UI
|
| 30 |
def main():
|
|
|
|
| 35 |
# Initialize Session State Variables
|
| 36 |
session_keys = ["company_data", "industry_trends", "ai_use_cases", "ai_strategy",
|
| 37 |
"ai_integration", "revenue_opportunities", "bni_benefits", "bni_connections"]
|
| 38 |
+
|
| 39 |
for key in session_keys:
|
| 40 |
if key not in st.session_state:
|
| 41 |
st.session_state[key] = None
|
|
|
|
| 75 |
st.session_state.company_data = process_company_description(company_description)
|
| 76 |
progress_bar.progress(30)
|
| 77 |
|
| 78 |
+
# **Execute All Phases Automatically After Company Data is Available**
|
| 79 |
if st.session_state.company_data:
|
| 80 |
st.subheader("β
Company Information Extracted")
|
| 81 |
st.write(st.session_state.company_data)
|
| 82 |
progress_bar.progress(40)
|
| 83 |
|
| 84 |
# Industry Analysis
|
| 85 |
+
progress_bar.progress(50)
|
| 86 |
+
st.session_state.industry_trends = get_industry_trends(company_industry)
|
| 87 |
+
st.session_state.ai_use_cases = get_ai_use_cases(company_industry)
|
| 88 |
+
progress_bar.progress(60)
|
|
|
|
| 89 |
|
| 90 |
if st.session_state.industry_trends:
|
| 91 |
st.subheader("π Industry Trends & AI Use Cases")
|
|
|
|
| 94 |
progress_bar.progress(70)
|
| 95 |
|
| 96 |
# AI Strategy & Implementation
|
| 97 |
+
progress_bar.progress(75)
|
| 98 |
+
st.session_state.ai_strategy = generate_ai_strategy(st.session_state.company_data,
|
| 99 |
+
st.session_state.industry_trends,
|
| 100 |
+
st.session_state.ai_use_cases)
|
| 101 |
+
st.session_state.ai_integration = suggest_ai_integration(st.session_state.company_data,
|
| 102 |
+
st.session_state.ai_strategy)
|
| 103 |
+
st.session_state.revenue_opportunities = identify_revenue_opportunities(st.session_state.company_data,
|
| 104 |
+
st.session_state.ai_strategy)
|
| 105 |
+
progress_bar.progress(85)
|
|
|
|
| 106 |
|
| 107 |
if st.session_state.ai_strategy:
|
| 108 |
st.subheader("π AI Strategy & Implementation Plan")
|
|
|
|
| 111 |
st.write(st.session_state.revenue_opportunities)
|
| 112 |
progress_bar.progress(90)
|
| 113 |
|
| 114 |
+
# **BNI Benefits & Recommendations (Handled with Error Handling)**
|
| 115 |
+
try:
|
|
|
|
| 116 |
st.session_state.bni_benefits = get_bni_benefits(st.session_state.company_data)
|
| 117 |
st.session_state.bni_connections = recommend_bni_connections(st.session_state.company_data)
|
| 118 |
progress_bar.progress(95)
|
| 119 |
+
except Exception as e:
|
| 120 |
+
print(f"β Error fetching BNI data: {e}")
|
| 121 |
+
st.session_state.bni_benefits = "No BNI data available."
|
| 122 |
+
st.session_state.bni_connections = "No relevant BNI connections found."
|
| 123 |
|
| 124 |
if st.session_state.bni_benefits:
|
| 125 |
st.subheader("π BNI Membership Benefits for Your Business")
|
|
|
|
| 130 |
st.write(st.session_state.bni_connections)
|
| 131 |
progress_bar.progress(98)
|
| 132 |
|
| 133 |
+
# Generate Final Report Automatically
|
| 134 |
+
progress_bar.progress(99)
|
| 135 |
+
report_filename = generate_report(company_name, st.session_state.ai_strategy,
|
| 136 |
+
st.session_state.ai_integration, st.session_state.revenue_opportunities)
|
| 137 |
+
st.success(f"π Report Generated: **{report_filename}**")
|
| 138 |
+
progress_bar.progress(100)
|
| 139 |
+
|
| 140 |
+
# Save Data to Hugging Face
|
| 141 |
+
if st.session_state.company_data and st.session_state.ai_strategy:
|
| 142 |
+
user_data = {
|
| 143 |
+
"name": name, "email": email, "mobile": mobile, "company_name": company_name,
|
| 144 |
+
"industry": company_industry, "input_method": input_method, "company_data": st.session_state.company_data,
|
| 145 |
+
"ai_strategy": st.session_state.ai_strategy, "ai_integration": st.session_state.ai_integration,
|
| 146 |
+
"revenue_opportunities": st.session_state.revenue_opportunities, "bni_benefits": st.session_state.bni_benefits
|
| 147 |
+
}
|
| 148 |
+
save_data_hf(user_data)
|
| 149 |
|
| 150 |
# Footer
|
| 151 |
st.markdown("---")
|
| 152 |
st.markdown("π **Developed by [Aditya Ghadge](https://www.linkedin.com/in/aditya-ghadge-a82b30240/) for Giant Analytics**")
|
| 153 |
|
| 154 |
if __name__ == "__main__":
|
| 155 |
+
main()
|