diff options
author | mayx | 2024-01-01 10:53:46 +0000 |
---|---|---|
committer | mayx | 2024-01-01 10:53:46 +0000 |
commit | 8f7d02697dce507ff6b34fef41cf4d9e43124a52 (patch) | |
tree | f5673a9b6022bcce5d927b7329a5f7a32f9c70a4 | |
parent | 4afea923c5f83d3bf056006abde80e8fbf83f04a (diff) |
Update 5 files
- /card.html - /llama.html - /index.html - /Live2dHistoire/live2d/js/message.js - /js/main.js
-rw-r--r-- | Live2dHistoire/live2d/js/message.js | 2 | ||||
-rw-r--r-- | card.html | 18 | ||||
-rw-r--r-- | index.html | 2 | ||||
-rw-r--r-- | js/main.js | 2 | ||||
-rw-r--r-- | llama.html | 385 |
5 files changed, 388 insertions, 21 deletions
diff --git a/Live2dHistoire/live2d/js/message.js b/Live2dHistoire/live2d/js/message.js index 5a1ae5a..ca6cf11 100644 --- a/Live2dHistoire/live2d/js/message.js +++ b/Live2dHistoire/live2d/js/message.js @@ -287,7 +287,7 @@ if(!norunFlag){ showMessage('思考中~', 0); $.ajax({ type: 'POST', - url: "https://turing-api.mayx.eu.org/", + url: talkAPI, data: { "info": info_, "userId": userid_ diff --git a/card.html b/card.html deleted file mode 100644 index 45d95f9..0000000 --- a/card.html +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><title>抽卡</title> -<script type="text/javascript"> -window.onload=function (){ -o.imgRandom(); -} -var o={ -aImg:['1001', '1002', '1003', '1004', '1005', '1006', '1007', '1008', '1009', '1010', '1011', '1012', '1013', '1014', '1015', '1016', '1017', '1018', '1019', '1020', '1021', '1022', '1023', '1024', '1025', '1026', '1027', '1028', '1029', '1030', '1031', '1032', '1033', '1034', '1035', '1036', '1037', '1038', '1039', '1040', '1041', '1042', '1043', '1044', '1045', '1046', '1047', '1048', '1049', '1050', '1051', '1052', '1053', '1054', '1055', '1056', '1057', '1058', '1059', '1060', '1061', '1062', '1063', '1064', '1065', '1066', '1067', '1068', '1069', '1070', '1071', '1072', '1073', '1074', '1075', '1076', '1077', '1078', '1079', '1080', '1081', '1082', '1083', '1084', '1085', '1086', '1087', '1088', '1089', '1090', '1091', '1092', '1093', '1094', '1095', '1096', '1097', '1098', '1099', '1100', '1101', '1102', '1103', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023', '2024', '2025', '2026', '2027', '2028', '2029', '2030', '2031', '2032', '2033', '2034', '2035', '2036', '2037', '2038', '2039', '2040', '2041', '2042', '2043', '2044', '2045', '2046', '2047', '2048', '2049', '2050', '2051', '2052', '2053', '2054', '2055', '2056', '2057', '2058', '2059', '2060', '2061', '2062', '2063', '2064', '2065', '2066', '2067', '2068', '2069', '2070', '2071', '2072', '2073', '2074', '2075', '2076', '2077', '2078', '2079', '2080', '2081', '2082', '2083', '2084', '2085', '2086', '2087', '2088', '2089', '2090', '2091', '2092', '2093', '2094', '2095', '2096', '3001', '3002', '3003', '3004', '3005', '3006', '3007', '3008', '3009', '3010', '3011', '3012', '3013', '3014', '3015', '3016', '3017', '3018', '3019', '3020', '3021', '3022', '3023', '3024', '3025', '3026', '3027', '3028', '3029', '3030', '3031', '3032', '3033', '3034', '3035', '3036', '3037', '3038', '3039', '3040', '3041', '3042', '3043', '3044', '3045', '3046', '3047', '3048', '3049', '3050', '3051', '3052', '3053', '3054', '3055', '3056', '3057', '3058', '3059', '3060', '3061', '3062', '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', '113', '114', '115', '116', '117', '118', '119', '120', '121', '122', '5410', '5491', '5510', '5511', '5512', '5543', '5546', '5547', '5548', '5549', '5550', '5551', '5552', '5656', '5685', '5798', '6406', '6525', '7728812653'], -imgRandom:function (){ -var img=document.getElementsByTagName("img")[0]; -var b=Math.random()*10000; -b=Math.floor(b)%(this.aImg.length); -img.src="https://nodejs.wikimoe.com:667/card/0/"+this.aImg[b]+".jpg"; -} -}; -</script> <body> -<h1>您抽到了:</h1><hr> -<img src="" onerror="o.imgRandom();"> -</body></html> diff --git a/index.html b/index.html index 718494e..22851e6 100644 --- a/index.html +++ b/index.html @@ -58,7 +58,7 @@ title: 首页 - 我的文章 <a href="{% unless site.github %}https://mabbs.github.io{% endunless %}/pixiv-index/">Pixiv图片索引API</a><br> - <a href="/card.html">抽卡</a> - 由<a href="https://github.com/eeg1412/">广树</a>大佬提供卡牌<br> + <a href="/card.html">Cloudflare LLaMA 2</a><br> <a href="/message.html">留言板</a><br> diff --git a/js/main.js b/js/main.js index 329b132..c14a457 100644 --- a/js/main.js +++ b/js/main.js @@ -54,4 +54,4 @@ if (daysold > 90) { } var message_Path = '/Live2dHistoire/live2d/'; -var talkAPI = auxiliaryHost+"/talk.php"; +var talkAPI = "https://turing-api.mayx.eu.org/"; diff --git a/llama.html b/llama.html new file mode 100644 index 0000000..f3e5a69 --- /dev/null +++ b/llama.html @@ -0,0 +1,385 @@ +<!DOCTYPE html> +<html> + +<head> + <title>Cloudflare AI</title> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="icon" + href="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Ctext%20x='0'%20y='14'%20style='filter:%20invert(100%);'%3E☁️%3C/text%3E%3C/svg%3E" + type="image/svg+xml" /> + <style> + body { + font-family: 'Raleway', sans-serif; + margin: 0; + padding: 20px; + background-color: #222; + color: #fff; + backdrop-filter: blur(10px); + overflow: hidden; + height: 100vh; + } + + + h1 { + text-align: center; + font-weight: 900; + text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); + font-size: 64px; + } + + h2 { + text-align: center; + font-weight: bold; + text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); + font-size: 20px; + } + + form { + margin-bottom: 20px; + display: flex; + justify-content: center; + /* Center items horizontally */ + align-items: center; + /* Center items vertically */ + position: fixed; + bottom: 12px; + width: 100vw; + border-radius: 10px; + padding: 10px; + /* Add some padding to give space around the items */ + } + + label { + font-weight: bold; + color: #ccc; + } + + input[type="text"] { + width: 50%; + padding: 10px; + background-color: rgba(0, 0, 0, 0.3); + color: #fff; + border: none; + border-radius: 5px; + } + + textarea { + width: 50%; + padding: 9px; + color: whitesmoke; + + border: none; + border-radius: 5px; + font-size: 18px; + background-color: #222222; + + } + + textarea::-webkit-scrollbar { + display: none; + } + + textarea:focus { + outline: none; + } + + + #response { + max-width: 80%; + height: calc(100% - 250px); + margin-left: 10%; + overflow-y: scroll; + } + + #response::-webkit-scrollbar { + width: 10px; + border-radius: 50%; + } + + + .user-message { + background-color: rgba(71, 71, 71, 0.3); + padding: 10px; + margin-bottom: 10px; + margin-left: 40%; + max-width: 60%; + border-radius: 10px; + box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37); + backdrop-filter: blur(4px); + -webkit-backdrop-filter: blur(4px); + border-radius: 10px; + border: 1px solid rgba(255, 255, 255, 0.18); + color: whitesmoke; + } + + .ai-message { + background-color: rgba(71, 71, 71, 0.3); + padding: 10px; + margin-bottom: 10px; + margin-right: 40%; + max-width: 60%; + border-radius: 10px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); + color: whitesmoke; + } + + p { + margin: 0; + padding: 0; + } + + .smaller { + font-size: 15; + } + + .fa-github { + text-decoration: none; + color: inherit; + position: fixed; + bottom: 0; + right: 0; + padding: 15px; + } + + .dropbtn { + background-color: #191b1c; + color: white; + padding: 16px; + font-size: 16px; + border: none; + cursor: pointer; + } + + .dropdown { + position: relative; + display: inline-block; + position: absolute; + top: 5px; + left: 5px; + padding: 10px; + color: #fff; + border: none; + border-radius: 5px; + cursor: pointer; + } + + .dropdown-content { + display: none; + position: absolute; + background-color: #191b1c; + min-width: 160px; + box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); + z-index: 1; + } + + .dropdown-content a { + color: #fff; + padding: 12px 16px; + text-decoration: none; + display: block; + } + + .dropdown-content a:hover { + background-color: black + } + + .dropdown:hover .dropdown-content { + display: block; + } + + .dropdown:hover .dropbtn { + background-color: #444; + } + + button { + font-size: 18px; + color: #e1e1e1; + font-family: inherit; + font-weight: 800; + cursor: pointer; + position: relative; + border: none; + background: none; + text-transform: uppercase; + transition-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1); + transition-duration: 400ms; + transition-property: color; + } + + button:focus, + button:hover { + color: #fff; + } + + button:focus:after, + button:hover:after { + width: 100%; + left: 0%; + } + + button:after { + content: ""; + pointer-events: none; + bottom: -2px; + left: 50%; + position: absolute; + width: 0%; + height: 2px; + background-color: #fff; + transition-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1); + transition-duration: 400ms; + transition-property: width, left; + } + + .github-icon { + position: fixed; + right: 50px; + bottom: 50px; + } + + /* if screen width<1000 then max -width=100% */ + @media screen and (max-width: 1000px) { + #response { + max-width: 100%; + margin-left: 0; + height: calc(100% - 280px); + } + + textarea { + width: 80%; + } + + .github-icon { + visibility: hidden; + } + + form { + bottom: 0; + } + + .ai-message { + max-width: 80%; + min-width: 80%; + } + } + </style> + <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> + <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> + <link rel="preconnect" href="https://fonts.googleapis.com"> + <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> + <link href="https://fonts.googleapis.com/css2?family=Raleway:wght@700&display=swap" rel="stylesheet"> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> +</head> + +<body> + <h1>Cloudflare AI</h1> + <div class="dropdown"> + <button class="dropbtn">Settings</button> + <div class="dropdown-content"> + <a href="#" onclick='setApiUrl()'>Custom API URL</a> + <a href="#" onclick='setIDsession()'>Custom ID Session</a> + </div> + </div> + <div id="response"> + <div class="ai-message">Hey there, how can i assist you?</div> + </div> + <form id="chatForm"> + <textarea id="input" type="text" placeholder="Send a message"></textarea> + <button type="submit">➤</button> + </form> + <a class="fa fa-github github-icon" href="https://github.com/localuser-isback/Cloudflare-AI" style="font-size:36px"> + <script> + + // --------------- CONFIG --------------- // + // modify URL to your API + let apiUrl = "https://llama.mayx.eu.org" + + // ----------- END OF CONFIG ------------ // + let uuid = ''; + + function setApiUrl() { + const customUrl = prompt("Enter custom API URL: "); + if (customUrl) { + apiUrl = customUrl; + } + } + + function setIDsession() { + const customUUID = prompt("Enter custom session ID: "); + if (customUUID) { + uuid = customUUID; + } + } + + function generateUUID() { + let newUUID = ''; + const chars = 'abcdef0123456789'; + for (let i = 0; i < 32; i++) { + const charIndex = Math.floor(Math.random() * chars.length); + newUUID += chars[charIndex]; + if (i === 7 || i === 11 || i === 15 || i === 19) { + newUUID += '-'; + } + } + return newUUID; + } + const chatForm = document.getElementById('chatForm'); + const inputField = document.getElementById('input'); + const responseDiv = document.getElementById('response'); + + function chat() { + var input = inputField.value; + input = encodeURIComponent(input) + + const userMessageDiv = document.createElement('div'); + userMessageDiv.className = 'user-message'; + userMessageDiv.innerText = decodeURIComponent(input); + responseDiv.appendChild(userMessageDiv); + + const loadingDiv = document.createElement('div'); + loadingDiv.className = 'loading'; + loadingDiv.innerHTML = `<svg width="30" height="30" viewBox="0 0 50 50"><circle cx="25" cy="25" r="20" stroke="black" stroke-width="4" fill="none" /><circle cx="25" cy="25" r="20" stroke="#3498db" stroke-width="4" fill="none" stroke-dasharray="90" stroke-dashoffset="0"><animateTransform attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="1s" repeatCount="indefinite"/></circle></svg><center class="smaller">If you recive an error than wait 1-2 minutes refresh and try again.</center>`; + responseDiv.appendChild(loadingDiv); + + axios.get(`${apiUrl}/${uuid}?q=${encodeURIComponent(input)}`) + .then((response) => { + responseDiv.removeChild(loadingDiv); + + const aiMessages = response.data[0].response.filter(message => message.role === 'system' && message.content.response); + if (aiMessages.length > 0) { + const lastAiMessage = aiMessages[aiMessages.length - 1]; + const aiMessageDiv = document.createElement('div'); + aiMessageDiv.className = 'ai-message'; + aiMessageDiv.innerHTML = marked.parse(lastAiMessage.content.response); + responseDiv.appendChild(aiMessageDiv); + } + + inputField.value = ''; + }) + .catch((error) => { + console.log("Error receiving response:", error); + }); + } + + chatForm.addEventListener('submit', (event) => { + event.preventDefault(); + chat() + }); + + inputField.addEventListener('keydown', (event) => { + if (event.key === 'Enter') { + if (!event.shiftKey) { + event.preventDefault(); + chat() + } + } + }); + + if (!uuid) { + uuid = generateUUID(); + } + </script> +</body> + +</html> \ No newline at end of file |