feat(agent): tune retrieval for decision support
This commit is contained in:
@@ -6,7 +6,13 @@ import pytest
|
||||
|
||||
from agent.config import Config
|
||||
from agent.generate import answer_question
|
||||
from agent.query_planner import SubQuery, parse_plan, plan_queries, should_plan
|
||||
from agent.query_planner import (
|
||||
SubQuery,
|
||||
decision_support_plan,
|
||||
parse_plan,
|
||||
plan_queries,
|
||||
should_plan,
|
||||
)
|
||||
from tests.conftest import FakeOllama
|
||||
|
||||
|
||||
@@ -20,12 +26,45 @@ def test_should_plan_gate():
|
||||
"Wie wird die Überstundenpauschale behandelt und wie wirkt sie sich "
|
||||
"auf die Sozialversicherung und die Lohnsteuer aus?"
|
||||
)
|
||||
# Gestaltungsfrage -> planen, auch wenn sie unter der Längenschwelle bleibt
|
||||
assert should_plan(
|
||||
"Ich will meinem Mitarbeiter 500 Euro zusätzlich auszahlen. "
|
||||
"Was ist die günstigste Lösung?"
|
||||
)
|
||||
# einfach -> Single-Shot
|
||||
assert not should_plan("Wie viele Werktage Urlaub stehen Arbeitnehmern zu?")
|
||||
assert not should_plan("Was ist Altersteilzeit?")
|
||||
assert not should_plan("Wie hoch ist der KV-Mindestlohn im Friseurgewerbe?")
|
||||
|
||||
|
||||
def test_decision_support_plan_splits_direct_payment_and_alternatives():
|
||||
planned = decision_support_plan(
|
||||
"Ich will meinem Mitarbeiter 500 Euro zusätzlich auszahlen. "
|
||||
"Was ist die günstigste Lösung?",
|
||||
default_year="2026",
|
||||
)
|
||||
assert planned is not None
|
||||
subs, qtype = planned
|
||||
assert qtype == "specific"
|
||||
assert len(subs) == 3
|
||||
assert all(s.scope == "gesetz" for s in subs)
|
||||
assert all(s.stand_year == "2026" for s in subs)
|
||||
assert "Mitarbeiterprämie 2026" in subs[0].text
|
||||
assert "Zukunftssicherung" in subs[1].text
|
||||
assert "Mahlzeiten" in subs[2].text
|
||||
|
||||
|
||||
def test_decision_support_plan_keeps_explicit_year_and_specific_intent():
|
||||
subs, qtype = decision_support_plan(
|
||||
"Kann ich 2025 jedem Mitarbeiter einfach 500 Euro steuerfrei auszahlen?",
|
||||
default_year="2026",
|
||||
)
|
||||
assert qtype == "specific"
|
||||
assert len(subs) == 1
|
||||
assert subs[0].stand_year == "2025"
|
||||
assert "Mitarbeiterprämie 2025" in subs[0].text
|
||||
|
||||
|
||||
def test_parse_plan_valid_and_fallback():
|
||||
subs, qtype = parse_plan(
|
||||
'Vorab: {"type": "specific", "queries": [{"text": "mindestlohn friseur", "stand_year": "2024"}, '
|
||||
|
||||
Reference in New Issue
Block a user