SoDa12321 commited on
Commit
5a66e66
·
verified ·
1 Parent(s): da4d546

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -1
app.py CHANGED
@@ -98,7 +98,7 @@ def collect_basic_info():
98
  # Create a new document for all sections combined
99
  combined_doc = create_document()
100
 
101
- for section_name, section_content in all_sections_content.items():
102
  st.subheader(section_name)
103
  st.write(section_content) # Display the generated content
104
 
@@ -111,6 +111,39 @@ def collect_basic_info():
111
  filename = f"{report_type}_{sanitized_topic}_all_sections.docx"
112
  st.download_button(f"Download All Sections as DOCX", combined_doc_bytes, filename)
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  else:
115
  if st.button('Generate Report Section'):
116
  # Dynamically get the function name and call it for individual sections
 
98
  # Create a new document for all sections combined
99
  combined_doc = create_document()
100
 
101
+ for section_name, section_content in all_sections_content: #.items():
102
  st.subheader(section_name)
103
  st.write(section_content) # Display the generated content
104
 
 
111
  filename = f"{report_type}_{sanitized_topic}_all_sections.docx"
112
  st.download_button(f"Download All Sections as DOCX", combined_doc_bytes, filename)
113
 
114
+ if section_to_generate == "All Sections_0":
115
+ for section_name, generate_prompt_func in sections_to_process:
116
+ prompt = generate_prompt_func(data)
117
+ section_content = call_llm(prompt)
118
+ st.subheader(section_name)
119
+ st.write(section_content)
120
+
121
+ # Update document and create download link
122
+ doc = add_section_to_doc(doc, section_name, section_content)
123
+ doc_bytes = get_docx_bytes(doc)
124
+
125
+ st.download_button(
126
+ label=f"Download {section_name} as DOCX",
127
+ data=doc_bytes,
128
+ file_name=f"{section_name.replace(' ', '_').lower()}.docx",
129
+ mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
130
+ )
131
+
132
+ # Save section content in a file
133
+ #filename = f"{company_name}_{section_name}.docx"
134
+ # Sanitize section name and limit file name length
135
+ sanitized_section_name = sanitize_filename(section_name, max_length=50)
136
+
137
+ # Generate final file name and ensure it is not too long
138
+ filename = f"{sanitized_company_name}_{sanitized_section_name}.docx"
139
+
140
+ with open(filename, 'wb') as f:
141
+ f.write(doc_bytes.getbuffer())
142
+
143
+ # Send email with section content and attachment
144
+ #send_email_with_attachment(email, f"{section_name} of Your Business Proposal", "Please find attached the section of your business proposal.", filename, section_content)
145
+
146
+
147
  else:
148
  if st.button('Generate Report Section'):
149
  # Dynamically get the function name and call it for individual sections