File size: 889 Bytes
8ef3a6b | 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 | /**
* Mount the ISCC-AI copilot chat widget with anonymous authentication.
*
* Shared across all ISCC documentation sites. Do not modify per project.
*
* Fetches a JWT token from the copilot-token endpoint, then mounts the
* Chainlit copilot widget with the token for cross-origin authentication.
*/
window.addEventListener("load", async function () {
if (typeof window.mountChainlitWidget !== "function") return;
var server = "https://iscc.ai";
var tokenUrl = server + "/api/copilot-token";
try {
var response = await fetch(tokenUrl);
var data = await response.json();
window.mountChainlitWidget({
chainlitServer: server,
theme: "light",
accessToken: data.accessToken,
customCssUrl: window.location.origin + "/stylesheets/copilot.css?v=7",
});
} catch (e) {
console.warn("ISCC-AI copilot: failed to fetch token", e);
}
});
|