Slide 12
Slide 12 text
難しかった点 3 - 過去の会話の記録と参照
質問への回答と、容疑者の発言を別々に記録する
- 尋問への回答 → 探偵に聞かれて答えたこと
- 独り言 → 誰も聞いていないのに容疑者が勝手に話しかけてくる雑談
~~~
def _build_my_history(history: list, live_utterances: list, suspect_id: str) -> list:
# 尋問中の応答を集める
from_ask = [
{"question": h.get("question", ""), "answer": _get_answer_for(h, suspect_id)}
for h in history
if _get_answer_for(h, suspect_id)
]
# 容疑者の発言を集める
from_tick = [
{"question": "", "answer": u.get("text", "")}
for u in live_utterances
if u.get("suspect_id") == suspect_id
]
# 尋問応答を最優先で直近3件は必ず確保する
ask_recent = from_ask[-3:]
# 残りの枠(最大2件)だけを独り言で埋める
remaining_slots = min(max(0, 5 - len(ask_recent)), 2)
tick_recent = from_tick[-remaining_slots:] if remaining_slots else []
return ask_recent + tick_recent
~~~
��