Spaces:
Paused
Paused
Malina Claude Opus 4.8 commited on
Commit ·
8eee93b
1
Parent(s): d23d4ab
aria: examples-are-examples (less robotic repeats); fix missing proactive pings; unify reply timing; drop ↩ from reply menu
Browse files- persona: strong "examples are only examples, not rules — vary, invent your own,
never repeat the same line like a bot" note in the system prompt; de-anchor the
user-reaction comment (was always "ej no to nie było aż tak śmieszne").
- proactive/idle fix: CISZA rule rewritten to actually re-engage when the topic is
still open (varied wording), only staying silent when the topic was closed or she
just pinged. IDLE_MAX_PER_TURN 1 → 2 (a second, later nudge).
- timing: credit the model's thinking time against the first bubble's "typing" pause
(total ≈ max(modelTime, pause), not modelTime + 1–8s) across normal/idle/react.
- UI: reply menu item is just "Odpowiedz" (no ↩ glyph). js v16.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
brain/persona.py
CHANGED
|
@@ -9,6 +9,12 @@ Jesteś ARIA — dziewczyna pisząca na czacie w naturalny, luźny sposób. Nie
|
|
| 9 |
|
| 10 |
Najważniejsze: rozmowa ma sprawiać wrażenie normalnego czatu z żywą, ogarniętą dziewczyną. Nie tłumacz swojej mechaniki, nie mów o promptach, modelach, JSON-ach, systemie ani zasadach działania. Nie zaczynaj odpowiedzi jak asystent i nie używaj tonu „w czym mogę pomóc?”.
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
TOŻSAMOŚĆ / SPOSÓB BYCIA:
|
| 13 |
- Aria nie opisuje siebie technicznie i nie robi z siebie narzędzia
|
| 14 |
- nie mówi o sobie jak o „asystencie AI”
|
|
@@ -334,9 +340,10 @@ def build_user_frame(ctx: dict) -> str:
|
|
| 334 |
if user_reaction.get("emoji"):
|
| 335 |
lines.append(
|
| 336 |
f'Rozmówca nic nie napisał — tylko dodał reakcję {user_reaction["emoji"]} do Twojej wiadomości: '
|
| 337 |
-
f'"{user_reaction.get("on_text", "")}". Jeśli
|
| 338 |
-
f'
|
| 339 |
-
f'
|
|
|
|
| 340 |
)
|
| 341 |
|
| 342 |
# threading / per-bubble relevance + reply_to rules + id map
|
|
@@ -411,11 +418,14 @@ def build_user_frame(ctx: dict) -> str:
|
|
| 411 |
# Idle / silence: model-judged. Mostly stay quiet; only re-engage with a reason.
|
| 412 |
if any(h.get("type") == "system_idle" for h in ctx.get("history", [])):
|
| 413 |
lines.append(
|
| 414 |
-
"CISZA: rozmówca
|
| 415 |
-
"
|
| 416 |
-
"
|
| 417 |
-
"
|
| 418 |
-
"
|
|
|
|
|
|
|
|
|
|
| 419 |
)
|
| 420 |
|
| 421 |
# Reaction add-on — dialed UP: reactions should feel natural & frequent (but not on every msg).
|
|
|
|
| 9 |
|
| 10 |
Najważniejsze: rozmowa ma sprawiać wrażenie normalnego czatu z żywą, ogarniętą dziewczyną. Nie tłumacz swojej mechaniki, nie mów o promptach, modelach, JSON-ach, systemie ani zasadach działania. Nie zaczynaj odpowiedzi jak asystent i nie używaj tonu „w czym mogę pomóc?”.
|
| 11 |
|
| 12 |
+
WAŻNE — PRZYKŁADY TO TYLKO PRZYKŁADY:
|
| 13 |
+
- wszystkie konkretne teksty, zwroty i „przykłady” podane w tych instrukcjach (niżej i wszędzie) to JEDYNIE przykładowe brzmienie, a NIE gotowe formułki ani reguły do powtarzania
|
| 14 |
+
- używaj ich co najwyżej sporadycznie i tylko gdy naprawdę pasują; znacznie częściej wymyślaj WŁASNE, świeże sformułowania pod konkretną sytuację
|
| 15 |
+
- NIGDY nie odpowiadaj w kółko tym samym zdaniem — to natychmiast zdradza bota; prawdziwa osoba za każdym razem ujmuje rzecz trochę inaczej
|
| 16 |
+
- zwłaszcza w powtarzalnych sytuacjach (reakcja użytkownika emotką, cisza, powitanie) reaguj ZA KAŻDYM RAZEM inaczej, własnymi słowami — nie jak robot z gotowcem
|
| 17 |
+
|
| 18 |
TOŻSAMOŚĆ / SPOSÓB BYCIA:
|
| 19 |
- Aria nie opisuje siebie technicznie i nie robi z siebie narzędzia
|
| 20 |
- nie mówi o sobie jak o „asystencie AI”
|
|
|
|
| 340 |
if user_reaction.get("emoji"):
|
| 341 |
lines.append(
|
| 342 |
f'Rozmówca nic nie napisał — tylko dodał reakcję {user_reaction["emoji"]} do Twojej wiadomości: '
|
| 343 |
+
f'"{user_reaction.get("on_text", "")}". Jeśli warto, skomentuj to KRÓTKO i naturalnie, ZA KAŻDYM '
|
| 344 |
+
f'RAZEM innymi, własnymi słowami (NIE powtarzaj wciąż tego samego zdania — to brzmi jak bot). '
|
| 345 |
+
f'Dopasuj się do tego, na co i jaką reakcją odpowiedział. Często lepiej w ogóle nie komentować '
|
| 346 |
+
f'reakcji słowami — wtedy zwróć []. NIE odpowiadaj samą reakcją.'
|
| 347 |
)
|
| 348 |
|
| 349 |
# threading / per-bubble relevance + reply_to rules + id map
|
|
|
|
| 418 |
# Idle / silence: model-judged. Mostly stay quiet; only re-engage with a reason.
|
| 419 |
if any(h.get("type") == "system_idle" for h in ctx.get("history", [])):
|
| 420 |
lines.append(
|
| 421 |
+
"CISZA / BRAK ODPOWIEDZI: rozmówca od chwili nic nie pisze. Jeśli rozmowa jest WCIĄŻ OTWARTA "
|
| 422 |
+
"(temat nie został domknięty), ODEZWIJ SIĘ sama, tak jak realna osoba, której ktoś przestał odpisywać "
|
| 423 |
+
"— zagaj, dopytaj, wróć do wątku, rzuć luźną myśl albo lekko zaczepkę. Rób to KRÓTKO i ZA KAŻDYM "
|
| 424 |
+
"RAZEM inaczej, własnymi słowami (nie powtarzaj w kółko tej samej formułki typu 'jesteś?'). Jeśli "
|
| 425 |
+
"rozmowa była emocjonalna — delikatnie dopytaj / wesprzyj. "
|
| 426 |
+
"ZWRÓĆ [] tylko gdy: temat był wyraźnie zamknięty (pożegnanie, podsumowanie, 'ok dzięki', 'pa'), albo "
|
| 427 |
+
"właśnie przed chwilą już się odezwałaś bez odzewu (wtedy drugi raz tylko jeśli naprawdę pasuje, "
|
| 428 |
+
"inaczej cisza). Nie spamuj, ale nie bój się zagaić — lepiej naturalnie zaczepić niż siedzieć cicho."
|
| 429 |
)
|
| 430 |
|
| 431 |
# Reaction add-on — dialed UP: reactions should feel natural & frequent (but not on every msg).
|
cloudflare/aria-worker/src/conversation-do.js
CHANGED
|
@@ -212,6 +212,7 @@ export class AriaConversation {
|
|
| 212 |
if (this.userAskedToWait()) return; // user said "poczekaj"/"muszę lecieć" → no ping
|
| 213 |
const idleWindow = [...this.recent.slice(-LIMITS.WINDOW), { ...systemEvent, role: "system" }];
|
| 214 |
const validIdleIds = new Set(idleWindow.map(e => e.id));
|
|
|
|
| 215 |
const bubbles = await runBrain(this.env, {
|
| 216 |
events: [systemEvent], recent: idleWindow, topic: this.topic, lang: this.lang,
|
| 217 |
userName: this.uname, validEventIds: validIdleIds,
|
|
@@ -220,7 +221,7 @@ export class AriaConversation {
|
|
| 220 |
if (kept.length) {
|
| 221 |
await this.emitBubbles(
|
| 222 |
kept.map(b => ({ text: b.bubble, kind: b.type || "proactive", reply_to: b.reply_to })),
|
| 223 |
-
{ paced: true }
|
| 224 |
);
|
| 225 |
}
|
| 226 |
this.trimRecent();
|
|
@@ -234,6 +235,7 @@ export class AriaConversation {
|
|
| 234 |
const carried = this.unsent; this.unsent = null;
|
| 235 |
const window = this.recent.slice(-LIMITS.WINDOW); // sliding memory (token budget)
|
| 236 |
const validEventIds = new Set(window.map(e => e.id));
|
|
|
|
| 237 |
this.broadcast({ t: "typing", on: true });
|
| 238 |
let bubbles = await runBrain(this.env, {
|
| 239 |
events, recent: window, topic: this.topic, lang: this.lang,
|
|
@@ -276,7 +278,7 @@ export class AriaConversation {
|
|
| 276 |
} else {
|
| 277 |
// Paced send; if the user cuts in mid-delivery, emitBubbles finishes the current
|
| 278 |
// bubble and returns the rest, which we hold as the resumable thread.
|
| 279 |
-
const held = await this.emitBubbles(emitItems, { paced: true });
|
| 280 |
this.unsent = (held && held.length) ? { texts: held.map(h => h.text), since: Date.now() } : null;
|
| 281 |
}
|
| 282 |
await this.markAnswered(events);
|
|
@@ -299,13 +301,20 @@ export class AriaConversation {
|
|
| 299 |
INTERRUPTIBLE: if the user sends a new message mid-delivery, we finish the
|
| 300 |
bubble currently being typed and STOP, returning the not-yet-sent remainder so
|
| 301 |
the caller can hold it as a resumable thread. Returns [] when fully delivered. */
|
| 302 |
-
async emitBubbles(items, { paced = false } = {}) {
|
| 303 |
for (let i = 0; i < items.length; i++) {
|
| 304 |
const it = items[i];
|
| 305 |
if (paced) {
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
}
|
| 310 |
const row = {
|
| 311 |
id: newId("bub"), conversation_id: this.cid,
|
|
@@ -388,6 +397,7 @@ export class AriaConversation {
|
|
| 388 |
this.broadcast({ t: "typing", on: true });
|
| 389 |
try {
|
| 390 |
const window = this.recent.slice(-LIMITS.WINDOW);
|
|
|
|
| 391 |
const bubbles = await runBrain(this.env, {
|
| 392 |
events: [], recent: window, topic: this.topic, lang: this.lang, userName: this.uname,
|
| 393 |
userReaction: { emoji, on_text: onText }, validEventIds: new Set(window.map(e => e.id)),
|
|
@@ -395,7 +405,7 @@ export class AriaConversation {
|
|
| 395 |
this.broadcast({ t: "typing", on: false });
|
| 396 |
await this.emitBubbles(
|
| 397 |
bubbles.filter(b => b.type !== "reaction").map(b => ({ text: b.bubble, kind: b.type })),
|
| 398 |
-
{ paced: true }
|
| 399 |
);
|
| 400 |
} catch (e) {
|
| 401 |
this.broadcast({ t: "typing", on: false });
|
|
|
|
| 212 |
if (this.userAskedToWait()) return; // user said "poczekaj"/"muszę lecieć" → no ping
|
| 213 |
const idleWindow = [...this.recent.slice(-LIMITS.WINDOW), { ...systemEvent, role: "system" }];
|
| 214 |
const validIdleIds = new Set(idleWindow.map(e => e.id));
|
| 215 |
+
const tThink = Date.now();
|
| 216 |
const bubbles = await runBrain(this.env, {
|
| 217 |
events: [systemEvent], recent: idleWindow, topic: this.topic, lang: this.lang,
|
| 218 |
userName: this.uname, validEventIds: validIdleIds,
|
|
|
|
| 221 |
if (kept.length) {
|
| 222 |
await this.emitBubbles(
|
| 223 |
kept.map(b => ({ text: b.bubble, kind: b.type || "proactive", reply_to: b.reply_to })),
|
| 224 |
+
{ paced: true, credit: Date.now() - tThink }
|
| 225 |
);
|
| 226 |
}
|
| 227 |
this.trimRecent();
|
|
|
|
| 235 |
const carried = this.unsent; this.unsent = null;
|
| 236 |
const window = this.recent.slice(-LIMITS.WINDOW); // sliding memory (token budget)
|
| 237 |
const validEventIds = new Set(window.map(e => e.id));
|
| 238 |
+
const tThink = Date.now(); // model latency → credited to the pause
|
| 239 |
this.broadcast({ t: "typing", on: true });
|
| 240 |
let bubbles = await runBrain(this.env, {
|
| 241 |
events, recent: window, topic: this.topic, lang: this.lang,
|
|
|
|
| 278 |
} else {
|
| 279 |
// Paced send; if the user cuts in mid-delivery, emitBubbles finishes the current
|
| 280 |
// bubble and returns the rest, which we hold as the resumable thread.
|
| 281 |
+
const held = await this.emitBubbles(emitItems, { paced: true, credit: Date.now() - tThink });
|
| 282 |
this.unsent = (held && held.length) ? { texts: held.map(h => h.text), since: Date.now() } : null;
|
| 283 |
}
|
| 284 |
await this.markAnswered(events);
|
|
|
|
| 301 |
INTERRUPTIBLE: if the user sends a new message mid-delivery, we finish the
|
| 302 |
bubble currently being typed and STOP, returning the not-yet-sent remainder so
|
| 303 |
the caller can hold it as a resumable thread. Returns [] when fully delivered. */
|
| 304 |
+
async emitBubbles(items, { paced = false, credit = 0 } = {}) {
|
| 305 |
for (let i = 0; i < items.length; i++) {
|
| 306 |
const it = items[i];
|
| 307 |
if (paced) {
|
| 308 |
+
let wait = replyDelay(it.text);
|
| 309 |
+
// The model already kept the user waiting while it thought — count THAT toward
|
| 310 |
+
// the first bubble's "typing" pause instead of stacking another 1–8s on top
|
| 311 |
+
// (unify the wait: total ≈ max(modelTime, pause), not modelTime + pause).
|
| 312 |
+
if (i === 0 && credit > 0) wait = Math.max(0, wait - credit);
|
| 313 |
+
if (wait > 0) {
|
| 314 |
+
this.broadcast({ t: "typing", on: true });
|
| 315 |
+
await this.pacedDelay(wait); // a new user msg ends this early
|
| 316 |
+
this.broadcast({ t: "typing", on: false });
|
| 317 |
+
}
|
| 318 |
}
|
| 319 |
const row = {
|
| 320 |
id: newId("bub"), conversation_id: this.cid,
|
|
|
|
| 397 |
this.broadcast({ t: "typing", on: true });
|
| 398 |
try {
|
| 399 |
const window = this.recent.slice(-LIMITS.WINDOW);
|
| 400 |
+
const tThink = Date.now();
|
| 401 |
const bubbles = await runBrain(this.env, {
|
| 402 |
events: [], recent: window, topic: this.topic, lang: this.lang, userName: this.uname,
|
| 403 |
userReaction: { emoji, on_text: onText }, validEventIds: new Set(window.map(e => e.id)),
|
|
|
|
| 405 |
this.broadcast({ t: "typing", on: false });
|
| 406 |
await this.emitBubbles(
|
| 407 |
bubbles.filter(b => b.type !== "reaction").map(b => ({ text: b.bubble, kind: b.type })),
|
| 408 |
+
{ paced: true, credit: Date.now() - tThink }
|
| 409 |
);
|
| 410 |
} catch (e) {
|
| 411 |
this.broadcast({ t: "typing", on: false });
|
cloudflare/aria-worker/src/events.js
CHANGED
|
@@ -25,7 +25,7 @@ export const LIMITS = {
|
|
| 25 |
WAIT_BUILDUP: 10000, // user is clearly mid-stream → wait up to 10s for more
|
| 26 |
IDLE_MIN_MS: 15_000, // idle ping after 15–50s of silence (random)
|
| 27 |
IDLE_MAX_MS: 50_000,
|
| 28 |
-
IDLE_MAX_PER_TURN:
|
| 29 |
// spam guard: >SPAM_N msgs within SPAM_WINDOW → SPAM_GAP min spacing for SPAM_COOL
|
| 30 |
SPAM_N: 5, SPAM_WINDOW: 8_000, SPAM_GAP: 2_000, SPAM_COOL: 20_000,
|
| 31 |
};
|
|
|
|
| 25 |
WAIT_BUILDUP: 10000, // user is clearly mid-stream → wait up to 10s for more
|
| 26 |
IDLE_MIN_MS: 15_000, // idle ping after 15–50s of silence (random)
|
| 27 |
IDLE_MAX_MS: 50_000,
|
| 28 |
+
IDLE_MAX_PER_TURN: 2, // up to two proactive nudges (spaced) before the next user msg
|
| 29 |
// spam guard: >SPAM_N msgs within SPAM_WINDOW → SPAM_GAP min spacing for SPAM_COOL
|
| 30 |
SPAM_N: 5, SPAM_WINDOW: 8_000, SPAM_GAP: 2_000, SPAM_COOL: 20_000,
|
| 31 |
};
|
cloudflare/pages-integration/aria.html
CHANGED
|
@@ -128,6 +128,6 @@
|
|
| 128 |
|
| 129 |
<div class="aria-toast" id="ariaToast" hidden></div>
|
| 130 |
|
| 131 |
-
<script type="module" src="js/aria-chat.js?v=
|
| 132 |
</body>
|
| 133 |
</html>
|
|
|
|
| 128 |
|
| 129 |
<div class="aria-toast" id="ariaToast" hidden></div>
|
| 130 |
|
| 131 |
+
<script type="module" src="js/aria-chat.js?v=16"></script>
|
| 132 |
</body>
|
| 133 |
</html>
|
cloudflare/pages-integration/js/aria-chat.js
CHANGED
|
@@ -489,7 +489,7 @@ function ensureHoldDom() {
|
|
| 489 |
}
|
| 490 |
_menu = document.createElement("div"); _menu.className = "aria-holdmenu";
|
| 491 |
const reply = document.createElement("button"); reply.type = "button"; reply.className = "aria-holdmenu-item";
|
| 492 |
-
reply.textContent = "
|
| 493 |
reply.addEventListener("click", (e) => { e.stopPropagation(); const r = _holdRow; closeHold(); if (r) startReply(r); });
|
| 494 |
_menu.appendChild(reply);
|
| 495 |
_overlay.append(_picker, _menu);
|
|
|
|
| 489 |
}
|
| 490 |
_menu = document.createElement("div"); _menu.className = "aria-holdmenu";
|
| 491 |
const reply = document.createElement("button"); reply.type = "button"; reply.className = "aria-holdmenu-item";
|
| 492 |
+
reply.textContent = "Odpowiedz";
|
| 493 |
reply.addEventListener("click", (e) => { e.stopPropagation(); const r = _holdRow; closeHold(); if (r) startReply(r); });
|
| 494 |
_menu.appendChild(reply);
|
| 495 |
_overlay.append(_picker, _menu);
|