GattoNero commited on
Commit
a53c765
·
verified ·
1 Parent(s): ac05917

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -26
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. Rimuovi dalla serviceList tutte le domande i cui task_id sono in blackList
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
- removed_blacklisted = initial_len - len(serviceList)
 
574
 
575
- # 2. Calcola la somma con whiteList
576
- total_after_merge = len(serviceList) + len(whiteList)
577
 
578
- # 3. Se somma > 20, rimuovi a caso da serviceList
579
- removed_random = []
580
- if total_after_merge > 20:
581
- to_remove = total_after_merge - 20
582
- removed_random = random.sample(serviceList, to_remove)
583
- serviceList = [q for q in serviceList if q not in removed_random]
584
 
585
- # 4. Stampa le domande eliminate
586
- print_coso("=== Domande rimosse per blacklist ===")
587
- print_coso(removed_blacklisted)
588
- print_coso("=== Domande rimosse random ===")
589
- for q in removed_random:
590
- print_coso(q)
591
 
592
- # 5. Stampa la nuova serviceList
593
- print_coso("=== Nuova serviceList ===")
594
  for q in serviceList:
595
- print_coso(q)
596
 
597
- # 6. Aggiungi le domande della whiteList
598
- serviceList.extend(whiteList)
599
 
600
- # 7. Ritorna la lista risultante
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):