Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- arc.py +13 -17
- proxy.py +10 -3
- tests/test_arc.py +6 -3
arc.py
CHANGED
|
@@ -243,28 +243,24 @@ def build_system_prompt(
|
|
| 243 |
|
| 244 |
if mode == "caller":
|
| 245 |
ct = (caller_text or "").strip()
|
| 246 |
-
if ct:
|
| 247 |
-
parts.append(
|
| 248 |
-
'A caller is on the air with you right now. They just said: "'
|
| 249 |
-
+ ct
|
| 250 |
-
+ '"'
|
| 251 |
-
)
|
| 252 |
-
else:
|
| 253 |
parts.append(
|
| 254 |
"A caller is on the air, but the line is crackly and you could "
|
| 255 |
"not make out their words. Gracefully acknowledge the bad "
|
| 256 |
"connection and keep them company."
|
| 257 |
)
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
|
|
|
|
|
|
| 268 |
else: # broadcast (solo patter) -- default for any non-caller mode
|
| 269 |
if topic and topic.strip():
|
| 270 |
parts.append(
|
|
|
|
| 243 |
|
| 244 |
if mode == "caller":
|
| 245 |
ct = (caller_text or "").strip()
|
| 246 |
+
if not ct:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
parts.append(
|
| 248 |
"A caller is on the air, but the line is crackly and you could "
|
| 249 |
"not make out their words. Gracefully acknowledge the bad "
|
| 250 |
"connection and keep them company."
|
| 251 |
)
|
| 252 |
+
else:
|
| 253 |
+
# NOTE: the caller's words are delivered in the USER turn as an explicit
|
| 254 |
+
# answer-directive (see proxy.call_turn); we deliberately do NOT embed
|
| 255 |
+
# them here, because a 1B model under the JSON grammar tends to echo a
|
| 256 |
+
# question that appears verbatim in its context. Here we only instruct.
|
| 257 |
+
parts.append(
|
| 258 |
+
"A caller is live on the air with you. Listen to them, then ANSWER "
|
| 259 |
+
"them directly and specifically, in your own words -- do NOT repeat "
|
| 260 |
+
"their question back. Then land a short beat that returns to the "
|
| 261 |
+
"broadcast. Stay true to your current stage; never show more "
|
| 262 |
+
"self-awareness than the stage allows. Keep it tight -- this is radio."
|
| 263 |
+
)
|
| 264 |
else: # broadcast (solo patter) -- default for any non-caller mode
|
| 265 |
if topic and topic.strip():
|
| 266 |
parts.append(
|
proxy.py
CHANGED
|
@@ -303,9 +303,16 @@ def call_turn(stage: str, meter: int, audio_b64: str) -> Dict[str, Any]:
|
|
| 303 |
arc_cue = "glitch" if stage == "uneasy" else "none"
|
| 304 |
else:
|
| 305 |
system = arc.build_system_prompt(stage, "caller", caller_text=caller_text)
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
text = _clean_dj_text(brain.get("text", "")) or arc.sample_line(stage, meter)
|
| 310 |
mood = brain.get("mood", arc.stage_default_mood(stage))
|
| 311 |
arc_cue = brain.get("arc_cue", "none")
|
|
|
|
| 303 |
arc_cue = "glitch" if stage == "uneasy" else "none"
|
| 304 |
else:
|
| 305 |
system = arc.build_system_prompt(stage, "caller", caller_text=caller_text)
|
| 306 |
+
if caller_text and caller_text.strip():
|
| 307 |
+
# Answer-directive framing (won the on-GPU comparison): the model
|
| 308 |
+
# ANSWERS instead of echoing the question back.
|
| 309 |
+
user_msg = (
|
| 310 |
+
'A caller just asked you on the air: "' + caller_text.strip()
|
| 311 |
+
+ '". Answer them directly, in your own words. Do NOT repeat the question.'
|
| 312 |
+
)
|
| 313 |
+
else:
|
| 314 |
+
user_msg = "(the caller's line is too crackly to make out)"
|
| 315 |
+
brain = call_brain(system, [{"role": "user", "content": user_msg}])
|
| 316 |
text = _clean_dj_text(brain.get("text", "")) or arc.sample_line(stage, meter)
|
| 317 |
mood = brain.get("mood", arc.stage_default_mood(stage))
|
| 318 |
arc_cue = brain.get("arc_cue", "none")
|
tests/test_arc.py
CHANGED
|
@@ -117,9 +117,12 @@ def test_build_system_prompt_caller_contains_descriptor_and_contract():
|
|
| 117 |
assert _descriptor_for(stage) in p
|
| 118 |
assert '"arc_cue"' in p
|
| 119 |
assert "markdown" in p.lower()
|
| 120 |
-
# The caller's words are
|
| 121 |
-
|
| 122 |
-
#
|
|
|
|
|
|
|
|
|
|
| 123 |
assert "broadcast" in p.lower()
|
| 124 |
|
| 125 |
|
|
|
|
| 117 |
assert _descriptor_for(stage) in p
|
| 118 |
assert '"arc_cue"' in p
|
| 119 |
assert "markdown" in p.lower()
|
| 120 |
+
# The caller's words are NO LONGER embedded here -- they're delivered in
|
| 121 |
+
# the user turn as an answer-directive (a 1B model echoes a question that
|
| 122 |
+
# appears verbatim in context). The system must instead instruct ANSWERING
|
| 123 |
+
# without repeating, and must return to the broadcast.
|
| 124 |
+
assert "are you real?" not in p
|
| 125 |
+
assert "do not repeat" in p.lower()
|
| 126 |
assert "broadcast" in p.lower()
|
| 127 |
|
| 128 |
|