84 lines
3.9 KiB
Python
84 lines
3.9 KiB
Python
#!/usr/bin/env python3
|
|
"""V113 - Add Quick Test Intent panel in Hub Capabilities tab"""
|
|
path = "/var/www/html/all-ia-hub.html"
|
|
with open(path, "r", encoding="utf-8") as f:
|
|
c = f.read()
|
|
|
|
if "V113-QUICK-INTENTS" in c:
|
|
print("ALREADY")
|
|
exit(0)
|
|
|
|
# Find the Blade section end (before DeepSeek Web Access card)
|
|
anchor = '<div class="cap">\n <h3>🌐 DeepSeek Web Access</h3>'
|
|
|
|
add_panel = '''<!-- V113-QUICK-INTENTS: test any intent from chat -->
|
|
<div class="cap" style="grid-column:1 / -1;background:linear-gradient(135deg,#1e293b,#0f172a);border-color:var(--vl)">
|
|
<h3>⚡ Quick Test Any Intent — 2004 intents live</h3>
|
|
<p style="margin-bottom:10px">Tape un trigger ci-dessous ou choisis un preset. Repond: <b id="intent-latency">-</b></p>
|
|
<div style="display:flex;gap:6px;margin-bottom:8px">
|
|
<input id="intent-input" type="text" placeholder="tape un trigger (ex: show tips, bilan complet, tous les agents, tips all, autowire, autoentraine)" style="flex:1;background:var(--bg3);border:1px solid var(--rim);border-radius:4px;padding:6px 10px;color:var(--t);font-family:inherit;font-size:11px"/>
|
|
<button class="mode" onclick="testIntent()">TEST</button>
|
|
</div>
|
|
<div style="display:flex;gap:4px;flex-wrap:wrap;margin-bottom:8px">
|
|
<button class="mode" onclick="setIntent('show tips')">show tips</button>
|
|
<button class="mode" onclick="setIntent('tips all')">tips all</button>
|
|
<button class="mode" onclick="setIntent('bilan complet')">bilan complet</button>
|
|
<button class="mode" onclick="setIntent('tous les agents en parallele')">tous les agents</button>
|
|
<button class="mode" onclick="setIntent('que peux tu faire')">capabilities</button>
|
|
<button class="mode" onclick="setIntent('autowire')">autowire</button>
|
|
<button class="mode" onclick="setIntent('autoentraine')">autoentraine</button>
|
|
<button class="mode" onclick="setIntent('create tool')">create tool</button>
|
|
<button class="mode" onclick="setIntent('push blade task')">blade tasks</button>
|
|
</div>
|
|
<pre id="intent-output" style="background:var(--bg3);padding:8px;border-radius:4px;font-size:10px;color:var(--mu);max-height:220px;overflow:auto;white-space:pre-wrap;word-break:break-word;display:none;margin:0"></pre>
|
|
</div>
|
|
<div class="cap">
|
|
<h3>🌐 DeepSeek Web Access</h3>'''
|
|
|
|
if anchor not in c:
|
|
print("ANCHOR NOT FOUND")
|
|
exit(1)
|
|
|
|
c = c.replace(anchor, add_panel, 1)
|
|
|
|
# Add JS functions before refreshBladeStats
|
|
js_anchor = "// V111-BLADE-ENRICH: live blade tasks"
|
|
js_add = '''// V113-QUICK-INTENTS: test any intent
|
|
function setIntent(s){ document.getElementById('intent-input').value=s; }
|
|
async function testIntent(){
|
|
const inp=document.getElementById('intent-input');
|
|
const out=document.getElementById('intent-output');
|
|
const lat=document.getElementById('intent-latency');
|
|
const msg=inp.value.trim();
|
|
if(!msg){out.style.display='block';out.textContent='Tape un trigger d abord';return;}
|
|
out.style.display='block';
|
|
out.textContent='Loading...';
|
|
lat.textContent='...';
|
|
const t0=Date.now();
|
|
try{
|
|
const r=await fetch('/api/wevia-master-api.php',{
|
|
method:'POST',
|
|
headers:{'Content-Type':'application/json'},
|
|
body:JSON.stringify({message:msg,session_id:'hub-v113-test-'+Date.now()}),
|
|
signal:AbortSignal.timeout(60000)
|
|
});
|
|
const d=await r.json();
|
|
const t=((Date.now()-t0)/1000).toFixed(1);
|
|
lat.textContent=t+'s '+(d.provider||d.tool||'?');
|
|
const txt=d.content||d.response||d.text||d.output||JSON.stringify(d,null,2);
|
|
out.textContent=txt.substring(0,2500);
|
|
}catch(e){
|
|
out.textContent='Error: '+e.message;
|
|
lat.textContent='err';
|
|
}
|
|
}
|
|
|
|
// V111-BLADE-ENRICH: live blade tasks'''
|
|
|
|
if js_anchor in c:
|
|
c = c.replace(js_anchor, js_add, 1)
|
|
|
|
with open(path, "w", encoding="utf-8") as f:
|
|
f.write(c)
|
|
print(f"PATCHED size={len(c)}")
|