Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,9 +59,25 @@ def analyze_requirement(requirement):
|
|
| 59 |
type_prompt = f"Classify the following requirement as Functional or Non-Functional in one word:\n\n{requirement}\n\nType:"
|
| 60 |
req_type = call_mistral_api(type_prompt).strip()
|
| 61 |
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 (e.g., Ambiguity, Incompleteness, etc.) in 1-2 words each:\n\n{requirement}\n\nDefects:"""
|
| 67 |
defects = call_groq_api(defects_prompt).strip()
|
|
@@ -73,7 +89,7 @@ def analyze_requirement(requirement):
|
|
| 73 |
"Requirement": requirement,
|
| 74 |
"Type": req_type,
|
| 75 |
"Domain": domain,
|
| 76 |
-
"Defects": defects,
|
| 77 |
"Rewritten": rewritten
|
| 78 |
}
|
| 79 |
|
|
@@ -240,14 +256,14 @@ def main():
|
|
| 240 |
<h4>🔎 Identified Issues</h4>
|
| 241 |
<div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
|
| 242 |
{''.join([f'<div class="analysis-badge defect-badge">⚠️ {d}</div>'
|
| 243 |
-
for d in result[
|
| 244 |
</div>
|
| 245 |
</div>
|
| 246 |
|
| 247 |
<div style="margin: 1rem 0;">
|
| 248 |
<h4>✨ Improved Version</h4>
|
| 249 |
<div class="analysis-badge improved-badge">
|
| 250 |
-
📝 {result[
|
| 251 |
</div>
|
| 252 |
</div>
|
| 253 |
</div>
|
|
|
|
| 59 |
type_prompt = f"Classify the following requirement as Functional or Non-Functional in one word:\n\n{requirement}\n\nType:"
|
| 60 |
req_type = call_mistral_api(type_prompt).strip()
|
| 61 |
|
| 62 |
+
defects_prompt = f"""List ONLY the major defects in this requirement (EXACTLY 3 bullet points,
|
| 63 |
+
each defect 1-2 words maximum, no explanations, format exactly like this example):
|
| 64 |
+
- Ambiguity
|
| 65 |
+
- Vagueness
|
| 66 |
+
- Incompleteness
|
| 67 |
+
|
| 68 |
+
Requirement: {requirement}
|
| 69 |
+
Defects:"""
|
| 70 |
domain = call_mistral_api(domain_prompt).strip()
|
| 71 |
|
| 72 |
+
# Process defects response
|
| 73 |
+
defects = []
|
| 74 |
+
if "API Error" not in defects_response:
|
| 75 |
+
defects = [line.strip()[2:] for line in defects_response.split("\n")
|
| 76 |
+
if line.strip().startswith("- ")]
|
| 77 |
+
|
| 78 |
+
if not defects:
|
| 79 |
+
defects = ["No major defects found"]
|
| 80 |
+
|
| 81 |
# Use Groq for defect analysis and rewriting
|
| 82 |
defects_prompt = f"""List ONLY the major defects in the following requirement (e.g., Ambiguity, Incompleteness, etc.) in 1-2 words each:\n\n{requirement}\n\nDefects:"""
|
| 83 |
defects = call_groq_api(defects_prompt).strip()
|
|
|
|
| 89 |
"Requirement": requirement,
|
| 90 |
"Type": req_type,
|
| 91 |
"Domain": domain,
|
| 92 |
+
"Defects": defects, # This is now a clean list
|
| 93 |
"Rewritten": rewritten
|
| 94 |
}
|
| 95 |
|
|
|
|
| 256 |
<h4>🔎 Identified Issues</h4>
|
| 257 |
<div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
|
| 258 |
{''.join([f'<div class="analysis-badge defect-badge">⚠️ {d}</div>'
|
| 259 |
+
for d in result["Defects"]])}
|
| 260 |
</div>
|
| 261 |
</div>
|
| 262 |
|
| 263 |
<div style="margin: 1rem 0;">
|
| 264 |
<h4>✨ Improved Version</h4>
|
| 265 |
<div class="analysis-badge improved-badge">
|
| 266 |
+
📝 {result["Rewritten"]}
|
| 267 |
</div>
|
| 268 |
</div>
|
| 269 |
</div>
|