fix: enforce assistant data quality disclosures
This commit is contained in:
@@ -98,6 +98,51 @@ def test_geo_assistant_recognizes_dutch_historical_questions(question: str) -> N
|
||||
assert GeoAssistantService.history_requested(question) is True
|
||||
|
||||
|
||||
def test_geo_assistant_discloses_estimated_population_values() -> None:
|
||||
metrics = [
|
||||
AssistantContextMetric(
|
||||
theme="population",
|
||||
label="Geschatte bevolking",
|
||||
value=74_254,
|
||||
unit="personen",
|
||||
source="Statbel",
|
||||
dataset_id=uuid4(),
|
||||
is_estimate=True,
|
||||
)
|
||||
]
|
||||
|
||||
answer = GeoAssistantService.ensure_estimate_disclosure(
|
||||
"De bevolking bedraagt 74.254 personen.",
|
||||
metrics,
|
||||
)
|
||||
|
||||
assert answer.startswith(
|
||||
"Datakwaliteit: bevolkingswaarden in dit antwoord zijn schattingen volgens de bronmetadata, "
|
||||
"geen exacte tellingen."
|
||||
)
|
||||
|
||||
|
||||
def test_geo_assistant_does_not_add_irrelevant_estimate_disclosure() -> None:
|
||||
metrics = [
|
||||
AssistantContextMetric(
|
||||
theme="population",
|
||||
label="Geschatte bevolking",
|
||||
value=74_254,
|
||||
unit="personen",
|
||||
source="Statbel",
|
||||
dataset_id=uuid4(),
|
||||
is_estimate=True,
|
||||
)
|
||||
]
|
||||
|
||||
answer = GeoAssistantService.ensure_estimate_disclosure(
|
||||
"De bosoppervlakte bedraagt 3.626,56 hectare.",
|
||||
metrics,
|
||||
)
|
||||
|
||||
assert answer == "De bosoppervlakte bedraagt 3.626,56 hectare."
|
||||
|
||||
|
||||
def test_geo_assistant_sends_grounded_context_without_thinking_trace(monkeypatch) -> None:
|
||||
service = GeoAssistantService(ollama_settings())
|
||||
project_id = uuid4()
|
||||
@@ -161,6 +206,7 @@ def test_geo_assistant_sends_grounded_context_without_thinking_trace(monkeypatch
|
||||
assert "scope.label is het exact geanalyseerde gebied" in captured["payload"]["messages"][0]["content"]
|
||||
assert "noem de waarde verplicht een schatting" in captured["payload"]["messages"][0]["content"]
|
||||
assert "verzin geen oorzaak, voorspelling, verzadiging" in captured["payload"]["messages"][0]["content"]
|
||||
assert "bereken zelf geen gemiddelde, tempo, oorzaak of afgeleide trend" in captured["payload"]["messages"][0]["content"]
|
||||
assert "zonder Markdown-symbolen" in captured["payload"]["messages"][0]["content"]
|
||||
assert "water_volume_available" in captured["payload"]["messages"][0]["content"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user