26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
(function () {
|
|||
|
|
var select = document.getElementById("adk-template");
|
||
|
|
var out = document.getElementById("adk-out");
|
||
|
|
function show(res) {
|
||
|
|
return res.json().then(function (j) { out.textContent = JSON.stringify(j, null, 2); });
|
||
|
|
}
|
||
|
|
function post(path, body) {
|
||
|
|
return fetch(path, { method: "POST", headers: { "Content-Type": "application/json" },
|
||
|
|
body: JSON.stringify(body) }).then(show).catch(function (e) { out.textContent = String(e); });
|
||
|
|
}
|
||
|
|
fetch("/agent/adk/garden").then(function (r) { return r.json(); }).then(function (j) {
|
||
|
|
j.templates.forEach(function (t) {
|
||
|
|
var o = document.createElement("option");
|
||
|
|
o.value = t.id; o.textContent = t.title; select.appendChild(o);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
document.getElementById("adk-run").addEventListener("click", function () {
|
||
|
|
out.textContent = "Running...";
|
||
|
|
post("/agent/adk/run", { template: select.value,
|
||
|
|
prompt: document.getElementById("adk-prompt").value });
|
||
|
|
});
|
||
|
|
document.getElementById("adk-export").addEventListener("click", function () {
|
||
|
|
post("/agent/adk/export", { template: select.value });
|
||
|
|
});
|
||
|
|
})();
|