Update index.html
Browse files- index.html +46 -43
index.html
CHANGED
|
@@ -6,13 +6,13 @@
|
|
| 6 |
<title>Benim YZ Asistanım</title>
|
| 7 |
<style>
|
| 8 |
body {
|
| 9 |
-
font-family:
|
| 10 |
background-color: #0f172a;
|
| 11 |
color: #f8fafc;
|
| 12 |
display: flex;
|
| 13 |
justify-content: center;
|
| 14 |
align-items: center;
|
| 15 |
-
height: 100vh;
|
| 16 |
margin: 0;
|
| 17 |
}
|
| 18 |
.card {
|
|
@@ -21,7 +21,7 @@
|
|
| 21 |
border-radius: 12px;
|
| 22 |
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
|
| 23 |
max-width: 500px;
|
| 24 |
-
width:
|
| 25 |
text-align: center;
|
| 26 |
}
|
| 27 |
h1 {
|
|
@@ -31,7 +31,7 @@
|
|
| 31 |
textarea {
|
| 32 |
width: 100%;
|
| 33 |
height: 100px;
|
| 34 |
-
padding:
|
| 35 |
border-radius: 8px;
|
| 36 |
border: 1px solid #334155;
|
| 37 |
background-color: #0f172a;
|
|
@@ -49,12 +49,17 @@
|
|
| 49 |
border: none;
|
| 50 |
border-radius: 8px;
|
| 51 |
font-size: 16px;
|
|
|
|
| 52 |
cursor: pointer;
|
| 53 |
transition: background 0.3s;
|
| 54 |
}
|
| 55 |
button:hover {
|
| 56 |
background-color: #0369a1;
|
| 57 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
.response {
|
| 59 |
margin-top: 20px;
|
| 60 |
padding: 15px;
|
|
@@ -64,61 +69,59 @@
|
|
| 64 |
min-height: 50px;
|
| 65 |
white-space: pre-wrap;
|
| 66 |
border: 1px solid #334155;
|
|
|
|
|
|
|
| 67 |
}
|
| 68 |
</style>
|
| 69 |
-
<!-- Hugging Face JS Kütüphanesi -->
|
| 70 |
-
<script type="module">
|
| 71 |
-
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.6.0';
|
| 72 |
-
window.pipeline = pipeline;
|
| 73 |
-
</script>
|
| 74 |
</head>
|
| 75 |
<body>
|
| 76 |
|
| 77 |
<div class="card">
|
| 78 |
<h1>🤖 Yapay Zeka Asistanı</h1>
|
| 79 |
-
<p>Sorunuzu yazın, yapay zeka
|
| 80 |
-
<textarea id="userInput" placeholder="
|
| 81 |
<button id="btn" onclick="askAI()">Yapay Zekaya Sor</button>
|
| 82 |
<div class="response" id="output">Yanıt burada görünecek...</div>
|
| 83 |
</div>
|
| 84 |
|
| 85 |
-
<script>
|
| 86 |
-
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
output.innerText = "Lütfen bir soru girin!";
|
| 95 |
-
return;
|
| 96 |
-
}
|
| 97 |
-
|
| 98 |
-
try {
|
| 99 |
-
btn.disabled = true;
|
| 100 |
|
| 101 |
-
if (!
|
| 102 |
-
output.innerText = "
|
| 103 |
-
|
| 104 |
}
|
| 105 |
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
}
|
| 121 |
-
}
|
| 122 |
</script>
|
| 123 |
|
| 124 |
</body>
|
|
|
|
| 6 |
<title>Benim YZ Asistanım</title>
|
| 7 |
<style>
|
| 8 |
body {
|
| 9 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 10 |
background-color: #0f172a;
|
| 11 |
color: #f8fafc;
|
| 12 |
display: flex;
|
| 13 |
justify-content: center;
|
| 14 |
align-items: center;
|
| 15 |
+
min-height: 100vh;
|
| 16 |
margin: 0;
|
| 17 |
}
|
| 18 |
.card {
|
|
|
|
| 21 |
border-radius: 12px;
|
| 22 |
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
|
| 23 |
max-width: 500px;
|
| 24 |
+
width: 90%;
|
| 25 |
text-align: center;
|
| 26 |
}
|
| 27 |
h1 {
|
|
|
|
| 31 |
textarea {
|
| 32 |
width: 100%;
|
| 33 |
height: 100px;
|
| 34 |
+
padding: 12px;
|
| 35 |
border-radius: 8px;
|
| 36 |
border: 1px solid #334155;
|
| 37 |
background-color: #0f172a;
|
|
|
|
| 49 |
border: none;
|
| 50 |
border-radius: 8px;
|
| 51 |
font-size: 16px;
|
| 52 |
+
font-weight: bold;
|
| 53 |
cursor: pointer;
|
| 54 |
transition: background 0.3s;
|
| 55 |
}
|
| 56 |
button:hover {
|
| 57 |
background-color: #0369a1;
|
| 58 |
}
|
| 59 |
+
button:disabled {
|
| 60 |
+
background-color: #475569;
|
| 61 |
+
cursor: not-allowed;
|
| 62 |
+
}
|
| 63 |
.response {
|
| 64 |
margin-top: 20px;
|
| 65 |
padding: 15px;
|
|
|
|
| 69 |
min-height: 50px;
|
| 70 |
white-space: pre-wrap;
|
| 71 |
border: 1px solid #334155;
|
| 72 |
+
font-size: 14px;
|
| 73 |
+
line-height: 1.5;
|
| 74 |
}
|
| 75 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
</head>
|
| 77 |
<body>
|
| 78 |
|
| 79 |
<div class="card">
|
| 80 |
<h1>🤖 Yapay Zeka Asistanı</h1>
|
| 81 |
+
<p>Sorunuzu veya cümlenizi yazın, yapay zeka tamamlasın:</p>
|
| 82 |
+
<textarea id="userInput" placeholder="Bir şeyler yazın..."></textarea>
|
| 83 |
<button id="btn" onclick="askAI()">Yapay Zekaya Sor</button>
|
| 84 |
<div class="response" id="output">Yanıt burada görünecek...</div>
|
| 85 |
</div>
|
| 86 |
|
| 87 |
+
<script type="module">
|
| 88 |
+
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.14.0';
|
| 89 |
|
| 90 |
+
let generator = null;
|
| 91 |
+
|
| 92 |
+
window.askAI = async function() {
|
| 93 |
+
const prompt = document.getElementById('userInput').value;
|
| 94 |
+
const output = document.getElementById('output');
|
| 95 |
+
const btn = document.getElementById('btn');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
+
if (!prompt.trim()) {
|
| 98 |
+
output.innerText = "Lütfen bir metin girin!";
|
| 99 |
+
return;
|
| 100 |
}
|
| 101 |
|
| 102 |
+
try {
|
| 103 |
+
btn.disabled = true;
|
| 104 |
+
|
| 105 |
+
if (!generator) {
|
| 106 |
+
output.innerText = "Model indiriliyor (Bu işlem ilk seferde birkaç saniye sürebilir)...";
|
| 107 |
+
generator = await pipeline('text-generation', 'Xenova/gpt2');
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
output.innerText = "Yapay zeka yanıt üretiyor...";
|
| 111 |
+
|
| 112 |
+
const result = await generator(prompt, {
|
| 113 |
+
max_new_tokens: 50,
|
| 114 |
+
temperature: 0.7
|
| 115 |
+
});
|
| 116 |
+
|
| 117 |
+
output.innerText = result[0].generated_text;
|
| 118 |
+
|
| 119 |
+
} catch (error) {
|
| 120 |
+
output.innerText = "Hata oluştu: " + error.message;
|
| 121 |
+
} finally {
|
| 122 |
+
btn.disabled = false;
|
| 123 |
+
}
|
| 124 |
}
|
|
|
|
| 125 |
</script>
|
| 126 |
|
| 127 |
</body>
|