File size: 2,326 Bytes
732e77c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!-- /app/assets/html/chat_console.html -->
<!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;

// boot
health();
</script>
</body>
</html>