Add writer for promoted tier-2 regulars
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from dataclasses import dataclass
|
||||
from datetime import date
|
||||
from pathlib import Path
|
||||
import json
|
||||
import re
|
||||
@@ -103,3 +104,33 @@ async def _call_sonnet(prompt: str) -> dict:
|
||||
async def evaluate_promotion(caller_name: str, call_transcript: str) -> dict:
|
||||
prompt = PROMOTION_PROMPT.format(name=caller_name, transcript=call_transcript)
|
||||
return await _call_sonnet(prompt)
|
||||
|
||||
|
||||
def write_new_regular(name: str, voice: str, age: int, identity_paragraph: str,
|
||||
arc_plan: str, first_call_summary: str) -> Path:
|
||||
REGULARS_DIR.mkdir(parents=True, exist_ok=True)
|
||||
slug = name.lower().replace(" ", "-")
|
||||
path = REGULARS_DIR / f"{slug}.md"
|
||||
today = date.today().isoformat()
|
||||
content = f"""---
|
||||
name: {name}
|
||||
voice: {voice}
|
||||
age: {age}
|
||||
arc_state: {arc_plan}
|
||||
promoted_on: {today}
|
||||
---
|
||||
|
||||
# {name}
|
||||
|
||||
{identity_paragraph}
|
||||
|
||||
## Arc Plan
|
||||
|
||||
{arc_plan}
|
||||
|
||||
## Arc Log
|
||||
|
||||
- {today}: {first_call_summary}
|
||||
"""
|
||||
path.write_text(content)
|
||||
return path
|
||||
|
||||
@@ -69,3 +69,24 @@ def test_call_sonnet_strips_markdown_fences():
|
||||
result = asyncio.run(_call_sonnet("prompt"))
|
||||
assert result["promote"] is True
|
||||
assert result["arc_plan"] == "ok"
|
||||
|
||||
|
||||
def test_write_new_regular_creates_lore_file(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr("backend.services.regulars_v2.REGULARS_DIR", tmp_path)
|
||||
from backend.services.regulars_v2 import write_new_regular
|
||||
|
||||
write_new_regular(
|
||||
name="Bobby",
|
||||
voice="Marcus",
|
||||
age=34,
|
||||
identity_paragraph="A landscaper in Las Cruces who...",
|
||||
arc_plan="3 episodes: distant → reveal → apology",
|
||||
first_call_summary="Called about damaged car",
|
||||
)
|
||||
f = tmp_path / "bobby.md"
|
||||
assert f.exists()
|
||||
body = f.read_text()
|
||||
assert "name: Bobby" in body
|
||||
assert "voice: Marcus" in body
|
||||
assert "A landscaper in Las Cruces" in body
|
||||
assert "3 episodes: distant → reveal → apology" in body
|
||||
|
||||
Reference in New Issue
Block a user