Spaces:
Runtime error
Runtime error
Commit
·
e8caf01
1
Parent(s):
2e156e1
fixed html
Browse files- templates/index.html +1 -131
templates/index.html
CHANGED
|
@@ -1,130 +1,3 @@
|
|
| 1 |
-
<<<<<<< HEAD
|
| 2 |
-
<!DOCTYPE html>
|
| 3 |
-
<html lang="en">
|
| 4 |
-
|
| 5 |
-
<head>
|
| 6 |
-
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
| 7 |
-
<title>AI API</title>
|
| 8 |
-
<style>
|
| 9 |
-
body {
|
| 10 |
-
font-family: Arial, sans-serif;
|
| 11 |
-
margin: 20px;
|
| 12 |
-
background-color: rgb(50, 50, 50);
|
| 13 |
-
}
|
| 14 |
-
|
| 15 |
-
button {
|
| 16 |
-
cursor: pointer;
|
| 17 |
-
|
| 18 |
-
border-style: solid;
|
| 19 |
-
border-width: 3px;
|
| 20 |
-
border-style: solid;
|
| 21 |
-
border-radius: 5px;
|
| 22 |
-
|
| 23 |
-
text-align: center;
|
| 24 |
-
|
| 25 |
-
margin: 3px;
|
| 26 |
-
margin-top: 0;
|
| 27 |
-
margin-bottom: 0;
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
input {
|
| 31 |
-
width: 200px;
|
| 32 |
-
padding: 10px;
|
| 33 |
-
border: 1px solid #ccc;
|
| 34 |
-
background-color: #6b6e7266;
|
| 35 |
-
color: #e9e9e9;
|
| 36 |
-
border-radius: 4px;
|
| 37 |
-
|
| 38 |
-
transition: all, 0.35s;
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
input:focus {
|
| 42 |
-
outline: none;
|
| 43 |
-
}
|
| 44 |
-
|
| 45 |
-
.img {
|
| 46 |
-
width: 40vh;
|
| 47 |
-
height: 40vh;
|
| 48 |
-
margin: 30px;
|
| 49 |
-
display: inline-block;
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
.video {
|
| 53 |
-
width: 40vh;
|
| 54 |
-
height: 40vh;
|
| 55 |
-
margin: 30px;
|
| 56 |
-
display: inline-block;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
.text {
|
| 60 |
-
color: rgb(223, 223, 223);
|
| 61 |
-
}
|
| 62 |
-
</style>
|
| 63 |
-
</head>
|
| 64 |
-
|
| 65 |
-
<body>
|
| 66 |
-
<h1 class="text">Chat with me</h1>
|
| 67 |
-
<div id="responses"></div>
|
| 68 |
-
|
| 69 |
-
<input class="input" type="text" id="prompt" placeholder="bake a cake">
|
| 70 |
-
<button class="send-button" id="send-prompt">
|
| 71 |
-
<i class="material-icons">send</i>
|
| 72 |
-
</button>
|
| 73 |
-
|
| 74 |
-
<script>
|
| 75 |
-
const apiUrl = `https://beveledcube-bevelapi.hf.space/api`;
|
| 76 |
-
const sendPromptButton = document.getElementById("send-prompt");
|
| 77 |
-
const responseContainer = document.getElementById("responses");
|
| 78 |
-
|
| 79 |
-
sendPromptButton.addEventListener("click", async () => {
|
| 80 |
-
console.log("Sending prompt")
|
| 81 |
-
|
| 82 |
-
const responseElement = document.createElement("div");
|
| 83 |
-
const requestData = { prompt: getValue("prompt") };
|
| 84 |
-
|
| 85 |
-
responseElement.classList.add("response-container");
|
| 86 |
-
|
| 87 |
-
responseElement.innerHTML = `<span class="text"><p><strong>You<br></strong>${requestData.prompt}</p>`;
|
| 88 |
-
|
| 89 |
-
responseContainer.appendChild(responseElement);
|
| 90 |
-
|
| 91 |
-
fetch(apiUrl, {
|
| 92 |
-
method: "POST",
|
| 93 |
-
headers: {
|
| 94 |
-
"Content-Type": "application/json"
|
| 95 |
-
},
|
| 96 |
-
body: JSON.stringify(requestData)
|
| 97 |
-
})
|
| 98 |
-
.then(response => {
|
| 99 |
-
if (!response.ok) {
|
| 100 |
-
throw new Error("Network response was " + response.status.toString());
|
| 101 |
-
}
|
| 102 |
-
|
| 103 |
-
return response.json();
|
| 104 |
-
})
|
| 105 |
-
.then(data => {
|
| 106 |
-
console.log("Response from API:", data);
|
| 107 |
-
const responseElement = document.createElement("div");
|
| 108 |
-
|
| 109 |
-
responseElement.classList.add("response-container");
|
| 110 |
-
|
| 111 |
-
responseElement.innerHTML = `<span class="text"><p><strong>AI<br></strong>${data.answer.replace("\n", "<br>")}</p>`;
|
| 112 |
-
|
| 113 |
-
responseContainer.appendChild(responseElement);
|
| 114 |
-
})
|
| 115 |
-
.catch(error => {
|
| 116 |
-
console.error("Error:", error.message);
|
| 117 |
-
});
|
| 118 |
-
|
| 119 |
-
});
|
| 120 |
-
|
| 121 |
-
function getValue(elementId) {
|
| 122 |
-
return document.getElementById(elementId).value;
|
| 123 |
-
}
|
| 124 |
-
</script>
|
| 125 |
-
</body>
|
| 126 |
-
|
| 127 |
-
=======
|
| 128 |
<!DOCTYPE html>
|
| 129 |
<html lang="en">
|
| 130 |
|
|
@@ -248,7 +121,4 @@
|
|
| 248 |
return document.getElementById(elementId).value;
|
| 249 |
}
|
| 250 |
</script>
|
| 251 |
-
</body>
|
| 252 |
-
|
| 253 |
-
>>>>>>> 2cb4613 (Modified frontend and added a few models)
|
| 254 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
|
|
|
|
| 121 |
return document.getElementById(elementId).value;
|
| 122 |
}
|
| 123 |
</script>
|
| 124 |
+
</body>
|
|
|
|
|
|
|
|
|