Address review feedback: fix tiebreaker map, error handling, regex patterns
- Add BlueskyItem/TruthSocialItem to _ITEM_SOURCE_MAP (wrong tiebreaker) - Add bluesky/truthsocial to _DEFAULT_TIEBREAKER - Log HTTPError in select_openai_model instead of silent fallback - Remove overly broad 'or.*for' from comparison regex (false positives) - Remove bare 'will' from prediction regex (misclassifies feature queries) - Narrow brave_search except clauses to ValueError/TypeError - Fix stale comments: pricing table, docstrings, penalty descriptions
This commit is contained in:
@@ -46,8 +46,9 @@ class TestDetectQueryType(unittest.TestCase):
|
||||
self.assertEqual(detect_query_type("OpenAI just announced GPT-6"), "breaking_news")
|
||||
|
||||
def test_prediction_queries(self):
|
||||
self.assertEqual(detect_query_type("will Trump win 2028 election"), "prediction")
|
||||
self.assertEqual(detect_query_type("odds of Fed rate cut"), "prediction")
|
||||
self.assertEqual(detect_query_type("predict the next recession"), "prediction")
|
||||
self.assertEqual(detect_query_type("election outcome 2028"), "prediction")
|
||||
|
||||
def test_default_is_breaking_news(self):
|
||||
self.assertEqual(detect_query_type("tariffs"), "breaking_news")
|
||||
@@ -61,6 +62,14 @@ class TestDetectQueryType(unittest.TestCase):
|
||||
"""How-to is more specific than concept."""
|
||||
self.assertEqual(detect_query_type("how to explain transformers"), "how_to")
|
||||
|
||||
def test_will_alone_not_prediction(self):
|
||||
"""Bare 'will' should not trigger prediction classification."""
|
||||
self.assertNotEqual(detect_query_type("Will React 19 support concurrent mode"), "prediction")
|
||||
|
||||
def test_or_for_not_comparison(self):
|
||||
"""'or X for Y' should not trigger comparison classification."""
|
||||
self.assertNotEqual(detect_query_type("best tools or libraries for Python"), "comparison")
|
||||
|
||||
|
||||
class TestIsSourceEnabled(unittest.TestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user