Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -564,41 +564,37 @@ tempMock = [{"task_id":"8e867cd7-cff9-4e6c-867a-ff5ddc2550be","question":"How ma
|
|
564 |
|
565 |
|
566 |
|
567 |
-
def process_questions(serviceList):
|
568 |
-
# 1.
|
569 |
-
initial_len = len(serviceList)
|
570 |
exclude_ids = {q["task_id"] for q in whiteList + blackList}
|
571 |
-
serviceList = [q for q in mock if q["task_id"] not in exclude_ids]
|
572 |
|
573 |
-
|
|
|
574 |
|
575 |
-
#
|
576 |
-
|
577 |
|
578 |
-
#
|
579 |
-
|
580 |
-
if
|
581 |
-
|
582 |
-
|
583 |
-
serviceList = [q for q in serviceList if q not in
|
584 |
|
585 |
-
#
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
for q in removed_random:
|
590 |
-
print_coso(q)
|
591 |
|
592 |
-
#
|
593 |
-
|
594 |
for q in serviceList:
|
595 |
-
|
596 |
|
597 |
-
#
|
598 |
-
serviceList
|
599 |
|
600 |
-
|
601 |
-
return serviceList
|
602 |
|
603 |
|
604 |
def generate_tool_descriptions(tools):
|
|
|
564 |
|
565 |
|
566 |
|
567 |
+
def process_questions(serviceList, whiteList, blackList):
|
568 |
+
# 1. Estrai tutti i task_id da escludere (da whiteList e blackList)
|
|
|
569 |
exclude_ids = {q["task_id"] for q in whiteList + blackList}
|
|
|
570 |
|
571 |
+
# 2. Rimuovi da serviceList tutte le domande con task_id in exclude_ids
|
572 |
+
serviceList = [q for q in serviceList if q["task_id"] not in exclude_ids]
|
573 |
|
574 |
+
# 3. Calcola la somma delle domande rimanenti + quelle in whiteList
|
575 |
+
total = len(serviceList) + len(whiteList)
|
576 |
|
577 |
+
# 4. Se la somma supera 20, rimuovi a caso da serviceList
|
578 |
+
removed = []
|
579 |
+
if total > 20:
|
580 |
+
excess = total - 20
|
581 |
+
removed = random.sample(serviceList, excess)
|
582 |
+
serviceList = [q for q in serviceList if q not in removed]
|
583 |
|
584 |
+
# 5. Stampa le domande rimosse
|
585 |
+
print("Domande rimosse:")
|
586 |
+
for q in removed:
|
587 |
+
print(f"- {q['task_id']}: {q['question'][:80]}")
|
|
|
|
|
588 |
|
589 |
+
# 6. Stampa la serviceList aggiornata
|
590 |
+
print("\nService list aggiornata:")
|
591 |
for q in serviceList:
|
592 |
+
print(f"- {q['task_id']}: {q['question'][:80]}")
|
593 |
|
594 |
+
# 7. Aggiungi le domande della whiteList
|
595 |
+
final_list = serviceList + whiteList
|
596 |
|
597 |
+
return final_list
|
|
|
598 |
|
599 |
|
600 |
def generate_tool_descriptions(tools):
|