Lucas ARRIESSE
commited on
Commit
·
ed93d85
1
Parent(s):
de87f05
Support disabling sort checks
Browse files- api/requirements.py +2 -1
- schemas.py +1 -0
- static/index.html +45 -20
- static/js/app.js +4 -2
api/requirements.py
CHANGED
@@ -71,7 +71,8 @@ async def categorize_reqs(params: ReqGroupingRequest, prompt_env: Environment =
|
|
71 |
# check for remaining requirements assigned to none of the categories
|
72 |
unassigned_ids = valid_ids_universe - valid_assigned_ids
|
73 |
|
74 |
-
|
|
|
75 |
categories.extend(output.categories)
|
76 |
break
|
77 |
else:
|
|
|
71 |
# check for remaining requirements assigned to none of the categories
|
72 |
unassigned_ids = valid_ids_universe - valid_assigned_ids
|
73 |
|
74 |
+
|
75 |
+
if len(unassigned_ids) == 0 or params.disable_sort_checks:
|
76 |
categories.extend(output.categories)
|
77 |
break
|
78 |
else:
|
schemas.py
CHANGED
@@ -118,6 +118,7 @@ class ReqGroupingRequest(BaseModel):
|
|
118 |
requirements: list[RequirementInfo]
|
119 |
max_n_categories: Optional[int] = Field(
|
120 |
default=None, description="Max number of categories to construct. Defaults to None")
|
|
|
121 |
|
122 |
|
123 |
class ReqGroupingResponse(BaseModel):
|
|
|
118 |
requirements: list[RequirementInfo]
|
119 |
max_n_categories: Optional[int] = Field(
|
120 |
default=None, description="Max number of categories to construct. Defaults to None")
|
121 |
+
disable_sort_checks: bool = Field(default=False, description="Disable sort checks when grouping requirements")
|
122 |
|
123 |
|
124 |
class ReqGroupingResponse(BaseModel):
|
static/index.html
CHANGED
@@ -240,30 +240,55 @@
|
|
240 |
<div id="solutions-tab-contents" class="hidden pt-10">
|
241 |
<!--Header de catégorisation des requirements-->
|
242 |
<div class="w-full mx-auto mt-4 p-4 bg-base-100 rounded-box shadow-lg border border-base-200">
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
<
|
248 |
-
<
|
249 |
-
|
250 |
-
|
251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
<div class="text-xs mt-1 text-base-content">Manual | Auto detect</div>
|
260 |
</div>
|
261 |
|
262 |
-
<!--
|
263 |
-
<
|
264 |
-
|
265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
</div>
|
|
|
267 |
</div>
|
268 |
<div id="categorized-requirements-container pt-10" class="mb-6">
|
269 |
<div class="flex mb-4 pt-10">
|
|
|
240 |
<div id="solutions-tab-contents" class="hidden pt-10">
|
241 |
<!--Header de catégorisation des requirements-->
|
242 |
<div class="w-full mx-auto mt-4 p-4 bg-base-100 rounded-box shadow-lg border border-base-200">
|
243 |
+
<div class="flex flex-wrap">
|
244 |
+
<!-- First Group: Aligned to the start (left) -->
|
245 |
+
<div class="flex items-center gap-6">
|
246 |
+
<!-- Number input -->
|
247 |
+
<div class="form-control flex flex-col items-center justify-center">
|
248 |
+
<div class="tooltip" data-tip="Number of categories for sorting requirements">
|
249 |
+
<label class="label" for="category-count">
|
250 |
+
<span class="label-text text-base-content"># Categories</span>
|
251 |
+
</label>
|
252 |
+
</div>
|
253 |
+
<input id="category-count" type="number" class="input input-bordered w-24" min="1" value="3"
|
254 |
+
disabled="">
|
255 |
+
</div>
|
256 |
+
|
257 |
+
<!-- Auto detect toggle -->
|
258 |
+
<div class="form-control flex flex-col items-center justify-center">
|
259 |
+
<div class="tooltip"
|
260 |
+
data-tip="Whether to use the user provided value for sorting or determine automatically the number of categories">
|
261 |
+
<label class="label">
|
262 |
+
<span class="label-text text-base-content">Number of categories</span>
|
263 |
+
</label>
|
264 |
+
</div>
|
265 |
+
<input type="checkbox" class="toggle toggle-primary" id="auto-detect-toggle" checked="true">
|
266 |
+
<div class="text-xs mt-1 text-base-content">Manual | Auto detect</div>
|
267 |
+
</div>
|
268 |
|
269 |
+
<!-- Action Button -->
|
270 |
+
<div class="tooltip" data-tip="Categorize the selected requirements">
|
271 |
+
<button id="categorize-requirements-btn" class="btn btn-primary btn-l self-center">
|
272 |
+
Categorize
|
273 |
+
</button>
|
274 |
+
</div>
|
|
|
275 |
</div>
|
276 |
|
277 |
+
<!-- Second Group: Pushed to the end (right) -->
|
278 |
+
<div class="flex items-center gap-6 ml-auto"> <!-- Added ml-auto here -->
|
279 |
+
<div class="form-control flex flex-col items-center justify-center">
|
280 |
+
<div class="tooltip"
|
281 |
+
data-tip="Disable the sorting checks. Use if models fails repeatedly at sorting requirements">
|
282 |
+
<label class="label">
|
283 |
+
<span class="label-text text-base-content">Disable sort checks</span>
|
284 |
+
</label>
|
285 |
+
</div>
|
286 |
+
<input type="checkbox" class="toggle toggle-error" id="disable-sort-checks">
|
287 |
+
<div class="text-xs mt-1 text-base-content">Checks on | Checks off</div>
|
288 |
+
</div>
|
289 |
+
</div>
|
290 |
</div>
|
291 |
+
|
292 |
</div>
|
293 |
<div id="categorized-requirements-container pt-10" class="mb-6">
|
294 |
<div class="flex mb-4 pt-10">
|
static/js/app.js
CHANGED
@@ -420,6 +420,8 @@ async function categorizeRequirements(max_categories) {
|
|
420 |
return;
|
421 |
}
|
422 |
|
|
|
|
|
423 |
showLoadingOverlay('Categorizing requirements...');
|
424 |
toggleElementsEnabled(['categorize-requirements-btn'], false);
|
425 |
|
@@ -427,7 +429,7 @@ async function categorizeRequirements(max_categories) {
|
|
427 |
const response = await fetch('/requirements/categorize_requirements', {
|
428 |
method: 'POST',
|
429 |
headers: { 'Content-Type': 'application/json' },
|
430 |
-
body: JSON.stringify({ requirements: formattedRequirements, "max_n_categories": max_categories })
|
431 |
});
|
432 |
|
433 |
const data = await response.json();
|
@@ -441,7 +443,7 @@ async function categorizeRequirements(max_categories) {
|
|
441 |
|
442 |
} catch (error) {
|
443 |
console.error('Error while categorizing requirements:', error);
|
444 |
-
alert(
|
445 |
} finally {
|
446 |
hideLoadingOverlay();
|
447 |
toggleElementsEnabled(['categorize-requirements-btn'], true);
|
|
|
420 |
return;
|
421 |
}
|
422 |
|
423 |
+
const disable_sort_checks = document.getElementById('disable-sort-checks').checked;
|
424 |
+
|
425 |
showLoadingOverlay('Categorizing requirements...');
|
426 |
toggleElementsEnabled(['categorize-requirements-btn'], false);
|
427 |
|
|
|
429 |
const response = await fetch('/requirements/categorize_requirements', {
|
430 |
method: 'POST',
|
431 |
headers: { 'Content-Type': 'application/json' },
|
432 |
+
body: JSON.stringify({ requirements: formattedRequirements, "max_n_categories": max_categories, "disable_sort_checks": disable_sort_checks })
|
433 |
});
|
434 |
|
435 |
const data = await response.json();
|
|
|
443 |
|
444 |
} catch (error) {
|
445 |
console.error('Error while categorizing requirements:', error);
|
446 |
+
alert(`Error while categorizing requirements: ${e}. If model fails repeatedly, try disabling sort checks.`);
|
447 |
} finally {
|
448 |
hideLoadingOverlay();
|
449 |
toggleElementsEnabled(['categorize-requirements-btn'], true);
|