Spaces:
Sleeping
Sleeping
File size: 7,135 Bytes
aa0919f b38d13a aa0919f b38d13a aa0919f b38d13a aa0919f |
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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
import streamlit as st
import pandas as pd
import os
from phase1_agents import search_company, scrape_website, process_company_description
from phase2_agents import get_industry_trends
from phase3_agents import generate_ai_strategy, identify_revenue_opportunities, generate_report
from bni_agent import get_bni_benefits
from rag_agent import recommend_bni_connections
from datasets import load_dataset, Dataset
from huggingface_hub import HfApi
# Hugging Face Dataset Name
HF_DATASET_NAME = "GiantAnalytics/visionary-ai-user-data"
# Function to Save Data to Hugging Face Dataset
def save_data_hf(data):
try:
dataset = load_dataset(HF_DATASET_NAME)
df = pd.DataFrame(dataset["train"])
new_df = pd.DataFrame([data])
df = pd.concat([df, new_df], ignore_index=True)
new_dataset = Dataset.from_pandas(df)
new_dataset.push_to_hub(HF_DATASET_NAME, split="train")
print("β
Data saved successfully to Hugging Face Dataset")
except Exception as e:
print(f"β Failed to save data: {e}")
# Streamlit UI
def main():
st.title("π Visionary AI - AI Strategy Generator")
st.write("π This tool provides an AI-driven business strategy report tailored for your company.")
st.write("π Powered by **State-of-the-Art Reasoning Models** for AI integration insights.")
# Initialize Session State Variables
session_keys = [
"company_data", "industry_trends", "ai_strategy",
"revenue_opportunities", "bni_benefits", "bni_connections"
]
for key in session_keys:
if key not in st.session_state:
st.session_state[key] = None
# Collect User Information
name = st.text_input("π€ Your Name")
email = st.text_input("π§ Email")
mobile = st.text_input("π± Mobile Number")
company_name = st.text_input("π’ Company Name")
company_industry = st.text_input("πΌ Industry (e.g., Healthcare, Finance, IT)")
# Select Company Data Input Method
st.subheader("π Provide Company Information")
input_method = st.radio("Choose a method to provide company details:",
["Company Website", "Web Search", "Manual Description"])
progress_bar = st.progress(0)
# Handle Company Data Input
if input_method == "Company Website":
website_url = st.text_input("π Enter Company Website URL")
if st.button("π Scrape Website"):
st.info("We are scraping the website, please wait...")
st.session_state.company_data = scrape_website(website_url)
progress_bar.progress(20)
elif input_method == "Web Search":
if st.button("π Search Company Online"):
st.info("We are searching the company details online, please wait...")
st.session_state.company_data = search_company(company_name)
progress_bar.progress(20)
elif input_method == "Manual Description":
company_description = st.text_area("π Enter Company Description")
if st.button("β Process Description"):
st.info("We are processing the description, please wait...")
st.session_state.company_data = process_company_description(company_description)
progress_bar.progress(20)
# **Execute All Phases Automatically After Company Data is Available**
if st.session_state.company_data:
st.subheader("β
Company Information Extracted")
st.write(st.session_state.company_data)
progress_bar.progress(40)
# **BNI Benefits & Recommendations** (Moved before AI)
try:
st.session_state.bni_benefits = get_bni_benefits(st.session_state.company_data)
# Call the RAG agent here:
st.session_state.bni_connections = recommend_bni_connections(st.session_state.company_data)
progress_bar.progress(60) # Updated progress position
except Exception as e:
print(f"β Error fetching BNI data: {e}")
st.session_state.bni_benefits = "No BNI data available."
st.session_state.bni_connections = "No relevant BNI connections found."
if st.session_state.bni_benefits:
st.subheader("π BNI Membership Benefits for Your Business")
st.write(st.session_state.bni_benefits)
if st.session_state.bni_connections:
st.subheader("π€ Recommended BNI Pearl Chapter Connections")
st.write(st.session_state.bni_connections)
progress_bar.progress(75) # Updated progress position
# Industry Analysis (Hidden from Frontend, but required for AI Strategy)
st.session_state.industry_trends = get_industry_trends(company_industry)
# AI Strategy & Implementation (Comes after BNI)
st.session_state.ai_strategy = generate_ai_strategy(
st.session_state.company_data, st.session_state.industry_trends)
# Revenue Opportunities
st.session_state.revenue_opportunities = identify_revenue_opportunities(
st.session_state.company_data, st.session_state.ai_strategy)
progress_bar.progress(90)
if st.session_state.ai_strategy:
st.subheader("π AI Strategy & Revenue Opportunities")
st.write(st.session_state.ai_strategy)
st.write(st.session_state.revenue_opportunities)
progress_bar.progress(95)
# Generate Final Report (Including BNI Data)
progress_bar.progress(99)
report_filename = generate_report(
company_name,
st.session_state.company_data,
st.session_state.ai_strategy,
st.session_state.revenue_opportunities,
st.session_state.bni_benefits,
st.session_state.bni_connections
)
st.success(f"π Report Generated: **{report_filename}**")
# Provide download button for the generated PDF
with open(report_filename, "rb") as pdf_file:
PDFbyte = pdf_file.read()
st.download_button(
label="π₯ Download AI Strategy Report (PDF)",
data=PDFbyte,
file_name=report_filename,
mime='application/octet-stream'
)
progress_bar.progress(100)
# Save Data to Hugging Face
if st.session_state.company_data and st.session_state.ai_strategy:
user_data = {
"name": name, "email": email, "mobile": mobile, "company_name": company_name,
"industry": company_industry, "input_method": input_method, "company_data": st.session_state.company_data,
"ai_strategy": st.session_state.ai_strategy,
"revenue_opportunities": st.session_state.revenue_opportunities,
"bni_benefits": st.session_state.bni_benefits,
"bni_connections": st.session_state.bni_connections # β add this
}
save_data_hf(user_data)
# Footer
st.markdown("---")
st.markdown("π **Powered by Giant Analytics | Contact Us: (+91) 96533 20500**")
if __name__ == "__main__":
main() |