DmitrMakeev commited on
Commit
40b2e70
1 Parent(s): 4a46bb7

Update settings.html

Browse files
Files changed (1) hide show
  1. settings.html +73 -84
settings.html CHANGED
@@ -214,92 +214,81 @@ input[type="number"] {
214
  <br><br><br><br>
215
 
216
 
217
- <style>
218
- body {
219
- font-family: Arial, sans-serif;
220
- padding: 20px;
221
- }
222
- #chat-container {
223
- max-width: 600px;
224
- margin: 0 auto;
225
- }
226
- #chat-output {
227
- background: #f9f9f9;
228
- border: 1px solid #ddd;
229
- padding: 10px;
230
- margin-bottom: 10px;
231
- height: 200px;
232
- overflow-y: scroll;
233
- }
234
- #user-input {
235
- width: 70%;
236
- padding: 10px;
237
- margin-right: 10px;
238
- }
239
- button {
240
- padding: 10px;
241
- background: #007BFF;
242
- color: white;
243
- border: none;
244
- cursor: pointer;
245
- }
246
- button:hover {
247
- background: #0056b3;
248
- }
249
- </style>
250
  </head>
251
  <body>
252
-
253
- <div id="chat-container">
254
- <div id="chat-output"></div>
255
- <input type="text" id="user-input" placeholder="Type your message here...">
256
- <button onclick="sendMessage()">Send</button>
257
- </div>
258
-
259
- <script>
260
- const API_KEY = 'sk-d77e468c052044eeaefb0f816f3e0944'; // Замените на ваш ключ API
261
- const BASE_URL = 'https://api.openai.com/v1/chat/completions';
262
-
263
- function sendMessage() {
264
- const userInput = document.getElementById('user-input').value;
265
- const outputDiv = document.getElementById('chat-output');
266
-
267
- // Очищаем поле ввода
268
- document.getElementById('user-input').value = '';
269
-
270
- // Добавляем сообщение пользователя в чат
271
- outputDiv.innerHTML += `<p><strong>You:</strong> ${userInput}</p>`;
272
-
273
- // Формируем запрос к API
274
- const requestOptions = {
275
- method: 'POST',
276
- headers: {
277
- 'Content-Type': 'application/json',
278
- 'Authorization': `Bearer ${API_KEY}`
279
- },
280
- body: JSON.stringify({
281
- model: 'deepseek-chat',
282
- messages: [
283
- {"role": "system", "content": "You are a helpful assistant"},
284
- {"role": "user", "content": userInput}
285
- ],
286
- stream: false
287
- })
288
- };
289
-
290
- // Отправляем запрос к API
291
- fetch(BASE_URL, requestOptions)
292
- .then(response => response.json())
293
- .then(data => {
294
- // Обрабатываем ответ от API
295
- const aiResponse = data.choices[0].message.content;
296
- outputDiv.innerHTML += `<p><strong>AI:</strong> ${aiResponse}</p>`;
297
- })
298
- .catch(error => {
299
- console.error('Error:', error);
300
- });
301
- }
302
- </script>
 
 
303
 
304
  </div>
305
 
 
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