task analysis
This commit is contained in:
62
app.py
62
app.py
@@ -72,6 +72,7 @@ Actions disponibles :
|
|||||||
{"action": "ajouter_note", "contenu": "...", "sujet": "...", "client": "...", "projet": "...", "type": "note"}
|
{"action": "ajouter_note", "contenu": "...", "sujet": "...", "client": "...", "projet": "...", "type": "note"}
|
||||||
{"action": "chercher_memoire", "requete": "..."}
|
{"action": "chercher_memoire", "requete": "..."}
|
||||||
{"action": "lister_clients"}
|
{"action": "lister_clients"}
|
||||||
|
{"action": "analyser_taches", "type": "client_plus_taches"}
|
||||||
|
|
||||||
Si une phrase contient plusieurs choses a enregistrer, utilise :
|
Si une phrase contient plusieurs choses a enregistrer, utilise :
|
||||||
{"actions": [{...}, {...}]}
|
{"actions": [{...}, {...}]}
|
||||||
@@ -192,6 +193,7 @@ ACTIONS = {
|
|||||||
"ajouter_note",
|
"ajouter_note",
|
||||||
"chercher_memoire",
|
"chercher_memoire",
|
||||||
"lister_clients",
|
"lister_clients",
|
||||||
|
"analyser_taches",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -258,6 +260,10 @@ def detecter_action_directe(texte, session_id=None):
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
analyse_taches = detecter_analyse_taches(texte_nettoye)
|
||||||
|
if analyse_taches:
|
||||||
|
return analyse_taches
|
||||||
|
|
||||||
tache_client = detecter_tache_client(texte_nettoye)
|
tache_client = detecter_tache_client(texte_nettoye)
|
||||||
if tache_client:
|
if tache_client:
|
||||||
return tache_client
|
return tache_client
|
||||||
@@ -384,6 +390,20 @@ def detecter_recherche_taches(texte):
|
|||||||
return {"action": "chercher_memoire", "requete": client_nom}
|
return {"action": "chercher_memoire", "requete": client_nom}
|
||||||
|
|
||||||
|
|
||||||
|
def detecter_analyse_taches(texte):
|
||||||
|
if not re.search(r"\bclients?\b", texte, flags=re.IGNORECASE):
|
||||||
|
return None
|
||||||
|
if not re.search(r"\b(taches?|tâches?|a faire|à faire|reste)\b", texte, flags=re.IGNORECASE):
|
||||||
|
return None
|
||||||
|
if re.search(
|
||||||
|
r"\b(plus\s+de|le\s+plus|maximum|max|prioritaire|charge|chargé|chargee|chargée)\b",
|
||||||
|
texte,
|
||||||
|
flags=re.IGNORECASE,
|
||||||
|
):
|
||||||
|
return {"action": "analyser_taches", "type": "client_plus_taches"}
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def detecter_suppression_tache(texte, session_id):
|
def detecter_suppression_tache(texte, session_id):
|
||||||
if not re.search(r"\b(enleve|enlève|supprime|retire|efface|termine|marque.*faite)\b", texte, flags=re.IGNORECASE):
|
if not re.search(r"\b(enleve|enlève|supprime|retire|efface|termine|marque.*faite)\b", texte, flags=re.IGNORECASE):
|
||||||
return None
|
return None
|
||||||
@@ -620,6 +640,21 @@ def executer_action(action):
|
|||||||
"memoryQuery": "",
|
"memoryQuery": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nom_action == "analyser_taches":
|
||||||
|
if action.get("type") == "client_plus_taches":
|
||||||
|
snapshot = get_memory_snapshot(limit=100)
|
||||||
|
return formater_client_plus_taches(snapshot), {
|
||||||
|
"memoryRead": True,
|
||||||
|
"memoryResult": {
|
||||||
|
"clients": snapshot["clients"],
|
||||||
|
"projects": snapshot["projects"],
|
||||||
|
"tasks": snapshot["tasks"],
|
||||||
|
"repositories": snapshot["repositories"],
|
||||||
|
"memories": [],
|
||||||
|
},
|
||||||
|
"memoryQuery": "",
|
||||||
|
}
|
||||||
|
|
||||||
return "", {}
|
return "", {}
|
||||||
|
|
||||||
|
|
||||||
@@ -724,6 +759,33 @@ def formater_liste_clients(clients_mem):
|
|||||||
return "Voici tes clients :\n" + "\n".join(f"- {nom}" for nom in noms)
|
return "Voici tes clients :\n" + "\n".join(f"- {nom}" for nom in noms)
|
||||||
|
|
||||||
|
|
||||||
|
def formater_client_plus_taches(snapshot):
|
||||||
|
clients_avec_taches = [
|
||||||
|
client_mem for client_mem in snapshot["clients"]
|
||||||
|
if int(client_mem.get("open_task_count") or 0) > 0
|
||||||
|
]
|
||||||
|
if not clients_avec_taches:
|
||||||
|
return "Tu n'as aucune tache ouverte dans la memoire professionnelle."
|
||||||
|
|
||||||
|
max_count = max(int(client_mem["open_task_count"]) for client_mem in clients_avec_taches)
|
||||||
|
premiers = [
|
||||||
|
client_mem["name"] for client_mem in clients_avec_taches
|
||||||
|
if int(client_mem["open_task_count"]) == max_count
|
||||||
|
]
|
||||||
|
lignes = [
|
||||||
|
f"{client_mem['name']} : {client_mem['open_task_count']} tache(s)"
|
||||||
|
for client_mem in sorted(
|
||||||
|
clients_avec_taches,
|
||||||
|
key=lambda item: (-int(item["open_task_count"]), item["name"].lower()),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
if len(premiers) == 1:
|
||||||
|
intro = f"Le client avec le plus de taches ouvertes est {premiers[0]} avec {max_count} tache(s)."
|
||||||
|
else:
|
||||||
|
intro = f"Les clients avec le plus de taches ouvertes sont {', '.join(premiers)} avec {max_count} tache(s) chacun."
|
||||||
|
return intro + "\n" + "\n".join(f"- {ligne}" for ligne in lignes)
|
||||||
|
|
||||||
|
|
||||||
def traiter_message(session_id, texte, avec_audio=False):
|
def traiter_message(session_id, texte, avec_audio=False):
|
||||||
action_directe = detecter_action_directe(texte, session_id)
|
action_directe = detecter_action_directe(texte, session_id)
|
||||||
reponse = json.dumps(action_directe, ensure_ascii=False) if action_directe else demander_au_llm(session_id, texte)
|
reponse = json.dumps(action_directe, ensure_ascii=False) if action_directe else demander_au_llm(session_id, texte)
|
||||||
|
|||||||
Reference in New Issue
Block a user