Files
html/api/helpers/v72_plan_nl.py
2026-04-18 02:35:02 +02:00

64 lines
1.9 KiB
Python
Executable File

#!/usr/bin/env python3
"""V72 Plan NL - Yacine ajoute action via chat NL"""
import sys, re, urllib.request, urllib.parse, json
msg = ' '.join(sys.argv[1:]) if len(sys.argv) > 1 else ''
if not msg:
print("Usage: plan_nl.py <msg>")
sys.exit(1)
title_match = re.search(r'(?:action|item|ajouter|nouvelle)\s+(.+?)(?:\s+priority|\s+priorit|\s+eta|\s+cat|\s+source|$)', msg, re.IGNORECASE)
title = title_match.group(1).strip() if title_match else msg[:80]
priority = 'medium'
for p in ['critical', 'high', 'medium', 'low']:
if p in msg.lower():
priority = p
break
source = 'manual'
if 'github' in msg.lower() or 'clone' in msg.lower():
source = 'github-clone'
elif 'source pure' in msg.lower() or 'source-pure' in msg.lower():
source = 'source-pure'
elif 'training' in msg.lower():
source = 'training'
eta_match = re.search(r'V\d+', msg)
eta = eta_match.group(0) if eta_match else 'V72'
github_url = ''
url_match = re.search(r'https?://\S+', msg)
if url_match:
github_url = url_match.group(0)
category = 'wiring'
for c in ['hallucination', 'benchmark', 'safety', 'rag', 'monitoring', 'infra', 'finetuning', 'factuality']:
if c in msg.lower():
category = c
break
params = urllib.parse.urlencode({
'action': 'plan_add',
'title': title,
'source': source,
'github_url': github_url,
'priority': priority,
'category': category,
'eta': eta
})
url = f'http://127.0.0.1:5890/api/wevia-v71-risk-halu-plan.php?{params}'
try:
r = urllib.request.urlopen(url, timeout=5)
res = json.loads(r.read().decode())
print(f"Plan item added: {res.get('id','?')}")
print(f" title: {title}")
print(f" priority: {priority}")
print(f" source: {source}")
print(f" category: {category}")
print(f" eta: {eta}")
print(f"Total items: {res.get('total','?')}")
except Exception as e:
print(f"ERR: {e}")
sys.exit(1)