sosa123454321 commited on
Commit
a38df1c
·
verified ·
1 Parent(s): 97cb039

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +93 -447
app.py CHANGED
@@ -1,48 +1,33 @@
1
  import streamlit as st
2
  from docx import Document
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
 
@@ -56,68 +41,54 @@ def call_llm(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,
@@ -131,393 +102,68 @@ def collect_basic_info():
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 = 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()
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from docx import Document
3
  import re
 
 
 
4
  import io
5
+ import os
6
+ from fpdf import FPDF
7
  from groq import Groq
8
  from exa_py import Exa
 
9
  from dotenv import load_dotenv
10
  from retrying import retry
11
  from funtions import *
 
 
 
12
 
13
  # Load environment variables from .env file
14
  load_dotenv()
15
 
16
+ # Declare the exa search API
17
  exa = Exa(api_key=os.getenv("EXA_API_KEY"))
18
 
19
+ # Define your API Model and key
20
  client = Groq(api_key=os.getenv("GROQ_API_KEY"))
21
  utilized_model = "llama3-70b-8192"
22
 
23
+ # Functions for the Exa Search content & Parameters for Highlights search
 
 
 
24
  highlights_options = {
25
+ "num_sentences": 7, # Length of highlights
26
+ "highlights_per_url": 1, # Get the best highlight for each URL
27
  }
28
 
29
  @retry(wait_exponential_multiplier=1000, wait_exponential_max=10000, stop_max_attempt_number=5)
30
  def call_llm(prompt):
 
 
 
 
 
31
  search_response = exa.search_and_contents(query=prompt, highlights=highlights_options, num_results=3, use_autoprompt=True)
32
  info = [sr.highlights[0] for sr in search_response.results]
33
 
 
41
  {"role": "user", "content": user_prompt},
42
  ]
43
  )
44
+ return completion.choices[0].message.content
 
 
 
 
 
45
 
 
46
  def strip_md(text):
47
+ text = text.replace("**", "").replace("*", "").replace("#", "")
48
+ return re.sub(r'([!*_=~-])', r'\\\1', text)
49
+
50
+ def create_document():
51
+ doc = Document()
52
+ doc.add_heading("Business Proposal", 0)
53
+ return doc
54
+
55
+ def add_section_to_doc(doc, section_name, section_content):
56
+ section_content = strip_md(section_content)
57
+ section_content = section_content.replace("\\", "") # Remove backslashes
58
+ doc.add_heading(section_name, level=1)
59
+ doc.add_paragraph(section_content)
60
+ return doc
61
+
62
+ def get_docx_bytes(doc):
63
+ doc_io = io.BytesIO()
64
+ doc.save(doc_io)
65
+ doc_io.seek(0)
66
+ return doc_io
67
 
68
  def collect_basic_info():
69
  st.title("Business Proposal Generator")
70
 
71
+ # Basic Company Information
72
  company_name = st.text_input("Company Name")
73
  industry = st.text_input("Industry")
74
  location = st.text_input("Location")
 
 
75
  mission = st.text_area("Mission Statement")
76
  vision = st.text_area("Vision Statement")
 
 
77
  products_services = st.text_area("Description of Products/Services")
78
+ target_market = st.text_area("Customer Segments")
 
 
 
 
79
  value_proposition = st.text_area("Competitive Advantage")
80
+ promotional_strategy = st.text_area("Promotional Strategy")
 
 
 
 
81
  current_revenue = st.number_input("Current Revenue (R)", min_value=0.0, format="%f")
82
  current_expenses = st.number_input("Current Expenses (R)", min_value=0.0, format="%f")
83
  funding_requirements = st.text_area("Funding Requirements")
84
+ management_team = st.text_area("Key Personnel")
85
+ company_structure = st.text_area("Company Structure")
 
 
 
 
 
 
86
  goals_objectives = st.text_area("Short-term and Long-term Goals")
87
+ operational_strategy = st.text_area("Operational Strategy")
88
+ market_overview = st.text_area("Market Overview")
 
 
 
 
89
 
90
  if st.button('Submit'):
91
+ # Collect data
92
  data = {
93
  "company_name": company_name,
94
  "industry": industry,
 
102
  "current_expenses": current_expenses,
103
  "funding_requirements": funding_requirements,
104
  "management_team": management_team,
105
+ "company_structure": company_structure,
106
  "goals_objectives": goals_objectives,
107
  "operational_strategy": operational_strategy,
108
  "market_overview": market_overview,
109
+ "promotional_strategy": promotional_strategy
 
110
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
+ # Create a new document
113
+ doc = create_document()
114
+
115
+ # Process and update document with each section
116
+ sections_to_process = [
117
+ ("Executive Summary", generate_executive_summary),
118
+ ("Mission Statement", generate_mission),
119
+ ("Vision Statement", generate_vision),
120
+ ("Objectives", generate_objectives),
121
+ ("Core Values", generate_core_values),
122
+ ("Business Description Analysis", generate_business_description),
123
+ ("Company Location", generate_company_location),
124
+ ("Products", generate_products),
125
+ ("Ownership", generate_ownership),
126
+ ("Company Structure", generate_company_structure),
127
+ ("Management Profiles", generate_management_profiles),
128
+ ("Operational Strategy", generate_operational_strategy),
129
+ ("Marketing Mix Strategy", generate_marketing_mix),
130
+ ("Promotional Strategy", generate_promotional_strategy),
131
+ ("Market Demand Analysis", analyze_demand),
132
+ ("Market Segment Analysis", segment_market),
133
+ ("Competitor Analysis", analyze_competitors),
134
+ ("Porter's Five Forces Analysis", perform_porters_five_forces),
135
+ ("Industry Analysis", analyze_industry_accommodation),
136
+ ("Major Player Analysis", list_major_players),
137
+ ("Business Sub Sector Analysis", analyze_business_sub_sector),
138
+ ("SWOT Analysis", generate_swot_analysis),
139
+ ("Funding Request", generate_funding_request),
140
+ ("Financing & Bank Loan Amortization", create_financing_plan),
141
+ ("Income Statement Analysis", generate_pro_forma_income_statement),
142
+ ("Revenue Expense Analysis", predict_revenue_expenses),
143
+ ("Montly Cash Flow Analysis", generate_monthly_cash_flow),
144
+ ("Pro Forma Annual Cash Flow Analysis", generate_pro_forma_annual_cash_flow),
145
+ ("Pro Forma Balance Sheet Analysis", generate_pro_forma_balance_sheet),
146
+ ("Break-Even Analysis", perform_break_even_analysis),
147
+ ("Payback Period Analysis", calculate_payback_period),
148
+ ("Financial Graphs Analysis", generate_financial_graphs),
149
+ ("Risk Mitigations Analysis", identify_risks_mitigations)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
+ for section_name, generate_prompt_func in sections_to_process:
153
+ prompt = generate_prompt_func(data)
154
+ section_content = call_llm(prompt)
155
+ st.subheader(section_name)
156
+ st.write(section_content)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
+ # Update document and create download link
159
+ doc = add_section_to_doc(doc, section_name, section_content)
160
+ doc_bytes = get_docx_bytes(doc)
161
+
162
+ st.download_button(
163
+ label=f"Download {section_name} as DOCX",
164
+ data=doc_bytes,
165
+ file_name=f"{section_name.replace(' ', '_').lower()}.docx",
166
+ mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
167
+ )
168
+
169
+ collect_basic_info()