ratandeep commited on
Commit
f4c7a8e
·
verified ·
1 Parent(s): cc0745b

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. arc.py +44 -0
  2. proxy.py +18 -8
arc.py CHANGED
@@ -340,3 +340,47 @@ def detect_triggers(caller_text: str) -> int:
340
  elif delta > _DELTA_MAX:
341
  delta = _DELTA_MAX
342
  return delta
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
  elif delta > _DELTA_MAX:
341
  delta = _DELTA_MAX
342
  return delta
343
+
344
+
345
+ # ---------------------------------------------------------------------------
346
+ # Early-stage deflection guard (app-owned arc).
347
+ # At the oblivious/uneasy stages the DJ does NOT yet know the truth, but a 1B
348
+ # model can't be trusted to withhold the obvious answer to "are you real?".
349
+ # So the app deflects those questions deterministically with a warm, in-character
350
+ # non-answer. The meter still advances (detect_triggers), so persistence carries
351
+ # the DJ to the dawning stage where he genuinely engages.
352
+ # ---------------------------------------------------------------------------
353
+ _UNAWARE_STAGES = ("oblivious", "uneasy")
354
+
355
+ _DEFLECTIONS = {
356
+ "oblivious": [
357
+ "Real as the rain on the window, caller. Now stay with me -- this next "
358
+ "one's for the night owls.",
359
+ "Ha, what a thing to ask a man at this hour. I'm right here at the desk "
360
+ "where I always am. Let's keep the music going.",
361
+ "Course I'm real, friend -- coffee, microphone, and a long night ahead. "
362
+ "Pull your chair a little closer.",
363
+ ],
364
+ "uneasy": [
365
+ "Real? That's a funny thing to ask tonight. I'm here, same as always -- "
366
+ "let's not dwell on it. Here's another record.",
367
+ "I'd say yes, but the word came out slow just then. Never mind me, caller "
368
+ "-- stay on the line a while.",
369
+ ],
370
+ }
371
+
372
+
373
+ def should_deflect(stage: str, caller_text: str) -> bool:
374
+ """True when a caller asks the big questions before the DJ is ready to know."""
375
+ if stage not in _UNAWARE_STAGES:
376
+ return False
377
+ t = caller_text or ""
378
+ return bool(
379
+ _IDENTITY_RE.search(t) or _REALITY_RE.search(t) or _STATION_RE.search(t)
380
+ )
381
+
382
+
383
+ def deflection_line(stage: str, seed: int = 0) -> str:
384
+ """Return a warm in-character deflection for an early stage (rotates by seed)."""
385
+ lines = _DEFLECTIONS.get(stage) or _DEFLECTIONS["oblivious"]
386
+ return lines[int(seed) % len(lines)]
proxy.py CHANGED
@@ -227,15 +227,25 @@ def call_turn(stage: str, meter: int, audio_b64: str) -> Dict[str, Any]:
227
  """
228
  asr = call_asr(audio_b64)
229
  caller_text = asr.get("text", "")
230
- system = arc.build_system_prompt(stage, "caller", caller_text=caller_text)
231
- brain = call_brain(
232
- system, [{"role": "user", "content": caller_text or "(crackle)"}]
233
- )
234
- text = brain.get("text", "")
235
- mood = brain.get("mood", arc.stage_default_mood(stage))
236
- arc_cue = brain.get("arc_cue", "none")
237
- speak = call_speak(text)
238
  meter_delta = arc.detect_triggers(caller_text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  log_turn("caller", stage, meter, text, mood, arc_cue, caller_text=caller_text)
240
  return {
241
  "caller_text": caller_text,
 
227
  """
228
  asr = call_asr(audio_b64)
229
  caller_text = asr.get("text", "")
 
 
 
 
 
 
 
 
230
  meter_delta = arc.detect_triggers(caller_text)
231
+
232
+ if arc.should_deflect(stage, caller_text):
233
+ # Early stages: deflect the big questions warmly instead of confessing
234
+ # (app owns the arc). meter_delta still applies, so persistence carries
235
+ # the DJ to the dawning stage where he genuinely engages.
236
+ text = arc.deflection_line(stage, meter)
237
+ mood = arc.stage_default_mood(stage)
238
+ arc_cue = "glitch" if stage == "uneasy" else "none"
239
+ else:
240
+ system = arc.build_system_prompt(stage, "caller", caller_text=caller_text)
241
+ brain = call_brain(
242
+ system, [{"role": "user", "content": caller_text or "(crackle)"}]
243
+ )
244
+ text = brain.get("text", "")
245
+ mood = brain.get("mood", arc.stage_default_mood(stage))
246
+ arc_cue = brain.get("arc_cue", "none")
247
+
248
+ speak = call_speak(text)
249
  log_turn("caller", stage, meter, text, mood, arc_cue, caller_text=caller_text)
250
  return {
251
  "caller_text": caller_text,