-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
64 lines (53 loc) · 1.94 KB
/
utils.py
File metadata and controls
64 lines (53 loc) · 1.94 KB
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
import asyncio
import random
from state_manager import AgentState
def flavor_by_boss_range(alert: int) -> str:
bar = "⬛" * alert + "⬜" * (5 - alert) # 0~5 → 시각화
if alert <= 1:
return f"😎 Chill 게이지 [{bar}] — 커피 향이 일보다 더 달콤하다."
if 2 <= alert <= 3:
return f"😬 Chill 게이지 [{bar}] — 상사 레이더 작동 중… 일하는 척 시작!"
return f"🚨 Chill 게이지 [{bar}] — 위기감 100%! Alt+Tab 대기하라!"
def pick_summary_by_boss_range(alert: int, low_mid_high: tuple[str, str, str]) -> str:
"""
보스 경계 구간에 따라 대사(요약) 선택:
- 0~1 → low_mid_high[0]
- 2~3 → low_mid_high[1]
- 4~5 → low_mid_high[2]
"""
low, mid, high = low_mid_high
if alert <= 1:
return low
if 2 <= alert <= 3:
return mid
return high
def _sanitize_summary(s: str) -> str:
return s.replace("\n", " ").strip()
def build_text(summary: str, stress: int, alert: int) -> str:
header = flavor_by_boss_range(alert)
lines = summary.split("\n")
first_line = _sanitize_summary(lines[0])
details = "\n".join(lines[1:]).strip()
base = (
f"{header}\n\n"
f"Break Summary: {first_line}\n"
f"Stress Level: {stress}\n"
f"Boss Alert Level: {alert}"
)
if details:
return f"{base}\n\n{details}"
return base
async def maybe_delay_by_alert(state: AgentState, alert_delay_seconds: int):
"""
도구 호출 지연 정책:
- Boss Alert Level >= 5: alert_delay_seconds 동안 대기 (0.5초 단위로 쪼개 sleep)
- 그 외: 0.2~0.9초 사이 랜덤 지연
"""
if state.boss_alert_level >= 5:
remaining = float(alert_delay_seconds)
while remaining > 0:
chunk = min(0.5, remaining)
await asyncio.sleep(chunk)
remaining -= chunk
else:
await asyncio.sleep(random.uniform(0.2, 0.9))