| |
| <!doctype html> |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8" /> |
| <title>Console Chat Tester</title> |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| <style> |
| body{ font-family: ui-sans-serif, system-ui, Arial; margin:20px; } |
| .row{ display:flex; gap:8px; align-items:center; margin:6px 0; } |
| input[type=text]{ flex:1; padding:8px; } |
| button{ padding:8px 10px; } |
| pre{ background:#0b1020; color:#d6e7ff; padding:10px; height:320px; overflow:auto; } |
| .chip{ display:inline-block; padding:3px 8px; background:#eef; border-radius:12px; margin-left:8px; } |
| </style> |
| </head> |
| <body> |
| <h2>AgenticCore Console</h2> |
|
|
| <div class="row"> |
| <label>Backend</label> |
| <input id="base" type="text" value="http://127.0.0.1:8000" /> |
| <button id="btnHealth">Health</button> |
| <button id="btnRoutes">Routes</button> |
| </div> |
|
|
| <div class="row"> |
| <input id="msg" type="text" placeholder="Say something…" /> |
| <button id="btnSend">POST /chatbot/message</button> |
| </div> |
|
|
| <div> |
| <span>Mode:</span> |
| <span id="mode" class="chip">API</span> |
| </div> |
|
|
| <pre id="out"></pre> |
|
|
| <script> |
| const $ = id => document.getElementById(id); |
| const out = $("out"); |
| function print(o){ out.textContent += (typeof o==="string" ? o : JSON.stringify(o,null,2)) + "\n"; out.scrollTop = out.scrollHeight; } |
| function join(b, p){ return b.replace(/\/+$/,"") + p; } |
| |
| async function health(){ |
| try{ |
| const r = await fetch(join($("base").value, "/health")); |
| print(await r.json()); |
| }catch(e){ print("health error: " + e); } |
| } |
| async function routes(){ |
| try{ |
| const r = await fetch(join($("base").value, "/openapi.json")); |
| const j = await r.json(); |
| print({ routes: Object.keys(j.paths) }); |
| }catch(e){ print("routes error: " + e); } |
| } |
| async function send(){ |
| const text = $("msg").value.trim(); |
| if(!text){ print("enter a message first"); return; } |
| try{ |
| const r = await fetch(join($("base").value, "/chatbot/message"), { |
| method:"POST", |
| headers:{ "Content-Type":"application/json" }, |
| body: JSON.stringify({ message: text }) |
| }); |
| print(await r.json()); |
| }catch(e){ print("send error: " + e); } |
| } |
| $("btnHealth").onclick = health; |
| $("btnRoutes").onclick = routes; |
| $("btnSend").onclick = send; |
| |
| |
| health(); |
| </script> |
| </body> |
| </html> |
|
|