Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
from fpdf import FPDF
|
4 |
-
import pdfplumber
|
5 |
import os
|
6 |
import time
|
7 |
|
@@ -105,36 +104,26 @@ def generate_pdf_report(results):
|
|
105 |
# Streamlit app
|
106 |
def main():
|
107 |
st.title("Requirement Analysis Tool")
|
108 |
-
st.markdown("**Team Name:**
|
109 |
-
st.markdown("**Model:** Mistral")
|
110 |
|
111 |
# Input options
|
112 |
-
|
|
|
|
|
113 |
|
114 |
requirements = []
|
115 |
-
if
|
116 |
-
|
117 |
-
if
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
uploaded_file = st.file_uploader("Upload a PDF file:", type="pdf")
|
122 |
-
if uploaded_file:
|
123 |
-
try:
|
124 |
-
with pdfplumber.open(uploaded_file) as pdf:
|
125 |
-
requirements = []
|
126 |
-
for page in pdf.pages:
|
127 |
-
text = page.extract_text()
|
128 |
-
if text:
|
129 |
-
# Split by periods or newlines
|
130 |
-
requirements.extend([req.strip() for req in text.replace("\n", ".").split(".") if req.strip()])
|
131 |
-
except Exception as e:
|
132 |
-
st.error(f"Error reading PDF file: {e}")
|
133 |
|
134 |
# Analyze requirements
|
135 |
if st.button("Analyze Requirements"):
|
136 |
if not requirements:
|
137 |
-
st.warning("Please enter
|
138 |
else:
|
139 |
results = []
|
140 |
for req in requirements:
|
@@ -144,13 +133,13 @@ def main():
|
|
144 |
# Display results
|
145 |
st.subheader("Analysis Results")
|
146 |
for i, result in enumerate(results, start=1):
|
147 |
-
st.
|
148 |
-
st.
|
149 |
-
st.
|
150 |
-
st.
|
151 |
-
st.
|
152 |
-
st.
|
153 |
-
st.
|
154 |
|
155 |
# Generate and download PDF report
|
156 |
pdf_report = generate_pdf_report(results)
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
from fpdf import FPDF
|
|
|
4 |
import os
|
5 |
import time
|
6 |
|
|
|
104 |
# Streamlit app
|
105 |
def main():
|
106 |
st.title("Requirement Analysis Tool")
|
107 |
+
st.markdown("**Team Name:** Sadia, Areeba, Rabbia, Tesmia")
|
108 |
+
st.markdown("**LLM Model:** Mistral")
|
109 |
|
110 |
# Input options
|
111 |
+
st.markdown("### Enter Requirements")
|
112 |
+
st.markdown("You can enter up to **5 requirements** at a time. Each requirement should be **clear and concise**.")
|
113 |
+
input_text = st.text_area("Enter your requirements (one per line or separated by periods):", height=150)
|
114 |
|
115 |
requirements = []
|
116 |
+
if input_text:
|
117 |
+
# Split by periods or newlines
|
118 |
+
requirements = [req.strip() for req in input_text.replace("\n", ".").split(".") if req.strip()]
|
119 |
+
if len(requirements) > 5:
|
120 |
+
st.warning("You have entered more than 5 requirements. Only the first 5 will be analyzed.")
|
121 |
+
requirements = requirements[:5]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
# Analyze requirements
|
124 |
if st.button("Analyze Requirements"):
|
125 |
if not requirements:
|
126 |
+
st.warning("Please enter at least one requirement.")
|
127 |
else:
|
128 |
results = []
|
129 |
for req in requirements:
|
|
|
133 |
# Display results
|
134 |
st.subheader("Analysis Results")
|
135 |
for i, result in enumerate(results, start=1):
|
136 |
+
st.markdown(f"### Requirement R{i}: {result['Requirement']}")
|
137 |
+
st.markdown(f"**Type:** {result['Type']}")
|
138 |
+
st.markdown(f"**Stakeholders:** {result['Stakeholders']}")
|
139 |
+
st.markdown(f"**Domain:** {result['Domain']}")
|
140 |
+
st.markdown(f"**Defects:** {result['Defects']}")
|
141 |
+
st.markdown(f"**Rewritten:** {result['Rewritten']}")
|
142 |
+
st.markdown("---")
|
143 |
|
144 |
# Generate and download PDF report
|
145 |
pdf_report = generate_pdf_report(results)
|