File size: 1,058 Bytes
5e47e93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
async function runSigil() {

    const input = document.getElementById("inputBox").value;
    setStatus("calling backend...");

    try {
        const res = await fetch(
            "https://nine1eight-vil-glyphmatic-demo.hf.space/api/predict",
            {
                method: "POST",
                headers: { "Content-Type": "application/json" },
                body: JSON.stringify({
                    data: [input, "web-session"]
                })
            }
        );

        if (!res.ok) throw new Error("HTTP " + res.status);

        const json = await res.json();

        console.log("API RESPONSE:", json);

        const [response, lattice, inspect] = json.data;

        document.getElementById("responseBox").innerText = response;
        document.getElementById("glyphBox").innerText = lattice;
        document.getElementById("inspectBox").innerText = inspect;

        renderGlyphs(lattice);

        setStatus("success");

    } catch (err) {
        console.error(err);
        setStatus("ERROR: " + err.message);
    }
}