Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -86,8 +86,7 @@ def analyze_requirement(requirement):
|
|
| 86 |
def generate_pdf_report(results):
|
| 87 |
pdf = FPDF()
|
| 88 |
pdf.add_page()
|
| 89 |
-
|
| 90 |
-
|
| 91 |
# Add watermark
|
| 92 |
pdf.set_font("Arial", 'B', 50)
|
| 93 |
pdf.set_text_color(230, 230, 230) # Light gray color for watermark
|
|
@@ -114,21 +113,16 @@ def generate_pdf_report(results):
|
|
| 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 |
-
|
| 118 |
-
pdf.
|
| 119 |
-
pdf.multi_cell(
|
| 120 |
-
pdf.
|
| 121 |
-
pdf.multi_cell(
|
| 122 |
-
pdf.multi_cell(
|
| 123 |
-
pdf.multi_cell(200, 10, txt=f"Stakeholders: {result['Stakeholders']}", align='L')
|
| 124 |
-
pdf.multi_cell(200, 10, txt=f"Defects: {result['Defects']}", align='L')
|
| 125 |
-
pdf.multi_cell(200, 10, txt=f"Rewritten: {result['Rewritten']}", align='L')
|
| 126 |
-
pdf.multi_cell(200, 10, txt="-" * 50, align='L')
|
| 127 |
-
pdf.ln(5) # Add some space between requirements
|
| 128 |
|
| 129 |
pdf_output = "requirements_report.pdf"
|
| 130 |
pdf.output(pdf_output)
|
| 131 |
-
return
|
| 132 |
|
| 133 |
# Custom CSS for professional styling
|
| 134 |
st.markdown("""
|
|
@@ -226,7 +220,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")
|
|
@@ -256,24 +249,25 @@ def main():
|
|
| 256 |
""", unsafe_allow_html=True)
|
| 257 |
|
| 258 |
# PDF Report Section
|
| 259 |
-
st.
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
st.download_button(
|
| 270 |
-
label="β¬οΈ Download Full Report",
|
| 271 |
-
data=f,
|
| 272 |
-
file_name="Requirement_Analysis_Report.pdf",
|
| 273 |
-
mime="application/pdf"
|
| 274 |
-
)
|
| 275 |
|
| 276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
|
| 278 |
if __name__ == "__main__":
|
| 279 |
main()
|
|
|
|
| 86 |
def generate_pdf_report(results):
|
| 87 |
pdf = FPDF()
|
| 88 |
pdf.add_page()
|
| 89 |
+
|
|
|
|
| 90 |
# Add watermark
|
| 91 |
pdf.set_font("Arial", 'B', 50)
|
| 92 |
pdf.set_text_color(230, 230, 230) # Light gray color for watermark
|
|
|
|
| 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 |
+
pdf.set_font("Arial", '', 12)
|
| 117 |
+
pdf.multi_cell(0, 10, f"π Type of Requirements: {req_type}")
|
| 118 |
+
pdf.multi_cell(0, 10, f"π Domain of Requirements: {domain}")
|
| 119 |
+
pdf.multi_cell(0, 10, f"π₯ Stakeholders: {stakeholders}")
|
| 120 |
+
pdf.multi_cell(0, 10, f"π Defects Found: {defects}")
|
| 121 |
+
pdf.multi_cell(0, 10, f"βοΈ Rewritten Requirements: {rewrite}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
pdf_output = "requirements_report.pdf"
|
| 124 |
pdf.output(pdf_output)
|
| 125 |
+
return pdf.output(dest='S').encode('latin1') # Return PDF bytes
|
| 126 |
|
| 127 |
# Custom CSS for professional styling
|
| 128 |
st.markdown("""
|
|
|
|
| 220 |
time.sleep(0.5)
|
| 221 |
st.session_state.results = results
|
| 222 |
|
|
|
|
| 223 |
# Display Results
|
| 224 |
if 'results' in st.session_state:
|
| 225 |
st.subheader("π Analysis Results")
|
|
|
|
| 249 |
""", unsafe_allow_html=True)
|
| 250 |
|
| 251 |
# PDF Report Section
|
| 252 |
+
if st.button("π Generate Report"):
|
| 253 |
+
pdf_bytes = generate_pdf(
|
| 254 |
+
requirements_text,
|
| 255 |
+
requirement_type,
|
| 256 |
+
requirement_domain,
|
| 257 |
+
requirement_stakeholders,
|
| 258 |
+
requirement_defects,
|
| 259 |
+
requirement_rewrite
|
| 260 |
+
)
|
| 261 |
+
st.download_button("β¬οΈ Download PDF", data=pdf_bytes, file_name="Requirements_Report.pdf", mime="application/pdf")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
|
| 263 |
+
# Footer
|
| 264 |
+
st.markdown("---")
|
| 265 |
+
st.markdown("""
|
| 266 |
+
<div style="text-align: center; color: #666; margin-top: 3rem;">
|
| 267 |
+
<p>AI-Powered Requirement Analysis System</p>
|
| 268 |
+
<p>π Powered by Mistral AI & Groq β’ π οΈ Developed by Team Four</p>
|
| 269 |
+
</div>
|
| 270 |
+
""", unsafe_allow_html=True)
|
| 271 |
|
| 272 |
if __name__ == "__main__":
|
| 273 |
main()
|