Update app.py
Browse files
app.py
CHANGED
@@ -82,6 +82,7 @@ def analyze_requirement(requirement):
|
|
82 |
"Rewritten": rewritten
|
83 |
}
|
84 |
|
|
|
85 |
def generate_pdf_report(results):
|
86 |
pdf = FPDF()
|
87 |
pdf.add_page()
|
@@ -113,13 +114,12 @@ def generate_pdf_report(results):
|
|
113 |
pdf.cell(200, 10, txt=f"Report Generated on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}", ln=True, align='C')
|
114 |
pdf.ln(10) # Add some space
|
115 |
|
116 |
-
# Add requirement details
|
117 |
pdf.set_font("Arial", 'B', 14)
|
118 |
pdf.multi_cell(200, 10, txt=f"Requirement R{i}: {result['Requirement']}", align='L')
|
119 |
pdf.set_font("Arial", size=12)
|
120 |
pdf.multi_cell(200, 10, txt=f"Type: {result['Type']}", align='L')
|
121 |
pdf.multi_cell(200, 10, txt=f"Domain: {result['Domain']}", align='L')
|
122 |
-
pdf.multi_cell(200, 10, txt=f"Stakeholders: {result['Stakeholders']}", align='L') # Added this line
|
123 |
pdf.multi_cell(200, 10, txt=f"Defects: {result['Defects']}", align='L')
|
124 |
pdf.multi_cell(200, 10, txt=f"Rewritten: {result['Rewritten']}", align='L')
|
125 |
pdf.multi_cell(200, 10, txt="-" * 50, align='L')
|
@@ -129,7 +129,6 @@ def generate_pdf_report(results):
|
|
129 |
pdf.output(pdf_output)
|
130 |
return pdf_output
|
131 |
|
132 |
-
|
133 |
# Custom CSS for professional styling
|
134 |
st.markdown("""
|
135 |
<style>
|
@@ -226,7 +225,6 @@ def main():
|
|
226 |
time.sleep(0.5)
|
227 |
st.session_state.results = results
|
228 |
|
229 |
-
|
230 |
# Display Results
|
231 |
if 'results' in st.session_state:
|
232 |
st.subheader("π Analysis Results")
|
@@ -255,27 +253,27 @@ def main():
|
|
255 |
</div>
|
256 |
""", unsafe_allow_html=True)
|
257 |
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
|
272 |
-
|
273 |
-
st.markdown("""
|
274 |
-
<div style="text-align: center; color: #666; margin-top: 3rem;">
|
275 |
-
<p>AI-Powered Requirement Analysis System</p>
|
276 |
-
<p>π Powered by Mistral AI & Groq β’ π οΈ Developed by Team Four</p>
|
277 |
-
</div>
|
278 |
-
""", unsafe_allow_html=True)
|
279 |
|
280 |
if __name__ == "__main__":
|
281 |
main()
|
|
|
82 |
"Rewritten": rewritten
|
83 |
}
|
84 |
|
85 |
+
# Function to generate a PDF report
|
86 |
def generate_pdf_report(results):
|
87 |
pdf = FPDF()
|
88 |
pdf.add_page()
|
|
|
114 |
pdf.cell(200, 10, txt=f"Report Generated on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}", ln=True, align='C')
|
115 |
pdf.ln(10) # Add some space
|
116 |
|
117 |
+
# Add requirement details
|
118 |
pdf.set_font("Arial", 'B', 14)
|
119 |
pdf.multi_cell(200, 10, txt=f"Requirement R{i}: {result['Requirement']}", align='L')
|
120 |
pdf.set_font("Arial", size=12)
|
121 |
pdf.multi_cell(200, 10, txt=f"Type: {result['Type']}", align='L')
|
122 |
pdf.multi_cell(200, 10, txt=f"Domain: {result['Domain']}", align='L')
|
|
|
123 |
pdf.multi_cell(200, 10, txt=f"Defects: {result['Defects']}", align='L')
|
124 |
pdf.multi_cell(200, 10, txt=f"Rewritten: {result['Rewritten']}", align='L')
|
125 |
pdf.multi_cell(200, 10, txt="-" * 50, align='L')
|
|
|
129 |
pdf.output(pdf_output)
|
130 |
return pdf_output
|
131 |
|
|
|
132 |
# Custom CSS for professional styling
|
133 |
st.markdown("""
|
134 |
<style>
|
|
|
225 |
time.sleep(0.5)
|
226 |
st.session_state.results = results
|
227 |
|
|
|
228 |
# Display Results
|
229 |
if 'results' in st.session_state:
|
230 |
st.subheader("π Analysis Results")
|
|
|
253 |
</div>
|
254 |
""", unsafe_allow_html=True)
|
255 |
|
256 |
+
# PDF Report Section
|
257 |
+
st.subheader("π€ Generate Report")
|
258 |
+
with st.container():
|
259 |
+
col1, col2 = st.columns([3, 2])
|
260 |
+
with col1:
|
261 |
+
st.info("π‘ Click below to generate a comprehensive PDF report with all analysis details")
|
262 |
+
with col2:
|
263 |
+
if st.button("π Generate PDF Report", type="secondary", use_container_width=True):
|
264 |
+
with st.spinner("Generating PDF..."):
|
265 |
+
pdf_report = generate_pdf_report(st.session_state.results)
|
266 |
+
with open(pdf_report, "rb") as f:
|
267 |
+
st.download_button(
|
268 |
+
label="β¬οΈ Download Full Report",
|
269 |
+
data=f,
|
270 |
+
file_name="Requirement_Analysis_Report.pdf",
|
271 |
+
mime="application/pdf",
|
272 |
+
use_container_width=True,
|
273 |
+
type="primary"
|
274 |
+
)
|
275 |
|
276 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
|
278 |
if __name__ == "__main__":
|
279 |
main()
|