OpenAi / index.html
Kaige1's picture
Create index.html
4ad45ed
<!DOCTYPE html>
<html>
<head>
<title>Artist Chatbot</title>
</head>
<body>
<h1>Artist Chatbot</h1>
<form id="chat-form">
<input type="text" id="user-input" placeholder="Enter your message">
<button type="submit">Send</button>
</form>
<div id="response-container"></div>
<script>
// Submit the user input and display the response
document.getElementById("chat-form").addEventListener("submit", function(event) {
event.preventDefault();
var userInput = document.getElementById("user-input").value;
fetch("/api/chat", {
method: "POST",
body: new URLSearchParams({
user_input: userInput
})
})
.then(response => response.text())
.then(data => {
var responseContainer = document.getElementById("response-container");
responseContainer.innerHTML += "<p><strong>User:</strong> " + userInput + "</p>";
responseContainer.innerHTML += "<p><strong>ChatGPT:</strong> " + data + "</p>";
document.getElementById("user-input").value = "";
});
});
</script>
</body>
</html>