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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import docx
|
| 3 |
+
import re
|
| 4 |
+
import tempfile
|
| 5 |
+
import pathlib
|
| 6 |
+
import os
|
| 7 |
+
import io
|
| 8 |
+
import fpdf
|
| 9 |
+
import time
|
| 10 |
+
from groq import Groq
|
| 11 |
+
from exa_py import Exa
|
| 12 |
+
from string import Template
|
| 13 |
+
from dotenv import load_dotenv
|
| 14 |
+
from retrying import retry
|
| 15 |
+
from funtions import *
|
| 16 |
+
from fpdf import FPDF
|
| 17 |
+
fpdf.set_global("UTF8", True)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# Load environment variables from .env file
|
| 21 |
+
load_dotenv()
|
| 22 |
+
|
| 23 |
+
#declare the exa search api
|
| 24 |
+
exa = Exa(api_key=os.getenv("EXA_API_KEY"))
|
| 25 |
+
|
| 26 |
+
# Define your API Model and key (replace 'your-api-key' with the actual key)
|
| 27 |
+
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
| 28 |
+
utilized_model = "llama3-70b-8192"
|
| 29 |
+
|
| 30 |
+
#the file path that contains the prompt
|
| 31 |
+
file_path = os.path.join(os.getcwd(), "plugins/modular_business_proposal")
|
| 32 |
+
|
| 33 |
+
#Functions for the Exa Search content & Parameters for our Highlights search
|
| 34 |
+
highlights_options = {
|
| 35 |
+
"num_sentences": 7, # how long our highlights should be
|
| 36 |
+
"highlights_per_url": 1, # just get the best highlight for each URL
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
@retry(wait_exponential_multiplier=1000, wait_exponential_max=10000, stop_max_attempt_number=5)
|
| 40 |
+
def call_llm(prompt):
|
| 41 |
+
|
| 42 |
+
proposal_parts = []
|
| 43 |
+
#for question in questions:
|
| 44 |
+
#Insert input data into placeholder in question prompts
|
| 45 |
+
|
| 46 |
+
search_response = exa.search_and_contents(query=prompt, highlights=highlights_options, num_results=3, use_autoprompt=True)
|
| 47 |
+
info = [sr.highlights[0] for sr in search_response.results]
|
| 48 |
+
|
| 49 |
+
system_prompt = "You are a Business proposal generator. Read the provided contexts and, if relevant, use them to answer the user's question."
|
| 50 |
+
user_prompt = f"Sources: {info}\nQuestion: {prompt}"
|
| 51 |
+
|
| 52 |
+
completion = client.chat.completions.create(
|
| 53 |
+
model=utilized_model,
|
| 54 |
+
messages=[
|
| 55 |
+
{"role": "system", "content": system_prompt},
|
| 56 |
+
{"role": "user", "content": user_prompt},
|
| 57 |
+
]
|
| 58 |
+
)
|
| 59 |
+
#taking out this Question: {prompt}\n to check if the output will change
|
| 60 |
+
response = f"Answer: {completion.choices[0].message.content}\n\n"
|
| 61 |
+
proposal_parts.append(response)
|
| 62 |
+
|
| 63 |
+
proposal_text = "\n\n".join(proposal_parts)
|
| 64 |
+
return proposal_text
|
| 65 |
+
|
| 66 |
+
# Function to strip markdown and unescape characters
|
| 67 |
+
def strip_md(text):
|
| 68 |
+
text = text.replace("**", "") # remove bold syntax
|
| 69 |
+
text = text.replace("*", "") # remove italic syntax
|
| 70 |
+
text = text.replace("#", "") # remove headings
|
| 71 |
+
text = re.sub(r'([!*_=~-])', r'\\\1', text)
|
| 72 |
+
return text
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def collect_basic_info():
|
| 76 |
+
st.title("Business Proposal Generator")
|
| 77 |
+
|
| 78 |
+
st.header("Basic Company Information")
|
| 79 |
+
company_name = st.text_input("Company Name")
|
| 80 |
+
industry = st.text_input("Industry")
|
| 81 |
+
location = st.text_input("Location")
|
| 82 |
+
|
| 83 |
+
st.header("Mission and Vision")
|
| 84 |
+
mission = st.text_area("Mission Statement")
|
| 85 |
+
vision = st.text_area("Vision Statement")
|
| 86 |
+
|
| 87 |
+
st.header("Products or Services")
|
| 88 |
+
products_services = st.text_area("Description of Products/Services")
|
| 89 |
+
|
| 90 |
+
st.header("Target Market")
|
| 91 |
+
target_market = st.text_area("Customer Segments (e.g., demographics, location)")
|
| 92 |
+
|
| 93 |
+
st.header("Unique Value Proposition")
|
| 94 |
+
value_proposition = st.text_area("Competitive Advantage")
|
| 95 |
+
|
| 96 |
+
st.header("Promotional Strategy")
|
| 97 |
+
promotional_strategy=st.text_area("Mention your potential Promotional Strategy")
|
| 98 |
+
|
| 99 |
+
st.header("Financial Information")
|
| 100 |
+
current_revenue = st.number_input("Current Revenue (R)", min_value=0.0, format="%f")
|
| 101 |
+
current_expenses = st.number_input("Current Expenses (R)", min_value=0.0, format="%f")
|
| 102 |
+
funding_requirements = st.text_area("Funding Requirements")
|
| 103 |
+
|
| 104 |
+
st.header("Management Team")
|
| 105 |
+
management_team = st.text_area("Key Personnel (name and roles)")
|
| 106 |
+
|
| 107 |
+
st.header("Company Structure")
|
| 108 |
+
company_structure=st.text_area("What is your organizational structure")
|
| 109 |
+
|
| 110 |
+
st.header("Goals and Objectives")
|
| 111 |
+
goals_objectives = st.text_area("Short-term and Long-term Goals")
|
| 112 |
+
|
| 113 |
+
st.header("Operational Plan")
|
| 114 |
+
operational_strategy = st.text_area("Basic Operational Strategy")
|
| 115 |
+
|
| 116 |
+
st.header("Market Analysis")
|
| 117 |
+
market_overview = st.text_area("Brief Market Overview (size, trends, etc.)")
|
| 118 |
+
|
| 119 |
+
if st.button('Submit'):
|
| 120 |
+
# Process the collected data
|
| 121 |
+
data = {
|
| 122 |
+
"company_name": company_name,
|
| 123 |
+
"industry": industry,
|
| 124 |
+
"location": location,
|
| 125 |
+
"mission": mission,
|
| 126 |
+
"vision": vision,
|
| 127 |
+
"products_services": products_services,
|
| 128 |
+
"target_market": target_market,
|
| 129 |
+
"value_proposition": value_proposition,
|
| 130 |
+
"current_revenue": current_revenue,
|
| 131 |
+
"current_expenses": current_expenses,
|
| 132 |
+
"funding_requirements": funding_requirements,
|
| 133 |
+
"management_team": management_team,
|
| 134 |
+
"goals_objectives": goals_objectives,
|
| 135 |
+
"operational_strategy": operational_strategy,
|
| 136 |
+
"market_overview": market_overview,
|
| 137 |
+
"company_structure":company_structure,
|
| 138 |
+
"promotional_strategy":promotional_strategy
|
| 139 |
+
}
|
| 140 |
+
st.write("Collected Information:", data)
|
| 141 |
+
# Further processing can be done here (e.g., calling AI to generate the business proposal)
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
st.title("Business Proposal Generator")
|
| 145 |
+
|
| 146 |
+
#output=call_llm(data)
|
| 147 |
+
#st.write(output)
|
| 148 |
+
# Generate and display executive summary
|
| 149 |
+
exec_summary_prompt = generate_executive_summary(data)
|
| 150 |
+
executive_summary = call_llm(exec_summary_prompt)
|
| 151 |
+
st.subheader("Executive Summary")
|
| 152 |
+
st.write(executive_summary)
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
#2. Mission, Objectives, and Keys to Success
|
| 157 |
+
|
| 158 |
+
#Mission Statement:
|
| 159 |
+
|
| 160 |
+
mission_prompt =generate_mission(data)
|
| 161 |
+
mission_analysis = call_llm(mission_prompt)
|
| 162 |
+
st.subheader("Mission Statement")
|
| 163 |
+
st.write(mission_analysis)
|
| 164 |
+
|
| 165 |
+
#Vision Statement:
|
| 166 |
+
vision_statement_prompt = generate_vision(data)
|
| 167 |
+
vision_analysis = call_llm(vision_statement_prompt)
|
| 168 |
+
st.subheader("Vision Statement:")
|
| 169 |
+
st.write(vision_analysis)
|
| 170 |
+
|
| 171 |
+
#Objectives
|
| 172 |
+
objectives_prompt= generate_objectives(data)
|
| 173 |
+
objectives_analysis = call_llm(objectives_prompt)
|
| 174 |
+
st.subheader("Objectives")
|
| 175 |
+
st.write(objectives_analysis)
|
| 176 |
+
|
| 177 |
+
#Core Values:
|
| 178 |
+
core_values_prompt = generate_core_values(data)
|
| 179 |
+
core_values_analysis = call_llm(core_values_prompt)
|
| 180 |
+
st.subheader("Core Values:")
|
| 181 |
+
st.write(core_values_analysis)
|
| 182 |
+
|
| 183 |
+
#3. Company Summary
|
| 184 |
+
#Business Description
|
| 185 |
+
business_description_prompt = generate_business_description(data)
|
| 186 |
+
business_description_analysis = call_llm(business_description_prompt)
|
| 187 |
+
st.subheader("Business Descrtiption Analysis")
|
| 188 |
+
st.write(business_description_analysis)
|
| 189 |
+
|
| 190 |
+
#Company Location:
|
| 191 |
+
|
| 192 |
+
company_location_prompt = generate_company_location(data)
|
| 193 |
+
company_location_analysis = call_llm(company_location_prompt)
|
| 194 |
+
st.subheader("Company location")
|
| 195 |
+
st.write(company_location_analysis)
|
| 196 |
+
|
| 197 |
+
#Products:
|
| 198 |
+
products_prompt = generate_products(data)
|
| 199 |
+
products_analysis = call_llm(products_prompt)
|
| 200 |
+
st.subheader("Products")
|
| 201 |
+
st.write(products_analysis)
|
| 202 |
+
|
| 203 |
+
#Ownership:
|
| 204 |
+
ownership_prompt = generate_ownership(data)
|
| 205 |
+
owner_analysis = call_llm(ownership_prompt)
|
| 206 |
+
st.subheader("Ownership")
|
| 207 |
+
st.write(owner_analysis)
|
| 208 |
+
|
| 209 |
+
#Company Structure:
|
| 210 |
+
company_structure_prompt = generate_company_structure(data)
|
| 211 |
+
company_structure_analysis = call_llm(company_structure_prompt)
|
| 212 |
+
st.subheader("Company Structure")
|
| 213 |
+
st.write(company_structure_analysis)
|
| 214 |
+
|
| 215 |
+
#Management Profiles:
|
| 216 |
+
management_profile_prompt = generate_management_profiles(data)
|
| 217 |
+
management_profile_analysis = call_llm(management_profile_prompt)
|
| 218 |
+
st.subheader("Management Profiles")
|
| 219 |
+
st.write(management_profile_analysis)
|
| 220 |
+
|
| 221 |
+
#4. Operational Strategy
|
| 222 |
+
operational_strategy_prompt = generate_operational_strategy(data)
|
| 223 |
+
operational_strategy_analysis = call_llm(operational_strategy_prompt)
|
| 224 |
+
st.subheader("Operational Strategy Analysis")
|
| 225 |
+
st.write(operational_strategy_analysis)
|
| 226 |
+
|
| 227 |
+
#5. Marketing Strategy
|
| 228 |
+
#Marketing Mix:
|
| 229 |
+
marketing_prompt = generate_marketing_mix(data)
|
| 230 |
+
marketing_analysis = call_llm(marketing_prompt)
|
| 231 |
+
st.subheader("Marketing Mix Strategy")
|
| 232 |
+
st.write(marketing_analysis)
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
#Promotional Strategy:
|
| 236 |
+
promotional_prompt = generate_promotional_strategy(data)
|
| 237 |
+
promotional_analysis = call_llm(promotional_prompt)
|
| 238 |
+
st.subheader("Promotional Strategy")
|
| 239 |
+
st.write(promotional_analysis)
|
| 240 |
+
|
| 241 |
+
#6. Market Analysis
|
| 242 |
+
#Demand Analysis:
|
| 243 |
+
analyze_demand_prompt = analyze_demand(data)
|
| 244 |
+
analyze_demand_analysis = call_llm(analyze_demand_prompt)
|
| 245 |
+
st.subheader("Demand Analysis")
|
| 246 |
+
st.write(analyze_demand_analysis)
|
| 247 |
+
|
| 248 |
+
#Market Segmentation:
|
| 249 |
+
segment_market_prompt = segment_market(data)
|
| 250 |
+
segment_market_analysis = call_llm(segment_market_prompt)
|
| 251 |
+
st.subheader("Market Segment Analysis")
|
| 252 |
+
st.write(segment_market_analysis)
|
| 253 |
+
|
| 254 |
+
#Competitor Analysis:
|
| 255 |
+
competitor_analysis_prompt = analyze_competitors(data)
|
| 256 |
+
competitor_analysis = call_llm(competitor_analysis_prompt)
|
| 257 |
+
st.subheader("Competitor Analysis")
|
| 258 |
+
st.write(competitor_analysis)
|
| 259 |
+
|
| 260 |
+
#Porter's Five Forces:
|
| 261 |
+
porters_prompt =perform_porters_five_forces(data)
|
| 262 |
+
porters_analysis = call_llm(porters_prompt)
|
| 263 |
+
st.subheader("Porter's Five Forces Analysis")
|
| 264 |
+
st.write(porters_analysis)
|
| 265 |
+
|
| 266 |
+
#7. Industry Analysis
|
| 267 |
+
#Industry Accommodation:
|
| 268 |
+
st.subheader("Industry Analysis")
|
| 269 |
+
industry_accommodation_prompt = analyze_industry_accommodation(data)
|
| 270 |
+
industry_accommodation_analysis = call_llm(industry_accommodation_prompt)
|
| 271 |
+
st.write(industry_accommodation_analysis)
|
| 272 |
+
#Major Players:
|
| 273 |
+
st.subheader("Major Players")
|
| 274 |
+
list_major_players_prompt = list_major_players(data)
|
| 275 |
+
list_major_players_analysis = call_llm(list_major_players_prompt)
|
| 276 |
+
st.write(list_major_players_analysis)
|
| 277 |
+
|
| 278 |
+
#Business Sub-Sector in Lesotho:
|
| 279 |
+
st.subheader("Business Sub-Sector Analysis")
|
| 280 |
+
business_sub_sector_analysis_prompt = analyze_business_sub_sector(data)
|
| 281 |
+
business_sub_sector_analysis = call_llm(business_sub_sector_analysis_prompt)
|
| 282 |
+
st.write(business_sub_sector_analysis)
|
| 283 |
+
|
| 284 |
+
#8. SWOT Analysis
|
| 285 |
+
# Generate and display SWOT analysis
|
| 286 |
+
swot_prompt = generate_swot_analysis(data)
|
| 287 |
+
swot_analysis = call_llm(swot_prompt)
|
| 288 |
+
st.subheader("SWOT Analysis")
|
| 289 |
+
st.write(swot_analysis)
|
| 290 |
+
|
| 291 |
+
#9Financial Statements
|
| 292 |
+
#Funding Request:
|
| 293 |
+
st.subheader("Funding Request")
|
| 294 |
+
funding_request_prompt = generate_funding_request(data)
|
| 295 |
+
funding_request_analysis = call_llm(funding_request_prompt)
|
| 296 |
+
st.write(funding_request_analysis)
|
| 297 |
+
|
| 298 |
+
#Financing & Bank Loan Amortization:
|
| 299 |
+
st.subheader("Financing & Bank Loan Amortization")
|
| 300 |
+
financing_plan_prompt = create_financing_plan(data)
|
| 301 |
+
financing_plan_analysis = call_llm(financing_plan_prompt)
|
| 302 |
+
st.write(financing_plan_analysis)
|
| 303 |
+
|
| 304 |
+
#Pro Forma Income Statement:
|
| 305 |
+
st.subheader("Pro Forma Income Statement")
|
| 306 |
+
pro_forma_income_statement_prompt = generate_pro_forma_income_statement(data)
|
| 307 |
+
pro_forma_income_statement_analysis = call_llm(pro_forma_income_statement_prompt)
|
| 308 |
+
st.write(pro_forma_income_statement_analysis)
|
| 309 |
+
|
| 310 |
+
#10. Assumptions/Predictions
|
| 311 |
+
#Revenue and Expenses Predictions:
|
| 312 |
+
st.subheader("Revenue and Expenses Predictions")
|
| 313 |
+
predict_revenue_expenses_prompt = predict_revenue_expenses(data)
|
| 314 |
+
predict_revenue_expenses_analysis = call_llm(predict_revenue_expenses_prompt)
|
| 315 |
+
st.write(predict_revenue_expenses_analysis)
|
| 316 |
+
|
| 317 |
+
#Monthly Cash Flow Statement:
|
| 318 |
+
st.subheader("Monthly Cash Flow Statement")
|
| 319 |
+
monthly_cash_flow_prompt = generate_monthly_cash_flow(data)
|
| 320 |
+
monthly_cash_flow_analysis = call_llm(monthly_cash_flow_prompt)
|
| 321 |
+
st.write(monthly_cash_flow_analysis)
|
| 322 |
+
|
| 323 |
+
#Pro Forma Annual Cash Flow:
|
| 324 |
+
st.subheader("Pro Forma Annual Cash Flow")
|
| 325 |
+
pro_forma_annual_cash_flow_prompt = generate_pro_forma_annual_cash_flow(data)
|
| 326 |
+
pro_forma_annual_cash_flow_analysis = call_llm(pro_forma_annual_cash_flow_prompt)
|
| 327 |
+
st.write(pro_forma_annual_cash_flow_analysis)
|
| 328 |
+
|
| 329 |
+
#Pro Forma Balance Sheet:
|
| 330 |
+
st.subheader("Pro Forma Balance Sheet")
|
| 331 |
+
pro_forma_balance_sheet_prompt = generate_pro_forma_balance_sheet(data)
|
| 332 |
+
pro_forma_balance_sheet_analysis = call_llm(pro_forma_balance_sheet_prompt)
|
| 333 |
+
st.write(pro_forma_balance_sheet_analysis)
|
| 334 |
+
|
| 335 |
+
#Break Even Analysis:
|
| 336 |
+
st.subheader("Break Even Analysis")
|
| 337 |
+
break_even_analysis_prompt = perform_break_even_analysis(data)
|
| 338 |
+
break_even_analysis = call_llm(break_even_analysis_prompt)
|
| 339 |
+
st.write(break_even_analysis)
|
| 340 |
+
|
| 341 |
+
#Payback Period Analysis:
|
| 342 |
+
payback_period_prompt = calculate_payback_period(data)
|
| 343 |
+
payback_period_analysis = call_llm(payback_period_prompt)
|
| 344 |
+
st.subheader("Payback Period Analysis")
|
| 345 |
+
st.write(payback_period_analysis)
|
| 346 |
+
|
| 347 |
+
#Financial Graphs:
|
| 348 |
+
financial_graphs_prompt = generate_financial_graphs(data)
|
| 349 |
+
financial_graphs_analysis = call_llm(financial_graphs_prompt)
|
| 350 |
+
st.subheader("Financial Graphs")
|
| 351 |
+
st.write(financial_graphs_analysis)
|
| 352 |
+
|
| 353 |
+
#11. Risk and Mitigatory Measures
|
| 354 |
+
risk_mitigations_prompt = identify_risks_mitigations(data)
|
| 355 |
+
risk_mitigations_analysis = call_llm(risk_mitigations_prompt)
|
| 356 |
+
st.subheader("Risk and Mitigatory Measures")
|
| 357 |
+
st.write(risk_mitigations_analysis)
|
| 358 |
+
|
| 359 |
+
# Create a PDF object
|
| 360 |
+
pdf = FPDF()
|
| 361 |
+
|
| 362 |
+
# Add a page
|
| 363 |
+
pdf.add_page()
|
| 364 |
+
|
| 365 |
+
# Set font
|
| 366 |
+
pdf.set_font("Arial", size=12)
|
| 367 |
+
|
| 368 |
+
# Add title
|
| 369 |
+
pdf.cell(0, 10, txt="Business Proposal", ln=True, align="C")
|
| 370 |
+
pdf.ln(10)
|
| 371 |
+
|
| 372 |
+
# Add sections
|
| 373 |
+
sections = [
|
| 374 |
+
executive_summary,
|
| 375 |
+
mission_analysis,
|
| 376 |
+
vision_analysis,
|
| 377 |
+
objectives_analysis,
|
| 378 |
+
core_values_analysis,
|
| 379 |
+
business_description_analysis,
|
| 380 |
+
company_location_analysis,
|
| 381 |
+
products_analysis,
|
| 382 |
+
owner_analysis,
|
| 383 |
+
company_structure_analysis,
|
| 384 |
+
management_profile_analysis,
|
| 385 |
+
operational_strategy_analysis,
|
| 386 |
+
marketing_analysis,
|
| 387 |
+
promotional_analysis,
|
| 388 |
+
analyze_demand_analysis,
|
| 389 |
+
segment_market_analysis,
|
| 390 |
+
competitor_analysis,
|
| 391 |
+
porters_analysis,
|
| 392 |
+
industry_accommodation_analysis,
|
| 393 |
+
list_major_players_analysis,
|
| 394 |
+
business_sub_sector_analysis,
|
| 395 |
+
swot_analysis,
|
| 396 |
+
|
| 397 |
+
funding_request_analysis,
|
| 398 |
+
financing_plan_analysis,
|
| 399 |
+
pro_forma_income_statement_analysis,
|
| 400 |
+
predict_revenue_expenses_analysis,
|
| 401 |
+
monthly_cash_flow_analysis,
|
| 402 |
+
pro_forma_annual_cash_flow_analysis,
|
| 403 |
+
pro_forma_balance_sheet_analysis,
|
| 404 |
+
break_even_analysis,
|
| 405 |
+
payback_period_analysis,
|
| 406 |
+
financial_graphs_analysis,
|
| 407 |
+
risk_mitigations_analysis
|
| 408 |
+
]
|
| 409 |
+
#Section Subheader title
|
| 410 |
+
section_headers = {
|
| 411 |
+
"executive_summary":"Executive Summary",
|
| 412 |
+
"mission_analysis":"Mission Statement",
|
| 413 |
+
"vision_analysis":"Vision Statement",
|
| 414 |
+
"objectives_analysis":"Objectives",
|
| 415 |
+
"core_values_analysis":"Core values",
|
| 416 |
+
"business_description_analysis":"Business Description Analysis",
|
| 417 |
+
"company_location_analysis":"Company Location",
|
| 418 |
+
"products_analysis":"Products",
|
| 419 |
+
"owner_analysis":"Ownership",
|
| 420 |
+
"company_structure_analysis":"Company Structure",
|
| 421 |
+
"management_profile_analysis":"Management Profiles",
|
| 422 |
+
"operational_strategy_analysis":"Operational Strategy",
|
| 423 |
+
"marketing_analysis":"Marketing Mix Strategy",
|
| 424 |
+
"promotional_analysis":"Promotional Strategy",
|
| 425 |
+
"analyze_demand_analysis":"Market Demand Analysis",
|
| 426 |
+
"segment_market_analysis":"Market Segment Analysis",
|
| 427 |
+
"competitor_analysis":"Competitors Analysi",
|
| 428 |
+
"porters_analysis":"Porter's Five Forces Analysis",
|
| 429 |
+
"industry_accommodation_analysis":"Industry Analysis",
|
| 430 |
+
"list_major_players_analysis":"Major Player Analysis",
|
| 431 |
+
"business_sub_sector_analysis": "Business Sub Sector Analysis",
|
| 432 |
+
"swot_analysis":"Swot Analysis",
|
| 433 |
+
"funding_request_analysis":"Funding Request",
|
| 434 |
+
"financing_plan_analysis":"Financing & Bank Loan Amortization",
|
| 435 |
+
"pro_forma_income_statement_analysis":"Income Statement Analysis",
|
| 436 |
+
"predict_revenue_expenses_analysis":"Revenue Expense Analysis",
|
| 437 |
+
"monthly_cash_flow_analysis":"Montly Cash Flow Analysis",
|
| 438 |
+
"pro_forma_annual_cash_flow_analysis": "Pro Forma Annual Cash Flow Analysis",
|
| 439 |
+
"pro_forma_balance_sheet_analysis": "Pro Forma Balance Sheet Analysis",
|
| 440 |
+
"break_even_analysis": "Break-Even Analysis",
|
| 441 |
+
"payback_period_analysis": "Payback Period Analysis",
|
| 442 |
+
"financial_graphs_analysis": "Financial Graphs Analysis",
|
| 443 |
+
"risk_mitigations_analysis": "Risk Mitigations Analysis"
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
|
| 448 |
+
|
| 449 |
+
# Create a Word document
|
| 450 |
+
doc = docx.Document()
|
| 451 |
+
|
| 452 |
+
# Add title
|
| 453 |
+
doc.add_heading("Business Proposal", 0)
|
| 454 |
+
|
| 455 |
+
# Add sections
|
| 456 |
+
for section in sections:
|
| 457 |
+
header_text = "" # Initialize an empty string
|
| 458 |
+
for key, value in section_headers.items():
|
| 459 |
+
if section == eval(key): # Match variable names from sections list with keys of section_headers dictionary
|
| 460 |
+
header_text = value # Assign the value of the key to header_text
|
| 461 |
+
break
|
| 462 |
+
|
| 463 |
+
|
| 464 |
+
|
| 465 |
+
# Add a Heading 3 for the subheader
|
| 466 |
+
doc.add_heading(header_text, 3)
|
| 467 |
+
|
| 468 |
+
# Remove Markdown formatting
|
| 469 |
+
section = strip_md(section)
|
| 470 |
+
section = section.replace("\\", "") # Remove backslashes
|
| 471 |
+
|
| 472 |
+
p = doc.add_paragraph("")
|
| 473 |
+
|
| 474 |
+
# Check if the section contains bold or italic text
|
| 475 |
+
parts = section.split("**")
|
| 476 |
+
p = doc.add_paragraph("")
|
| 477 |
+
for part in parts:
|
| 478 |
+
if part:
|
| 479 |
+
if parts.index(part) % 2 == 1:
|
| 480 |
+
# Add bold text
|
| 481 |
+
p.add_run(part).bold = True
|
| 482 |
+
else:
|
| 483 |
+
# Add non-bold text
|
| 484 |
+
p.add_run(part)
|
| 485 |
+
|
| 486 |
+
# Check if the section contains headings
|
| 487 |
+
if "#" in section:
|
| 488 |
+
heading_parts = section.split("#")
|
| 489 |
+
for part in heading_parts:
|
| 490 |
+
if part:
|
| 491 |
+
level = heading_parts.index(part) + 1
|
| 492 |
+
doc.add_heading(part, level)
|
| 493 |
+
|
| 494 |
+
|
| 495 |
+
|
| 496 |
+
# Check if the section contains tables
|
| 497 |
+
if "|" in section:
|
| 498 |
+
# Split the text into table rows
|
| 499 |
+
rows = section.split("\n")
|
| 500 |
+
table = doc.add_table(rows=1, cols=len(rows[0].split("|")))
|
| 501 |
+
# Initialize your table
|
| 502 |
+
table = doc.tables[0] # Assuming you have a Word document with tables
|
| 503 |
+
|
| 504 |
+
num_rows = len(table.rows)
|
| 505 |
+
num_cols = len(table.columns)
|
| 506 |
+
for row_idx in range(num_rows):
|
| 507 |
+
for col_idx in range(num_cols):
|
| 508 |
+
cell = section.split("\n")[row_idx].split("|")[col_idx]
|
| 509 |
+
table.cell(row_idx, col_idx).text = cell
|
| 510 |
+
|
| 511 |
+
# Save the Word document to a BytesIO object
|
| 512 |
+
mem_file = io.BytesIO()
|
| 513 |
+
doc.save(mem_file)
|
| 514 |
+
mem_file.seek(0)
|
| 515 |
+
|
| 516 |
+
# Create a download button
|
| 517 |
+
st.download_button("Download Business Proposal (Word)", mem_file.getvalue(), "business_proposal.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|
| 518 |
+
|
| 519 |
+
|
| 520 |
+
|
| 521 |
+
|
| 522 |
+
if __name__ == "__main__":
|
| 523 |
+
collect_basic_info()
|