Update index.html
Browse files- index.html +16 -226
index.html
CHANGED
|
@@ -1,229 +1,27 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html lang="
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<
|
| 6 |
-
<title>شات عارف - معهد مدينة العلوم العصرية</title>
|
| 7 |
-
|
| 8 |
-
<style>
|
| 9 |
-
body {
|
| 10 |
-
font-family: 'Cairo', Arial, sans-serif;
|
| 11 |
-
background: #f6fafc;
|
| 12 |
-
min-height: 100vh;
|
| 13 |
-
display: flex;
|
| 14 |
-
align-items: center;
|
| 15 |
-
justify-content: center;
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
.chat-container {
|
| 19 |
-
background: #fff;
|
| 20 |
-
border-radius: 30px;
|
| 21 |
-
box-shadow: 0 10px 35px rgba(60,180,90,0.12);
|
| 22 |
-
width: 98%;
|
| 23 |
-
max-width: 500px;
|
| 24 |
-
height: 92vh;
|
| 25 |
-
display: flex;
|
| 26 |
-
flex-direction: column;
|
| 27 |
-
overflow: hidden;
|
| 28 |
-
border: 2px solid #e6f6ed;
|
| 29 |
-
position: relative;
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
.header {
|
| 33 |
-
padding: 25px 10px;
|
| 34 |
-
text-align: center;
|
| 35 |
-
border-bottom: 2px solid #e6f6ed;
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
.logo {
|
| 39 |
-
width: 90px;
|
| 40 |
-
height: 90px;
|
| 41 |
-
border-radius: 20px;
|
| 42 |
-
margin-bottom: 10px;
|
| 43 |
-
border: 3px solid #77eeaa;
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
.header h1 {
|
| 47 |
-
color: #27ae60;
|
| 48 |
-
font-size: 30px;
|
| 49 |
-
margin: 5px 0;
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
.header p {
|
| 53 |
-
color: #555;
|
| 54 |
-
font-size: 15px;
|
| 55 |
-
}
|
| 56 |
-
|
| 57 |
-
.chat-messages {
|
| 58 |
-
flex: 1;
|
| 59 |
-
padding: 15px;
|
| 60 |
-
overflow-y: auto;
|
| 61 |
-
background: #f8fefb;
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
.message {
|
| 65 |
-
margin-bottom: 15px;
|
| 66 |
-
display: flex;
|
| 67 |
-
align-items: flex-end;
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
.message.user {
|
| 71 |
-
flex-direction: row-reverse;
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
.bot-avatar {
|
| 75 |
-
width: 34px;
|
| 76 |
-
height: 34px;
|
| 77 |
-
border-radius: 50%;
|
| 78 |
-
margin: 0 8px;
|
| 79 |
-
border: 2px solid #7affb8;
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
.message-content {
|
| 83 |
-
max-width: 75%;
|
| 84 |
-
padding: 14px 18px;
|
| 85 |
-
border-radius: 20px;
|
| 86 |
-
font-size: 16px;
|
| 87 |
-
line-height: 1.6;
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
.message.bot .message-content {
|
| 91 |
-
background: #f0fff7;
|
| 92 |
-
color: #29482d;
|
| 93 |
-
border-bottom-left-radius: 5px;
|
| 94 |
-
}
|
| 95 |
-
|
| 96 |
-
.message.user .message-content {
|
| 97 |
-
background: linear-gradient(135deg, #27ae60, #86e5a8);
|
| 98 |
-
color: #fff;
|
| 99 |
-
border-bottom-right-radius: 5px;
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
.input-container {
|
| 103 |
-
padding: 12px;
|
| 104 |
-
border-top: 2px solid #e6f6ed;
|
| 105 |
-
display: flex;
|
| 106 |
-
gap: 8px;
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
.message-input {
|
| 110 |
-
flex: 1;
|
| 111 |
-
padding: 12px 15px;
|
| 112 |
-
border-radius: 18px;
|
| 113 |
-
border: 2px solid #d1f5e0;
|
| 114 |
-
font-size: 15px;
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
.send-button {
|
| 118 |
-
background: linear-gradient(135deg, #27ae60, #86e5a8);
|
| 119 |
-
border: none;
|
| 120 |
-
color: #fff;
|
| 121 |
-
padding: 12px 18px;
|
| 122 |
-
border-radius: 18px;
|
| 123 |
-
cursor: pointer;
|
| 124 |
-
font-weight: bold;
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
-
.send-button:disabled {
|
| 128 |
-
opacity: 0.6;
|
| 129 |
-
}
|
| 130 |
-
|
| 131 |
-
.clear-btn {
|
| 132 |
-
position: absolute;
|
| 133 |
-
top: 10px;
|
| 134 |
-
left: 10px;
|
| 135 |
-
background: #fff;
|
| 136 |
-
border: 1px solid #eee;
|
| 137 |
-
color: #27ae60;
|
| 138 |
-
padding: 6px 12px;
|
| 139 |
-
border-radius: 14px;
|
| 140 |
-
cursor: pointer;
|
| 141 |
-
}
|
| 142 |
-
</style>
|
| 143 |
</head>
|
| 144 |
-
|
| 145 |
<body>
|
| 146 |
|
| 147 |
-
<
|
| 148 |
-
<button class="clear-btn" onclick="clearChat()">مسح</button>
|
| 149 |
|
| 150 |
-
|
| 151 |
-
<img src="https://ufastpro.com/wp-content/uploads/2025/04/476234917_1002033431973236_2935522081755714863_n.jpg" class="logo">
|
| 152 |
-
<h1>عارف</h1>
|
| 153 |
-
<p>مساعدك الذكي لمعهد مدينة العلوم العصرية</p>
|
| 154 |
-
</div>
|
| 155 |
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
<div class="input-container">
|
| 159 |
-
<input id="messageInput" class="message-input" placeholder="اكتب سؤالك..." onkeypress="if(event.key==='Enter') sendMessage()">
|
| 160 |
-
<button id="sendButton" class="send-button" onclick="sendMessage()">إرسال</button>
|
| 161 |
-
</div>
|
| 162 |
-
</div>
|
| 163 |
|
| 164 |
<script>
|
| 165 |
const API_URL = "https://api.deepseek.com/chat/completions";
|
| 166 |
const API_KEY = "sk-6080b89d5cb844c29ad10158144e45eb";
|
| 167 |
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
`;
|
| 172 |
-
|
| 173 |
-
let conversationHistory = [];
|
| 174 |
-
const STORAGE_KEY = "chat_arif_mscieg";
|
| 175 |
-
|
| 176 |
-
window.onload = () => {
|
| 177 |
-
const saved = localStorage.getItem(STORAGE_KEY);
|
| 178 |
-
if (saved) {
|
| 179 |
-
conversationHistory = JSON.parse(saved);
|
| 180 |
-
conversationHistory.forEach(m => addMessage(m.content, m.role === "user"));
|
| 181 |
-
}
|
| 182 |
-
};
|
| 183 |
-
|
| 184 |
-
function saveHistory() {
|
| 185 |
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(conversationHistory));
|
| 186 |
-
}
|
| 187 |
-
|
| 188 |
-
function clearChat() {
|
| 189 |
-
localStorage.removeItem(STORAGE_KEY);
|
| 190 |
-
location.reload();
|
| 191 |
-
}
|
| 192 |
-
|
| 193 |
-
function addMessage(text, isUser) {
|
| 194 |
-
const chat = document.getElementById("chatMessages");
|
| 195 |
-
|
| 196 |
-
const div = document.createElement("div");
|
| 197 |
-
div.className = "message " + (isUser ? "user" : "bot");
|
| 198 |
-
|
| 199 |
-
if (isUser) {
|
| 200 |
-
div.innerHTML = `<div class="message-content">${text}</div>`;
|
| 201 |
-
} else {
|
| 202 |
-
div.innerHTML = `
|
| 203 |
-
<img class="bot-avatar" src="https://ufastpro.com/wp-content/uploads/2025/04/476234917_1002033431973236_2935522081755714863_n.jpg">
|
| 204 |
-
<div class="message-content">${text}</div>
|
| 205 |
-
`;
|
| 206 |
-
}
|
| 207 |
-
|
| 208 |
-
chat.appendChild(div);
|
| 209 |
-
chat.scrollTop = chat.scrollHeight;
|
| 210 |
-
}
|
| 211 |
-
|
| 212 |
-
async function sendMessage() {
|
| 213 |
-
const input = document.getElementById("messageInput");
|
| 214 |
-
const btn = document.getElementById("sendButton");
|
| 215 |
-
const text = input.value.trim();
|
| 216 |
-
if (!text) return;
|
| 217 |
-
|
| 218 |
-
addMessage(text, true);
|
| 219 |
-
conversationHistory.push({ role: "user", content: text });
|
| 220 |
-
saveHistory();
|
| 221 |
-
|
| 222 |
-
input.value = "";
|
| 223 |
-
btn.disabled = true;
|
| 224 |
|
| 225 |
try {
|
| 226 |
-
const
|
| 227 |
method: "POST",
|
| 228 |
headers: {
|
| 229 |
"Content-Type": "application/json",
|
|
@@ -232,27 +30,19 @@ async function sendMessage() {
|
|
| 232 |
body: JSON.stringify({
|
| 233 |
model: "deepseek-chat",
|
| 234 |
messages: [
|
| 235 |
-
{ role: "system", content:
|
| 236 |
-
|
| 237 |
],
|
| 238 |
-
|
| 239 |
-
max_tokens: 1000
|
| 240 |
})
|
| 241 |
});
|
| 242 |
|
| 243 |
-
const data = await
|
| 244 |
-
|
| 245 |
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
saveHistory();
|
| 249 |
-
|
| 250 |
-
} catch (e) {
|
| 251 |
-
addMessage("حصلت مشكلة في الاتصال 😅", false);
|
| 252 |
}
|
| 253 |
-
|
| 254 |
-
btn.disabled = false;
|
| 255 |
-
input.focus();
|
| 256 |
}
|
| 257 |
</script>
|
| 258 |
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<title>DeepSeek Test</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
</head>
|
|
|
|
| 7 |
<body>
|
| 8 |
|
| 9 |
+
<h2>DeepSeek Chat Test</h2>
|
|
|
|
| 10 |
|
| 11 |
+
<button onclick="send()">Send Request</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
<pre id="output"></pre>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
<script>
|
| 16 |
const API_URL = "https://api.deepseek.com/chat/completions";
|
| 17 |
const API_KEY = "sk-6080b89d5cb844c29ad10158144e45eb";
|
| 18 |
|
| 19 |
+
async function send() {
|
| 20 |
+
const output = document.getElementById("output");
|
| 21 |
+
output.textContent = "Loading...";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
try {
|
| 24 |
+
const response = await fetch(API_URL, {
|
| 25 |
method: "POST",
|
| 26 |
headers: {
|
| 27 |
"Content-Type": "application/json",
|
|
|
|
| 30 |
body: JSON.stringify({
|
| 31 |
model: "deepseek-chat",
|
| 32 |
messages: [
|
| 33 |
+
{ role: "system", content: "You are a helpful assistant." },
|
| 34 |
+
{ role: "user", content: "Hello!" }
|
| 35 |
],
|
| 36 |
+
stream: false
|
|
|
|
| 37 |
})
|
| 38 |
});
|
| 39 |
|
| 40 |
+
const data = await response.json();
|
| 41 |
+
output.textContent = data.choices[0].message.content;
|
| 42 |
|
| 43 |
+
} catch (err) {
|
| 44 |
+
output.textContent = "Error: " + err.message;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
}
|
|
|
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
</script>
|
| 48 |
|