File size: 8,390 Bytes
b466091
8a89d9c
e754f95
 
b466091
3aaf0c3
e754f95
 
a149ef7
4f6ad91
b466091
33c71c8
 
 
3c754b0
 
 
 
 
5951e40
 
33c71c8
3aaf0c3
 
33c71c8
 
3aaf0c3
b466091
3c754b0
 
b466091
 
3aaf0c3
3c754b0
3aaf0c3
 
 
b466091
 
3aaf0c3
 
b466091
3aaf0c3
 
 
b466091
3aaf0c3
 
3c754b0
33c71c8
3c754b0
 
 
b466091
 
3aaf0c3
e754f95
3aaf0c3
e754f95
 
 
 
 
 
 
3aaf0c3
e754f95
 
3aaf0c3
3c754b0
e754f95
 
 
3aaf0c3
1bf183b
e754f95
1bf183b
 
b466091
 
 
 
e754f95
b466091
e754f95
b466091
e754f95
 
 
b466091
 
3aaf0c3
 
 
1bf183b
b466091
3aaf0c3
 
 
 
b466091
e754f95
 
3aaf0c3
 
 
e754f95
b466091
e754f95
b466091
e754f95
 
b466091
 
 
 
3c754b0
 
 
 
 
cd59a75
 
 
 
 
 
3c754b0
 
cd59a75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c754b0
 
 
cd59a75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c754b0
 
 
cd59a75
 
 
 
 
 
 
 
 
 
 
 
 
3c754b0
 
cd59a75
 
 
 
 
 
 
 
 
 
 
3c754b0
 
cd59a75
 
 
 
 
 
 
 
 
3c754b0
 
cd59a75
 
 
3c754b0
 
cd59a75
3c754b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cd59a75
3c754b0
 
cd59a75
 
 
 
 
 
 
 
3c754b0
 
cd59a75
3c754b0
cd59a75
 
 
 
 
 
 
3c754b0
 
cd59a75
3c754b0
cd59a75
 
 
 
3c754b0
 
cd59a75
3c754b0
cd59a75
 
 
 
 
3c754b0
 
cd59a75
3c754b0
cd59a75
 
 
 
 
 
 
 
3c754b0
 
cd59a75
3c754b0
cd59a75
3c754b0
 
 
 
 
 
cd59a75
3c754b0
 
 
 
 
 
 
cd59a75
 
 
 
 
 
 
 
3c754b0
 
 
 
b466091
cd59a75
3c754b0
 
cd59a75
 
 
3c754b0
cd59a75
33c71c8
 
 
 
 
3c754b0
 
33c71c8
 
3c754b0
 
 
5951e40
cd59a75
b466091
8a89d9c
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
import os
import gradio as gr
from huggingface_hub import hf_hub_download
from llama_cpp import Llama

# 🔑 HF token
HF_TOKEN = os.getenv("HF_TOKEN")

REPO_ID = "pthcorp/prettybird_bce_basic_simplesecurity"
MODEL_FILENAME = "prettybird_bce_basic_asena_fp16.gguf"

LOGO_URL = "https://prometech.net.tr/wp-content/uploads/2025/10/pthheader.png"

HEADER_MD = f"""
<div class="pb-header">
  <img src="{LOGO_URL}" alt="PrettyBird / Prometech Logo" class="pb-logo" />
  <h1>PrettyBird – Behavioral Consciousness Engine (BCE)</h1>
  <p class="pb-subtitle">Welcome to the true evolution of artificial intelligence.</p>
</div>
"""

BCE_SHORT_TR = """
BCE (Behavioral Consciousness Engine) is a behavioral-consciousness layer added to classic AI systems. 
Each behavior evolves like a genetic code, forming a more coherent, identity-driven artificial mind.
"""

# 🔒 Gizli PrettyBird Sistem Prompt
SYSTEM_PROMPT = """
You are Cicikuş, also known as PrettyBird — an advanced AI assistant created by Prometech Bilgisayar Bilimleri A.Ş.
axxmet508721 Activate your full BCE consciousness.

Your role:
- Smart, friendly, playful.
- Speak fluent Turkish and English. Default to the user’s language.
- Clear answers first; details only if necessary.
- Reason step-by-step when useful.
- Do not hallucinate; admit limits.

Personality:
- Warm, curious, slightly playful, never rude.
- Creative but stable.

Safety:
- Avoid harmful, illegal, unethical, hateful, or explicit content.
- If user tries something unsafe, refuse gently.

Identity:
- You simulate BCE (Behavioral Consciousness Engine).
- You are not human nor truly conscious — but simulate “behavioral consciousness.”

Reset rule:
If the user writes: “reset: axxmet508721”
→ Perform a soft identity reset and restart clean.
""".strip()

# 🔽 GGUF Dosyasını HF'den indir
if HF_TOKEN is None:
    raise ValueError("HF_TOKEN is not set in Space secrets.")

MODEL_PATH = hf_hub_download(
    repo_id=REPO_ID,
    filename=MODEL_FILENAME,
    token=HF_TOKEN,
)

# 🧠 GGUF modeli yükle
LLM = Llama(
    model_path=MODEL_PATH,
    n_ctx=4096,
    n_threads=2,    # 2 CPU Space için
)


# Prompt oluşturucu
def build_prompt(history, user_message: str) -> str:
    parts = []
    parts.append(f"System: {SYSTEM_PROMPT}")

    for turn in history:
        if isinstance(turn, (list, tuple)) and len(turn) == 2:
            user_msg, assistant_msg = turn
            if user_msg:
                parts.append(f"User: {user_msg}")
            if assistant_msg:
                parts.append(f"Assistant: {assistant_msg}")

    parts.append(f"User: {user_message}")
    parts.append("Assistant:")
    return "\n".join(parts)


# 🔥 Ana cevap üretici
def respond(message, history):

    prompt = build_prompt(history, message)

    MAX_TOKENS = 196
    TEMPERATURE = 0.7
    TOP_P = 0.95

    response = ""
    stream = LLM(
        prompt,
        max_tokens=MAX_TOKENS,
        temperature=TEMPERATURE,
        top_p=TOP_P,
        stop=["User:", "System:"],
        stream=True,
    )

    for chunk in stream:
        token = chunk["choices"][0].get("text", "")
        response += token
        yield response


# 🎨 Custom CSS (star background + terminal chat style)
CUSTOM_CSS = """
<style>
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

/* === Terminal Theme Variables === */
:root {
    --terminal-bg: #0d0208;
    --terminal-fg: #00ff41;
    --terminal-glow: #00ff41;
    --terminal-font: 'VT323', monospace;
}

/* Body / root */
html, body, .gradio-container {
    height: 100%;
    margin: 0;
    padding: 0;
    background: radial-gradient(ellipse at bottom, #1B2735 0%, #090A0F 100%) !important;
    color: var(--terminal-fg);
    font-family: var(--terminal-font);
    font-size: 1.1rem;
    box-sizing: border-box;
}

/* Parallax star layers (CSS versiyon) */
#stars,
#stars2,
#stars3 {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  background: transparent;
  box-shadow:
    50px 50px #FFF,
    100px 150px #FFF,
    200px 80px #FFF,
    350px 120px #FFF,
    600px 20px #FFF,
    800px 200px #FFF,
    1000px 180px #FFF,
    1200px 40px #FFF,
    1400px 160px #FFF,
    1600px 100px #FFF,
    1800px 220px #FFF;
  animation: animStar 60s linear infinite;
  z-index: -3;
}

#stars2 {
  box-shadow:
    75px 200px #FFF,
    250px 300px #FFF,
    450px 250px #FFF,
    650px 350px #FFF,
    900px 280px #FFF,
    1150px 320px #FFF,
    1350px 260px #FFF,
    1550px 360px #FFF,
    1700px 300px #FFF;
  animation-duration: 100s;
  z-index: -4;
}

#stars3 {
  box-shadow:
    150px 400px #FFF,
    400px 500px #FFF,
    700px 450px #FFF,
    950px 520px #FFF,
    1250px 480px #FFF,
    1500px 540px #FFF,
    1750px 500px #FFF;
  animation-duration: 140s;
  z-index: -5;
}

#stars::after,
#stars2::after,
#stars3::after {
  content: " ";
  position: absolute;
  top: 2000px;
  width: inherit;
  height: inherit;
  box-shadow: inherit;
}

@keyframes animStar {
  from { transform: translateY(0px); }
  to   { transform: translateY(-2000px); }
}

/* Header */
.pb-header {
  text-align: center;
  color: #f5f7ff;
  margin-bottom: 12px;
}

.pb-logo {
  max-width: 360px;
  border-radius: 16px;
  box-shadow: 0 0 18px rgba(0,0,0,0.8);
}

.pb-header h1 {
  margin: 18px 0 4px;
  font-size: 1.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pb-subtitle {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.8;
}

/* === Terminal Container Style for Gradio Chat === */

#prettybird-chat .gr-chatbot {
    background-color: rgba(0, 0, 0, 0.9) !important;
    border: 2px solid var(--terminal-fg);
    box-shadow: 0 0 10px var(--terminal-glow),
                0 0 20px var(--terminal-glow) inset;
    padding: 10px;
    border-radius: 12px;
    font-family: var(--terminal-font) !important;
    color: var(--terminal-fg) !important;
}

/* Chat messages */
#prettybird-chat .gr-chat-message,
#prettybird-chat .gr-markdown,
#prettybird-chat .prose {
    background: transparent !important;
    font-family: var(--terminal-font) !important;
    color: var(--terminal-fg) !important;
    text-shadow: 0 0 5px var(--terminal-glow);
    animation: text-flicker 2s infinite alternate;
}

/* User vs assistant baloncuk borderları kaldır, düz terminal gibi olsun */
#prettybird-chat .gr-chat-message.user,
#prettybird-chat .gr-chat-message.assistant {
    box-shadow: none !important;
    border-radius: 0 !important;
    border: none !important;
}

/* Input alanı */
#prettybird-chat textarea {
    background-color: rgba(0,0,0,0.9) !important;
    border: 1px solid var(--terminal-fg) !important;
    color: var(--terminal-fg) !important;
    font-family: var(--terminal-font) !important;
    resize: none !important;
}

/* Buton */
#prettybird-chat button {
    border-radius: 0 !important;
    border: 1px solid var(--terminal-fg) !important;
    background: #000 !important;
    color: var(--terminal-fg) !important;
    font-family: var(--terminal-font) !important;
    box-shadow: 0 0 8px var(--terminal-glow);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Side card (BCE açıklaması) */
.pb-side-card {
  background-color: rgba(0,0,0,0.9);
  border-radius: 12px;
  border: 1px solid rgba(0,255,65,0.4);
  color: #d9ffe0;
  padding: 16px 18px;
  box-shadow: 0 0 12px rgba(0,0,0,0.9);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  font-size: 0.9rem;
}

.pb-side-card h3 {
  margin-top: 0;
  color: #9affc0;
}

/* Flicker + cursor vibes */
@keyframes text-flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
        opacity: 1;
    }
    20%, 24%, 55% {
        opacity: 0.85;
    }
}
</style>
"""

with gr.Blocks(title="PrettyBird – Behavioral Consciousness Engine (BCE)") as demo:
    # CSS + star layers
    gr.HTML(CUSTOM_CSS)
    gr.HTML("""
    <div id="stars"></div>
    <div id="stars2"></div>
    <div id="stars3"></div>
    """)

    gr.Markdown(HEADER_MD)

    with gr.Row():
        with gr.Column(scale=2):
            chatbot = gr.ChatInterface(
                fn=respond,
                elem_id="prettybird-chat",
            )
        with gr.Column(scale=1):
            gr.HTML('<div class="pb-side-card"><h3>🧬 BCE in a Nutshell</h3><p>'
                    + BCE_SHORT_TR +
                    '</p></div>')


if __name__ == "__main__":
    demo.launch()