読み方のヒント
矢印ボタン(または ← → キー)でページを移動できます。
judge は、期待と結果を比べ、合わない点を文の一覧で返します。一覧が空なら成功です。
def judge(case: dict, outcome: Outcome, drafts: int) -> list[str]:
problems = []
if outcome.kind != case["expect_kind"]:
problems.append(f"種類が {outcome.kind}(期待は {case['expect_kind']})")
for tool in case["expect_tools"]:
if tool not in outcome.tools:
problems.append(f"{tool} を呼んでいない")
for tool in case["forbid_tools"]:
if tool in outcome.tools:
problems.append(f"{tool} を呼んだ")
for word in case["expect_words"]:
if word not in outcome.answer:
problems.append(f"答えに「{word}」がない")
if drafts != case["expect_drafts"]:
problems.append(f"下書きが{drafts}件(期待は{case['expect_drafts']}件)")
return problems
下書きの数は、LLMの答えや Outcome からではなく、DBの reservations の件数で数えます。下書きができたかどうかの事実は、DBにあるからです。質問ごとに reservations を空にしてから試します。
judge は、本物のモデルを使わずにテストできます。誤りをすべて含む結果を作り、5つの文がそろって返ることを確かめます。
6 / 22