Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,6 +53,7 @@ TASK_TMPL = """\
|
|
| 53 |
Classe ce produit en COICOP:
|
| 54 |
EAN: {ean}
|
| 55 |
Libellé: {label}
|
|
|
|
| 56 |
Outils autorisés :
|
| 57 |
- validate_ean
|
| 58 |
- openfoodfacts_product_by_ean
|
|
@@ -63,21 +64,39 @@ Outils autorisés :
|
|
| 63 |
- resolve_coicop_candidates
|
| 64 |
- web_search
|
| 65 |
- web_get
|
| 66 |
-
- python_interpreter # autorisé si
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
-
|
| 70 |
-
-
|
| 71 |
-
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
1) v = validate_ean(ean)
|
| 74 |
-
2) off = openfoodfacts_product_by_ean(ean)
|
| 75 |
-
3) offmap = map_off_to_coicop(off_payload=off) #
|
| 76 |
4) rx = coicop_regex_rules(text=LIBELLÉ UTILISATEUR)
|
| 77 |
5) sem = coicop_semantic_similarity(text=LIBELLÉ UTILISATEUR, topk=5)
|
| 78 |
6) merged = merge_candidates(candidates_lists=[offmap, rx, sem], min_k=3, fallback_bias="cheese")
|
| 79 |
7) res = resolve_coicop_candidates(json_lists=[merged], topn=3)
|
| 80 |
-
→
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
"""
|
| 82 |
|
| 83 |
|
|
|
|
| 53 |
Classe ce produit en COICOP:
|
| 54 |
EAN: {ean}
|
| 55 |
Libellé: {label}
|
| 56 |
+
|
| 57 |
Outils autorisés :
|
| 58 |
- validate_ean
|
| 59 |
- openfoodfacts_product_by_ean
|
|
|
|
| 64 |
- resolve_coicop_candidates
|
| 65 |
- web_search
|
| 66 |
- web_get
|
| 67 |
+
- python_interpreter # autorisé uniquement si nécessaire pour manipuler des listes/dicts
|
| 68 |
+
|
| 69 |
+
Règles STRICTES de sortie :
|
| 70 |
+
- Tu dois terminer par un UNIQUE objet JSON valide via final_answer({...}).
|
| 71 |
+
- N’écris AUCUNE phrase, AUCUN commentaire, AUCUN bloc de code dans ta réponse finale.
|
| 72 |
+
- N’utilise PAS de backticks ``` dans la réponse finale.
|
| 73 |
+
- Le JSON final DOIT contenir: final, alternatives, candidates_top, explanation.
|
| 74 |
+
|
| 75 |
+
Branchements selon l’EAN :
|
| 76 |
+
- Si l’EAN est vide, "N/A", non numérique, longueur non autorisée (≠ 8/12/13/14) ou clé GS1 invalide ⇒ MODE SANS EAN.
|
| 77 |
+
- Sinon ⇒ MODE AVEC EAN.
|
| 78 |
+
|
| 79 |
+
Pipeline — MODE AVEC EAN (EAN valide) :
|
| 80 |
1) v = validate_ean(ean)
|
| 81 |
+
2) off = openfoodfacts_product_by_ean(ean) # si off.ok != True, ignore off
|
| 82 |
+
3) offmap = map_off_to_coicop(off_payload=off) # ou map_off_to_coicop(product_name, categories_tags, ingredients_text, ...) si utile
|
| 83 |
4) rx = coicop_regex_rules(text=LIBELLÉ UTILISATEUR)
|
| 84 |
5) sem = coicop_semantic_similarity(text=LIBELLÉ UTILISATEUR, topk=5)
|
| 85 |
6) merged = merge_candidates(candidates_lists=[offmap, rx, sem], min_k=3, fallback_bias="cheese")
|
| 86 |
7) res = resolve_coicop_candidates(json_lists=[merged], topn=3)
|
| 87 |
+
→ Appelle immédiatement final_answer(res)
|
| 88 |
+
|
| 89 |
+
Pipeline — MODE SANS EAN (EAN vide/invalide) :
|
| 90 |
+
4) rx = coicop_regex_rules(text=LIBELLÉ UTILISATEUR)
|
| 91 |
+
5) sem = coicop_semantic_similarity(text=LIBELLÉ UTILISATEUR, topk=5)
|
| 92 |
+
6) merged = merge_candidates(candidates_lists=[rx, sem], min_k=3, fallback_bias="cheese")
|
| 93 |
+
7) res = resolve_coicop_candidates(json_lists=[merged], topn=3)
|
| 94 |
+
→ Appelle immédiatement final_answer(res)
|
| 95 |
+
|
| 96 |
+
Contraintes d’usage :
|
| 97 |
+
- N’utilise python_interpreter que pour des manipulations de listes/dicts si merge_candidates ne suffit pas. Pas de fichiers, pas d’IO externes.
|
| 98 |
+
- web_search / web_get sont optionnels (utilise-les seulement si rx+sem sont insuffisants).
|
| 99 |
+
- Ne fais aucun “print”, ni d’explication hors du JSON final.
|
| 100 |
"""
|
| 101 |
|
| 102 |
|