Spaces:
Build error
Build error
File size: 4,876 Bytes
ae58099 cc9880e ae58099 cc9880e ae58099 cc9880e ae58099 cc9880e ae58099 |
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 |
import streamlit as st
from docx import Document
import re
import io
import os
from fpdf import FPDF
from groq import Groq
from exa_py import Exa
from dotenv import load_dotenv
from retrying import retry
from business_plan_functions import *
import json
# Load environment variables from .env file
load_dotenv()
# Declare the exa search API
exa = Exa(api_key=os.getenv("EXA_API_KEY"))
# Define your API Model and key
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
utilized_model = "llama3-70b-8192"
def strip_md(text):
text = text.replace("**", "").replace("*", "").replace("#", "")
return re.sub(r'([!*_=~-])', r'\\\1', text)
def create_document():
doc = Document()
doc.add_heading("Business Proposal", 0)
return doc
def add_section_to_doc(doc, section_name, section_content):
section_content = strip_md(section_content)
section_content = section_content.replace("\\", "") # Remove backslashes
doc.add_heading(section_name, level=1)
doc.add_paragraph(section_content)
return doc
def get_docx_bytes(doc):
doc_io = io.BytesIO()
doc.save(doc_io)
doc_io.seek(0)
return doc_io
def collect_basic_info():
st.title("Business Proposal Generator")
# Get the URL from the user
url = st.text_input("Enter the URL of the company's website")
if st.button('Submit'):
# Collect data from the provided URL
data = collect_business_info(url)
if data and isinstance(data, dict):
# Create a new document
doc = create_document()
# Process and update document with each section
sections_to_process = [
("Executive Summary", generate_executive_summary),
("Mission Statement", generate_mission),
("Vision Statement", generate_vision),
("Objectives", generate_objectives),
("Core Values", generate_core_values),
("Business Description Analysis", generate_business_description),
("Company Location", generate_company_location),
("Products", generate_products),
("Ownership", generate_ownership),
("Company Structure", generate_company_structure),
("Management Profiles", generate_management_profiles),
("Operational Strategy", generate_operational_strategy),
("Marketing Mix Strategy", generate_marketing_mix),
("Promotional Strategy", generate_promotional_strategy),
("Market Demand Analysis", analyze_demand),
("Market Segment Analysis", segment_market),
("Competitor Analysis", analyze_competitors),
("Porter's Five Forces Analysis", perform_porters_five_forces),
("Industry Analysis", analyze_industry_accommodation),
("Major Player Analysis", list_major_players),
("Business Sub Sector Analysis", analyze_business_sub_sector),
("SWOT Analysis", generate_swot_analysis),
("Funding Request", generate_funding_request),
("Financing & Bank Loan Amortization", create_financing_plan),
("Income Statement Analysis", generate_pro_forma_income_statement),
("Revenue Expense Analysis", predict_revenue_expenses),
("Monthly Cash Flow Analysis", generate_monthly_cash_flow),
("Pro Forma Annual Cash Flow Analysis", generate_pro_forma_annual_cash_flow),
("Pro Forma Balance Sheet Analysis", generate_pro_forma_balance_sheet),
("Break-Even Analysis", perform_break_even_analysis),
("Payback Period Analysis", calculate_payback_period),
("Financial Graphs Analysis", generate_financial_graphs),
("Risk Mitigations Analysis", identify_risks_mitigations)
]
for section_name, generate_prompt_func in sections_to_process:
prompt = generate_prompt_func(data)
section_content = call_llm(prompt)
st.subheader(section_name)
st.write(section_content)
# Update document and create download link
doc = add_section_to_doc(doc, section_name, section_content)
doc_bytes = get_docx_bytes(doc)
st.download_button(
label=f"Download {section_name} as DOCX",
data=doc_bytes,
file_name=f"{section_name.replace(' ', '_').lower()}.docx",
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
)
else:
st.error("Failed to collect business information from the provided URL.")
if __name__ == "__main__":
collect_basic_info() |