gpt-4o-2024-08-06· openai
WildChat-4.8M
Пожалуйста, сформируй полный HTML-код (ничего не пропускай), выделив его обратными…
- User
Пожалуйста, сформируй полный HTML-код (ничего не пропускай), выделив его обратными тройными кавычками, для следующего запроса: "Есть функция запроса к нейросети requestAI. При нажатии на кнопку "Придумать историю" ты должен отправить запрос таким образом
Придумай историю на основе запроса "${значение поля}" на языке "${текущий язык}"". В прошлой итерации код выглядел следующим образом: "#container { width: 90%; max-width: 600px; display: flex; flex-direction: column; align-items: center; gap: 15px; height: 90%; box-sizing: border-box; } h1 { margin: 0; font-size: 2.5em; color: #333; } #language-switch { position: absolute; top: 10px; right: 10px; width: 80px; user-select: none; } .custom-select { position: relative; display: inline-block; } .select-selected { background-color: #4CAF50; color: white; padding: 8px 12px; border-radius: 8px; cursor: pointer; text-align: center; transition: background-color 0.3s ease; } .select-selected:hover { background-color: #45a049; } .select-items { position: absolute; background-color: white; border: 1px solid #ddd; border-radius: 8px; width: 100%; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1); z-index: 99; display: none; animation: slideDown 0.3s forwards; } .select-items.open { display: block; animation: slideDown 0.3s forwards; } .select-items div { color: #333; padding: 8px 12px; cursor: pointer; transition: background-color 0.3s; } .select-items div:hover { background-color: #f1f1f1; } textarea { width: 100%; flex-grow: 1; resize: none; padding: 10px; font-size: 1em; border-radius: 8px; border: 1px solid #ccc; box-sizing: border-box; min-height: 100px; max-height: 200px; } textarea:focus { outline: none; border-color: blue; } button { padding: 10px 20px; font-size: 1.2em; border-radius: 8px; border: none; background-color: #4CAF50; color: white; cursor: pointer; transition: background-color 0.3s ease; } button:hover { background-color: #45a049; } @keyframes slideDown { from { max-height: 0; opacity: 0; } to { max-height: 500px; opacity: 1; } } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } </style><script> function switchLanguage(language) { const textElements = { title: { ru: "AI Stories", en: "AI Stories" }, button: { ru: "Придумать историю", en: "Generate Story" }, placeholder: { ru: "Введите текст здесь...", en: "Enter text here..." } }; document.querySelector('h1').innerText = textElements.title[language]; document.querySelector('button').innerText = textElements.button[language]; document.querySelector('textarea').placeholder = textElements.placeholder[language]; } document.addEventListener('DOMContentLoaded', () => { const selected = document.querySelector('.select-selected'); const items = document.querySelector('.select-items'); selected.addEventListener('click', function() { items.classList.toggle('open'); }); document.querySelectorAll('.select-items div').forEach(item => { item.addEventListener('click', function() { selected.textContent = this.textContent; items.classList.remove('open'); switchLanguage(this.getAttribute('data-value')); }); }); document.addEventListener('click', function(e) { if (!e.target.closest('.custom-select')) { items.classList.remove('open'); } }); }); /* Функция запроса к нейросети Пример использования: Запрос на получение текста (ограничение 20 запросов каждые 2 минуты): requestAI('Придумай краткое начало истории', { responseCallback: ({ data, modData, message, isStream, isStreaming }) => { console.log({ callback: 'responseCallback', data, modData, message, isStream, isStreaming }); }, errorCallback: ({ message, error }) => { console.log(message); }, }); Запрос на получение картинки (ограничение 4 запроса каждые 5 минут): requestAI('A cat', { type: 'image', responseCallback: ({ data, modData, images, image, imageNode }) => { // image - src картинки, imageNode - DOM-элемент картинки с указанным src console.log({ callback: 'responseCallback', data, modData, images, image, imageNode }); }, errorCallback: ({ message, error }) => { console.log(message); }, }); */ function requestAI(prompt, { url = 'https://nexra.aryahcr.cc/api/chat/complements', model = 'gpt-4o', stream = false, markdown = false, type = 'text', messages = [], // Бывают roles: system, user, assistant responseCallback = () => { }, // Колбек ответа от сервера вне зависимости от стриминга successCallback = () => { }, // Колбек для успешного завершения errorCallback = () => { }, // Колбек ошибки } = {}) { if (type === 'text') { // Текст messages.push({ role: 'user', content: prompt }); let body = { messages, model, stream, markdown, }; if (url.indexOf('/gptweb') !== -1) { body = { prompt, markdown, }; } if (messages.length > 1 && model === 'llama-3.1') { body.messages = [{ role: 'user', content: JSON.stringify({ messages: messages }) }]; } if (model === 'Bing') { body['conversation_style'] = 'balanced'; } if (model === 'blackbox') { body['websearch'] = false; } fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(body), }).then(response => response.text()).then((data) => { const modData = JSON.parse(data.slice(data.indexOf('{'))); const message = modData.message || modData.gpt; responseCallback({ data, modData, message, isStream: stream, isStreaming: false }); successCallback({ data, modData, message, isStream: stream, isStreaming: false }); }).catch((error) => { errorCallback({ message: `Ошибка в функции requestAI (type: text, stream: false): ${error}`, error }); }); } else if (type === 'image') { // Картинка model = 'emi'; fetch("https://nexra.aryahcr.cc/api/image/complements", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ prompt, model, //response: "base64" }) }).then((response) => { response.text().then((data) => { const modData = JSON.parse(data.slice(data.indexOf('{'))); const images = modData.images; const imageNode = document.createElement('img'); imageNode.className = 'image'; imageNode.src = images[0]; responseCallback({ data, modData, images, image: images[0], imageNode }); successCallback({ data, modData, images, image: images[0], imageNode }); }).catch((err) => { errorCallback({ message: `Ошибка в функции requestAI (type: image): ${err}`, err }); }); }).catch((err) => { errorCallback({ message: `Ошибка в функции requestAI (type: image): ${err}`, err }); }); } } </script> - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.