Update app.py
Browse files
app.py
CHANGED
@@ -53,11 +53,6 @@ def call_groq_api(prompt):
|
|
53 |
st.error(f"Error: {err}")
|
54 |
return f"Error: {err}"
|
55 |
|
56 |
-
def clean_text(text):
|
57 |
-
# Remove markdown code fences and any trailing newlines/spaces
|
58 |
-
cleaned = text.replace("```", "").strip()
|
59 |
-
return cleaned
|
60 |
-
|
61 |
# Function to analyze a single requirement
|
62 |
def analyze_requirement(requirement):
|
63 |
# Use Mistral for classification and domain identification
|
@@ -68,13 +63,17 @@ def analyze_requirement(requirement):
|
|
68 |
domain = call_mistral_api(domain_prompt).strip()
|
69 |
|
70 |
# Use Groq for defect analysis and rewriting
|
71 |
-
defects_prompt = f"""List ONLY the major defects in the following requirement (
|
72 |
-
|
73 |
-
|
|
|
|
|
74 |
|
75 |
-
rewritten_prompt = f"""Rewrite the following requirement in 1-2 sentences to address
|
76 |
-
|
77 |
-
|
|
|
|
|
78 |
|
79 |
return {
|
80 |
"Requirement": requirement,
|
@@ -169,6 +168,15 @@ st.markdown("""
|
|
169 |
font-weight: 500;
|
170 |
margin: 0.3rem;
|
171 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
.download-btn {
|
173 |
width: 100%;
|
174 |
padding: 1rem;
|
@@ -247,7 +255,7 @@ def main():
|
|
247 |
<h4>🔎 Identified Issues</h4>
|
248 |
<div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
|
249 |
{''.join([f'<div class="analysis-badge defect-badge">⚠️ {d}</div>'
|
250 |
-
for d in result['Defects'].split(', ')])
|
251 |
</div>
|
252 |
</div>
|
253 |
|
|
|
53 |
st.error(f"Error: {err}")
|
54 |
return f"Error: {err}"
|
55 |
|
|
|
|
|
|
|
|
|
|
|
56 |
# Function to analyze a single requirement
|
57 |
def analyze_requirement(requirement):
|
58 |
# Use Mistral for classification and domain identification
|
|
|
63 |
domain = call_mistral_api(domain_prompt).strip()
|
64 |
|
65 |
# Use Groq for defect analysis and rewriting
|
66 |
+
defects_prompt = f"""List ONLY the major defects in the following requirement as comma-separated values (1-2 words each). Valid options: Ambiguity, Vagueness, Incompleteness, Volatility, Unverifiability. Do NOT add explanations:
|
67 |
+
{requirement}
|
68 |
+
Defects:"""
|
69 |
+
defects = defects.split(":")[-1].strip() if ":" in defects else defects
|
70 |
+
defects = defects.replace("Defects", "").strip()
|
71 |
|
72 |
+
rewritten_prompt = f"""Rewrite the following requirement in 1-2 sentences to address defects. Start directly with "The project shall..." without preamble:
|
73 |
+
{requirement}
|
74 |
+
Improved:"""
|
75 |
+
rewritten = rewritten.split(":")[-1].strip() if ":" in rewritten else rewritten
|
76 |
+
rewritten = rewritten.replace("Rewritten", "").replace("Improved", "").strip()
|
77 |
|
78 |
return {
|
79 |
"Requirement": requirement,
|
|
|
168 |
font-weight: 500;
|
169 |
margin: 0.3rem;
|
170 |
}
|
171 |
+
.defect-badge {
|
172 |
+
white-space: nowrap;
|
173 |
+
margin: 0.2rem 0.3rem !important;
|
174 |
+
}
|
175 |
+
.improved-badge {
|
176 |
+
line-height: 1.5;
|
177 |
+
text-align: left;
|
178 |
+
width: 100%;
|
179 |
+
}
|
180 |
.download-btn {
|
181 |
width: 100%;
|
182 |
padding: 1rem;
|
|
|
255 |
<h4>🔎 Identified Issues</h4>
|
256 |
<div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
|
257 |
{''.join([f'<div class="analysis-badge defect-badge">⚠️ {d}</div>'
|
258 |
+
for d in result['Defects'].split(', ') if d.strip()])
|
259 |
</div>
|
260 |
</div>
|
261 |
|