File size: 3,780 Bytes
cb86ca2
 
 
 
 
 
 
 
f682bb8
cb86ca2
 
 
 
 
f682bb8
cb86ca2
 
 
 
 
 
 
 
f682bb8
cb86ca2
 
 
 
 
 
 
 
 
f682bb8
cb86ca2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f682bb8
cb86ca2
 
 
 
 
 
f682bb8
 
 
 
cb86ca2
 
 
 
 
 
 
 
 
f682bb8
 
cb86ca2
 
 
 
 
 
 
c806237
b0b319e
c806237
cb86ca2
 
 
f682bb8
 
868c795
c806237
f682bb8
 
 
 
 
cb86ca2
f682bb8
c806237
f682bb8
cb86ca2
868c795
f682bb8
 
 
c806237
 
 
 
f682bb8
 
c806237
f682bb8
c806237
 
f682bb8
 
 
 
 
 
 
 
 
cb86ca2
 
 
 
 
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
123
124
125
126
127
128
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Benim YZ Asistanım</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #0f172a;
            color: #f8fafc;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            margin: 0;
        }
        .card {
            background-color: #1e293b;
            padding: 30px;
            border-radius: 12px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
            max-width: 500px;
            width: 90%;
            text-align: center;
        }
        h1 {
            color: #38bdf8;
            margin-bottom: 20px;
        }
        textarea {
            width: 100%;
            height: 100px;
            padding: 12px;
            border-radius: 8px;
            border: 1px solid #334155;
            background-color: #0f172a;
            color: #fff;
            resize: none;
            box-sizing: border-box;
            font-size: 14px;
        }
        button {
            margin-top: 15px;
            width: 100%;
            padding: 12px;
            background-color: #0284c7;
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: background 0.3s;
        }
        button:hover {
            background-color: #0369a1;
        }
        button:disabled {
            background-color: #475569;
            cursor: not-allowed;
        }
        .response {
            margin-top: 20px;
            padding: 15px;
            background-color: #0f172a;
            border-radius: 8px;
            text-align: left;
            min-height: 50px;
            white-space: pre-wrap;
            border: 1px solid #334155;
            font-size: 14px;
            line-height: 1.5;
        }
    </style>
</head>
<body>

<div class="card">
    <h1>🤖 Yapay Zeka Asistanı</h1>
    <p>Sohbet etmek için bir şeyler yazın:</p>
    <textarea id="userInput" placeholder="Örn: Merhaba, nasılsın?"></textarea>
    <button id="btn" onclick="askAI()">Gönder</button>
    <div class="response" id="output">Yanıt burada görünecek...</div>
</div>

<script type="module">
    import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.14.0';

    let summarizer = null;

    window.askAI = async function() {
        const prompt = document.getElementById('userInput').value;
        const output = document.getElementById('output');
        const btn = document.getElementById('btn');
        
        if (!prompt.trim()) {
            output.innerText = "Lütfen bir şeyler yazın!";
            return;
        }
        
        try {
            btn.disabled = true;
            
            if (!summarizer) {
                output.innerText = "Yapay zeka modeli hazırlanıyor, ilk açılışta biraz sürebilir...";
                // Türkçe destekli ve daha kararlı bir model seçiyoruz
                summarizer = await pipeline('text2text-generation', 'Xenova/flan-t5-small');
            }
            
            output.innerText = "Cevap yazılıyor...";
            
            const result = await summarizer(prompt, { 
                max_new_tokens: 100
            });
            
            output.innerText = result[0].generated_text;
            
        } catch (error) {
            output.innerText = "Hata oluştu: " + error.message;
        } finally {
            btn.disabled = false;
        }
    }
</script>

</body>
</html>