models: EndpointAdmin and PublisherAdmin wrap every remaining method of the owned resources (84 call table rows, 132 Discovery methods covered, v1beta1 twins, IAM, operations, responses, export, config, enableModel); planner rejects undeclared body keys; VertexModel::TurnBuilder replays model turns with every thoughtSignature; Lyria WAV mime from bytes; veo-3.1 default. runtime: v1beta1 feedbackEntries, A2A gateway (40 rpcs), a2aTasks, task store records, scoped operations, beta twin flag (103 rows, 214 methods covered); checker verifies twins, a2aEndpoint patterns and coverage. example: admin routes for both parts. SPECs: live results moved from Unverified to Verified live (Veo, Lyria, thought signatures, v1beta1 routes). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
68 lines
3.1 KiB
JavaScript
68 lines
3.1 KiB
JavaScript
// Models page: posts the chosen action to /agent/models/<action>.
|
|
(function () {
|
|
"use strict";
|
|
var $ = function (id) { return document.getElementById(id); };
|
|
var routes = {
|
|
generate: "/agent/models/generate", count: "/agent/models/count",
|
|
embed: "/agent/models/embed", claude: "/agent/models/claude",
|
|
list: "/agent/models/list", image: "/agent/models/image",
|
|
music: "/agent/models/music", video: "/agent/models/video"
|
|
};
|
|
var MAX_OUT = 20000;
|
|
|
|
fetch("/agent/models/status").then(function (r) { return r.json(); }).then(function (s) {
|
|
$("m-config").textContent = s.configured
|
|
? "Credential found. Mode: " + s.mode + ". Default model: " + s.default_model + "."
|
|
: "No Google credential configured: calls answer 503 until GOOGLE_API_KEY is set.";
|
|
}).catch(function () { $("m-config").textContent = "Status unavailable."; });
|
|
|
|
// Admin panel: one example body per route (the server validates everything).
|
|
var templates = {
|
|
"endpoints": { action: "list_beta" },
|
|
"endpoint/call": { kind: "compute_tokens", endpoint: "ENDPOINT_ID",
|
|
contents: [{ role: "user", parts: [{ text: "hello" }] }] },
|
|
"endpoint/operations": { action: "list", endpoint: "ENDPOINT_ID" },
|
|
"publisher": { action: "beta_get", publisher: "google", model: "gemini-2.5-flash" }
|
|
};
|
|
function fillAdmin() {
|
|
$("m-admin-body").value = JSON.stringify(templates[$("m-admin-route").value], null, 1);
|
|
}
|
|
$("m-admin-route").addEventListener("change", fillAdmin);
|
|
fillAdmin();
|
|
$("m-admin-run").addEventListener("click", function () {
|
|
var body;
|
|
try { body = JSON.parse($("m-admin-body").value || "{}"); }
|
|
catch (e) { $("m-error").textContent = "Body is not valid JSON"; return; }
|
|
$("m-error").textContent = "";
|
|
$("m-out").textContent = "...";
|
|
fetch("/agent/models/" + $("m-admin-route").value, {
|
|
method: "POST", headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(body)
|
|
}).then(function (r) {
|
|
return r.text().then(function (t) { return { ok: r.ok, text: t }; });
|
|
}).then(function (res) {
|
|
if (!res.ok) { $("m-error").textContent = res.text.slice(0, 300); $("m-out").textContent = ""; return; }
|
|
$("m-out").textContent = res.text.slice(0, MAX_OUT);
|
|
}).catch(function (e) { $("m-error").textContent = String(e); });
|
|
});
|
|
|
|
$("m-run").addEventListener("click", function () {
|
|
var action = $("m-action").value;
|
|
var prompt = $("m-prompt").value;
|
|
var body = { prompt: prompt };
|
|
if (action === "embed") body = { text: prompt };
|
|
if ($("m-model").value) body.model = $("m-model").value;
|
|
$("m-error").textContent = "";
|
|
$("m-out").textContent = "...";
|
|
fetch(routes[action], {
|
|
method: "POST", headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(body)
|
|
}).then(function (r) {
|
|
return r.text().then(function (t) { return { ok: r.ok, text: t }; });
|
|
}).then(function (res) {
|
|
if (!res.ok) { $("m-error").textContent = res.text.slice(0, 300); $("m-out").textContent = ""; return; }
|
|
$("m-out").textContent = res.text.slice(0, MAX_OUT);
|
|
}).catch(function (e) { $("m-error").textContent = String(e); });
|
|
});
|
|
})();
|