Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sparkth/plugins/chat/assets/scope_keywords.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"can you code",
"debug",
"fix this",
"translate",
"rewrite",
"python",
"javascript",
Expand Down
19 changes: 19 additions & 0 deletions sparkth/plugins/chat/tests/test_scope_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ def test_course_related_query_with_potential_substring_match_is_in_scope(self) -
# "curriculum" (in-scope) wins
assert is_query_in_scope("Who is responsible for curriculum design in K-12?") is True

def test_translation_requests_reach_the_classifier(self) -> None:
""" "translate" must not hard-refuse: the keyword layer cannot express the
system prompt's "unrelated to course content" qualifier, so it over-refuses.
The LLM classifier downstream handles the genuinely out-of-scope case."""
assert is_query_in_scope("translate this into Spanish") is True
assert is_query_in_scope("Can you translate my content to French") is True
assert is_query_in_scope("translate everything to German") is True
# Contrast case from the research table: this one already passed before the fix,
# because the in-scope "outline" short-circuits the out-of-scope check. Kept to
# pin that the in-scope override still wins.
assert is_query_in_scope("translate this outline into Spanish") is True

def test_non_english_query_falls_through_to_the_classifier(self) -> None:
"""A non-English query matches no English keyword either way, so the filter
returns True and the classifier decides. Pins existing behaviour that nothing
else asserts — the pre-filter is a fast path, never a non-English refusal."""
assert is_query_in_scope("crea un curso sobre privacidad de datos") is True
assert is_query_in_scope("créer un cours sur la protection des données") is True


class TestStreamOutOfScopeRefusal:
"""Test the stream_out_of_scope_refusal SSE generator."""
Expand Down
Loading