Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
from VisionaryAgent import search_company, scrape_website, process_company_description, process_uploaded_document
|
| 6 |
+
from VisionaryAgent import get_industry_trends, get_ai_use_cases, get_competitor_ai_strategies
|
| 7 |
+
from VisionaryAgent import generate_ai_strategy, suggest_ai_integration, identify_revenue_opportunities, generate_report
|
| 8 |
+
|
| 9 |
+
# Define data storage paths
|
| 10 |
+
CSV_FILE = "user_data.csv"
|
| 11 |
+
JSON_FILE = "user_data.json"
|
| 12 |
+
|
| 13 |
+
# Function to save data to CSV
|
| 14 |
+
def save_data_csv(data):
|
| 15 |
+
df = pd.DataFrame([data])
|
| 16 |
+
if os.path.exists(CSV_FILE):
|
| 17 |
+
df.to_csv(CSV_FILE, mode='a', header=False, index=False)
|
| 18 |
+
else:
|
| 19 |
+
df.to_csv(CSV_FILE, index=False)
|
| 20 |
+
|
| 21 |
+
# Function to save data to JSON
|
| 22 |
+
def save_data_json(data):
|
| 23 |
+
if os.path.exists(JSON_FILE):
|
| 24 |
+
with open(JSON_FILE, "r") as file:
|
| 25 |
+
existing_data = json.load(file)
|
| 26 |
+
else:
|
| 27 |
+
existing_data = []
|
| 28 |
+
|
| 29 |
+
existing_data.append(data)
|
| 30 |
+
with open(JSON_FILE, "w") as file:
|
| 31 |
+
json.dump(existing_data, file, indent=4)
|
| 32 |
+
|
| 33 |
+
# Streamlit UI
|
| 34 |
+
def main():
|
| 35 |
+
st.title("Visionary AI by Giant Analytics")
|
| 36 |
+
st.write("Fill in the details to generate an AI-driven business strategy report.")
|
| 37 |
+
st.write("It uses SOTA (State-of-the-Art) Reasoning Models to provide cutting-edge insights and AI integration strategies.")
|
| 38 |
+
# Collect User Information
|
| 39 |
+
name = st.text_input("Name")
|
| 40 |
+
email = st.text_input("Email")
|
| 41 |
+
mobile = st.text_input("Mobile Number")
|
| 42 |
+
company_name = st.text_input("Company Name")
|
| 43 |
+
|
| 44 |
+
# Select method to provide company details
|
| 45 |
+
input_method = st.radio("How would you like to provide company details?",
|
| 46 |
+
("Search by Name", "Website URL", "Manual Description", "Upload Document"))
|
| 47 |
+
|
| 48 |
+
company_data = ""
|
| 49 |
+
if input_method == "Search by Name":
|
| 50 |
+
if st.button("Find Company Details"):
|
| 51 |
+
company_data = search_company(company_name)
|
| 52 |
+
st.write(company_data)
|
| 53 |
+
elif input_method == "Website URL":
|
| 54 |
+
website_url = st.text_input("Enter Website URL")
|
| 55 |
+
if st.button("Scrape Website"):
|
| 56 |
+
company_data = scrape_website(website_url)
|
| 57 |
+
st.write(company_data)
|
| 58 |
+
elif input_method == "Manual Description":
|
| 59 |
+
company_data = st.text_area("Enter Company Description")
|
| 60 |
+
if st.button("Process Description"):
|
| 61 |
+
company_data = process_company_description(company_data)
|
| 62 |
+
st.write(company_data)
|
| 63 |
+
elif input_method == "Upload Document":
|
| 64 |
+
uploaded_file = st.file_uploader("Upload PDF or PPT", type=["pdf", "pptx"])
|
| 65 |
+
if uploaded_file is not None:
|
| 66 |
+
company_data = process_uploaded_document(uploaded_file)
|
| 67 |
+
st.write(company_data)
|
| 68 |
+
|
| 69 |
+
if company_data:
|
| 70 |
+
industry = st.text_input("Industry Type (e.g., Healthcare, Finance)")
|
| 71 |
+
if st.button("Analyze Industry Trends"):
|
| 72 |
+
industry_trends = get_industry_trends(industry)
|
| 73 |
+
st.write(industry_trends)
|
| 74 |
+
|
| 75 |
+
if st.button("Find AI Use Cases"):
|
| 76 |
+
ai_use_cases = get_ai_use_cases(industry)
|
| 77 |
+
st.write(ai_use_cases)
|
| 78 |
+
|
| 79 |
+
competitor = st.text_input("Enter Competitor Name")
|
| 80 |
+
if st.button("Analyze Competitor AI Strategies"):
|
| 81 |
+
competitor_analysis = get_competitor_ai_strategies(competitor)
|
| 82 |
+
st.write(competitor_analysis)
|
| 83 |
+
|
| 84 |
+
if st.button("Generate AI Strategy"):
|
| 85 |
+
ai_strategy = generate_ai_strategy(company_data, industry_trends, ai_use_cases, competitor_analysis)
|
| 86 |
+
st.write(ai_strategy)
|
| 87 |
+
|
| 88 |
+
if st.button("Suggest AI Integration Plan"):
|
| 89 |
+
ai_integration = suggest_ai_integration(company_data, ai_strategy)
|
| 90 |
+
st.write(ai_integration)
|
| 91 |
+
|
| 92 |
+
if st.button("Identify Revenue Growth Opportunities"):
|
| 93 |
+
revenue_opportunities = identify_revenue_opportunities(company_data, ai_strategy)
|
| 94 |
+
st.write(revenue_opportunities)
|
| 95 |
+
|
| 96 |
+
if st.button("Generate Final Report"):
|
| 97 |
+
report_filename = generate_report(company_name, ai_strategy, ai_integration, revenue_opportunities)
|
| 98 |
+
st.success(f"Report Generated: {report_filename}")
|
| 99 |
+
|
| 100 |
+
# Save data to backend
|
| 101 |
+
user_data = {
|
| 102 |
+
"name": name,
|
| 103 |
+
"email": email,
|
| 104 |
+
"mobile": mobile,
|
| 105 |
+
"company_name": company_name,
|
| 106 |
+
"company_data": company_data,
|
| 107 |
+
"industry": industry,
|
| 108 |
+
"competitor": competitor,
|
| 109 |
+
"ai_strategy": ai_strategy,
|
| 110 |
+
"ai_integration": ai_integration,
|
| 111 |
+
"revenue_opportunities": revenue_opportunities
|
| 112 |
+
}
|
| 113 |
+
save_data_csv(user_data)
|
| 114 |
+
save_data_json(user_data)
|
| 115 |
+
|
| 116 |
+
if __name__ == "__main__":
|
| 117 |
+
main()
|