Spaces:
Running
Running
Update index.html
Browse files- index.html +14 -3
index.html
CHANGED
@@ -44,6 +44,8 @@
|
|
44 |
<button onclick="sendMessage()">Send</button>
|
45 |
</div>
|
46 |
<script>
|
|
|
|
|
47 |
function appendMessage(who, text) {
|
48 |
const div = document.createElement('div');
|
49 |
div.className = who;
|
@@ -59,9 +61,18 @@
|
|
59 |
// Append user message to chat
|
60 |
appendMessage('user', text);
|
61 |
|
62 |
-
//
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
</script>
|
67 |
</body>
|
|
|
44 |
<button onclick="sendMessage()">Send</button>
|
45 |
</div>
|
46 |
<script>
|
47 |
+
const endpoint = 'YOUR_SPACE_URL_HERE'; // Replace with your Space's URL
|
48 |
+
|
49 |
function appendMessage(who, text) {
|
50 |
const div = document.createElement('div');
|
51 |
div.className = who;
|
|
|
61 |
// Append user message to chat
|
62 |
appendMessage('user', text);
|
63 |
|
64 |
+
// Make a request to your AI model to get a response
|
65 |
+
fetch(endpoint, {
|
66 |
+
method: 'POST',
|
67 |
+
headers: { 'Content-Type': 'application/json' },
|
68 |
+
body: JSON.stringify({ prompt: text })
|
69 |
+
})
|
70 |
+
.then(response => response.json())
|
71 |
+
.then(data => {
|
72 |
+
// Append AI response to chat
|
73 |
+
appendMessage('bot', data.response);
|
74 |
+
})
|
75 |
+
.catch(error => console.error('Error:', error));
|
76 |
}
|
77 |
</script>
|
78 |
</body>
|