-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
112 lines (101 loc) · 2.8 KB
/
index.html
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>XVi AI/title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.chat-container {
background-color: #ffffff;
border-radius: 5px;
padding: 20px;
width: 80%;
max-width: 600px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}
h1 {
text-align: center;
margin-bottom: 20px;
}
#chat-form {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
}
#user-input {
flex-grow: 1;
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
}
#submitBtn {
background-color: #4caf50;
color: white;
border: none;
border-radius: 5px;
padding: 10px 15px;
margin-left: 10px;
cursor: pointer;
}
#submitBtn:hover {
background-color: #45a049;
}
#result {
border: 1px solid #ccc;
border-radius: 5px;
padding: 20px;
background-color: #f8f8f8;
min-height: 100px;
overflow-wrap: break-word;
}
</style>
</head>
<body>
<div class="chat-container">
<h1>XVI AI </h1>
<form id="chat-form">
<input
type="text"
id="user-input"
name="user_input"
placeholder="Type your message..."
/>
<button type="submit" id="submitBtn">Send</button>
</form>
<div id="result"></div>
</div>
<script>
window.onload = function () {
document
.getElementById("chat-form")
.addEventListener("submit", function (event) {
// Prevent the form from submitting and refreshing the page
event.preventDefault();
let userInput = document.getElementById("user-input").value;
let url = `/gpt4?user_input=${encodeURIComponent(userInput)}`;
fetch(url)
.then((response) => response.json())
.then((data) => {
let content = data.content;
let resultDiv = document.getElementById("result");
resultDiv.innerHTML = content;
})
.catch((error) => {
console.error("Error fetching GPT-4 response:", error);
});
});
};
</script>
</body>
</html>