Spaces:
Runtime error
Runtime error
DmitrMakeev
commited on
Commit
•
290296c
1
Parent(s):
40b2e70
Update settings.html
Browse files- settings.html +0 -75
settings.html
CHANGED
@@ -214,81 +214,6 @@ input[type="number"] {
|
|
214 |
<br><br><br><br>
|
215 |
|
216 |
|
217 |
-
<style>
|
218 |
-
#chat-box {
|
219 |
-
width: 300px;
|
220 |
-
height: 400px;
|
221 |
-
border: 1px solid #ccc;
|
222 |
-
overflow-y: scroll;
|
223 |
-
padding: 10px;
|
224 |
-
}
|
225 |
-
.message {
|
226 |
-
margin: 5px 0;
|
227 |
-
}
|
228 |
-
.message.user {
|
229 |
-
text-align: right;
|
230 |
-
color: blue;
|
231 |
-
}
|
232 |
-
.message.bot {
|
233 |
-
text-align: left;
|
234 |
-
color: green;
|
235 |
-
}
|
236 |
-
</style>
|
237 |
-
</head>
|
238 |
-
<body>
|
239 |
-
<div id="chat-box"></div>
|
240 |
-
<input type="text" id="user-input" placeholder="Type a message...">
|
241 |
-
<button id="send-btn">Send</button>
|
242 |
-
|
243 |
-
<script>
|
244 |
-
const chatBox = document.getElementById('chat-box');
|
245 |
-
const userInput = document.getElementById('user-input');
|
246 |
-
const sendBtn = document.getElementById('send-btn');
|
247 |
-
|
248 |
-
sendBtn.addEventListener('click', () => {
|
249 |
-
const userMessage = userInput.value;
|
250 |
-
if (!userMessage) return;
|
251 |
-
|
252 |
-
appendMessage('user', userMessage);
|
253 |
-
userInput.value = '';
|
254 |
-
|
255 |
-
const apiKey = "sk-d77e468c052044eeaefb0f816f3e0944";
|
256 |
-
const apiUrl = "https://api.deepseek.com/v1/chat/completions";
|
257 |
-
|
258 |
-
fetch(apiUrl, {
|
259 |
-
method: 'POST',
|
260 |
-
headers: {
|
261 |
-
'Content-Type': 'application/json',
|
262 |
-
'Authorization': `Bearer ${apiKey}`
|
263 |
-
},
|
264 |
-
body: JSON.stringify({
|
265 |
-
model: "deepseek-chat",
|
266 |
-
messages: [
|
267 |
-
{ role: "system", content: "You are a helpful assistant" },
|
268 |
-
{ role: "user", content: userMessage }
|
269 |
-
],
|
270 |
-
stream: false
|
271 |
-
})
|
272 |
-
})
|
273 |
-
.then(response => response.json())
|
274 |
-
.then(data => {
|
275 |
-
const botMessage = data.choices[0].message.content;
|
276 |
-
appendMessage('bot', botMessage);
|
277 |
-
})
|
278 |
-
.catch(error => {
|
279 |
-
console.error('Error:', error);
|
280 |
-
appendMessage('bot', 'Error: Could not retrieve response.');
|
281 |
-
});
|
282 |
-
});
|
283 |
-
|
284 |
-
function appendMessage(role, message) {
|
285 |
-
const messageDiv = document.createElement('div');
|
286 |
-
messageDiv.classList.add('message', role);
|
287 |
-
messageDiv.textContent = message;
|
288 |
-
chatBox.appendChild(messageDiv);
|
289 |
-
chatBox.scrollTop = chatBox.scrollHeight;
|
290 |
-
}
|
291 |
-
</script>
|
292 |
|
293 |
</div>
|
294 |
|
|
|
214 |
<br><br><br><br>
|
215 |
|
216 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
218 |
</div>
|
219 |
|