11import numpy as np
22import pytest
33
4- from promptolution .helpers import FirstOccurrenceClassifier , MarkerBasedClassifier
4+ from promptolution .helpers import FirstOccurrencePredictor , MarkerBasedPredictor
55
66
77def test_first_occurrence_classifier (mock_downstream_llm , mock_df ):
8- """Test the FirstOccurrenceClassifier ."""
8+ """Test the FirstOccurrencePredictor ."""
99 # Create classifier
10- classifier = FirstOccurrenceClassifier (llm = mock_downstream_llm , classes = mock_df ["y" ].values )
10+ classifier = FirstOccurrencePredictor (llm = mock_downstream_llm , classes = mock_df ["y" ].values )
1111
1212 # Test with multiple inputs
1313 xs = ["I love this product!" , "I hate this product!" , "This product is okay." , "ja ne" ]
@@ -25,9 +25,9 @@ def test_first_occurrence_classifier(mock_downstream_llm, mock_df):
2525
2626
2727def test_marker_based_classifier (mock_downstream_llm , mock_df ):
28- """Test the MarkerBasedClassifier ."""
28+ """Test the MarkerBasedPredictor ."""
2929 # Create classifier
30- classifier = MarkerBasedClassifier (
30+ classifier = MarkerBasedPredictor (
3131 llm = mock_downstream_llm ,
3232 classes = mock_df ["y" ].values ,
3333 begin_marker = "<final_answer>" ,
@@ -56,9 +56,9 @@ def test_marker_based_classifier(mock_downstream_llm, mock_df):
5656
5757
5858def test_marker_based_without_classes (mock_downstream_llm ):
59- """Test MarkerBasedClassifier without predefined classes."""
59+ """Test MarkerBasedPredictor without predefined classes."""
6060 # Create classifier without classes
61- classifier = MarkerBasedClassifier (
61+ predictor = MarkerBasedPredictor (
6262 llm = mock_downstream_llm ,
6363 classes = None , # No class restrictions
6464 begin_marker = "<final_answer>" ,
@@ -70,7 +70,7 @@ def test_marker_based_without_classes(mock_downstream_llm):
7070 prompts = ["Classify:" ] * len (xs )
7171
7272 # Make predictions
73- predictions = classifier .predict (prompts , xs )
73+ predictions = predictor .predict (prompts , xs )
7474
7575 # Verify shape and content - should accept any value between markers
7676 assert len (predictions ) == 4
@@ -83,7 +83,7 @@ def test_marker_based_without_classes(mock_downstream_llm):
8383def test_multiple_prompts_with_classifiers (mock_downstream_llm , mock_df ):
8484 """Test using multiple prompts with classifiers."""
8585 # Create classifier
86- classifier = FirstOccurrenceClassifier (llm = mock_downstream_llm , classes = mock_df ["y" ].values )
86+ classifier = FirstOccurrencePredictor (llm = mock_downstream_llm , classes = mock_df ["y" ].values )
8787
8888 # Test with multiple prompts
8989 prompts = ["Classify:" , "Classify:" , "Rate:" , "Rate:" ]
@@ -103,7 +103,7 @@ def test_multiple_prompts_with_classifiers(mock_downstream_llm, mock_df):
103103def test_sequence_return_with_classifiers (mock_downstream_llm , mock_df ):
104104 """Test return_seq parameter with classifiers."""
105105 # Create classifier
106- classifier = MarkerBasedClassifier (llm = mock_downstream_llm , classes = mock_df ["y" ].values )
106+ classifier = MarkerBasedPredictor (llm = mock_downstream_llm , classes = mock_df ["y" ].values )
107107
108108 # Test with return_seq=True
109109 prompts = ["Classify:" ]
@@ -128,15 +128,15 @@ def test_invalid_class_labels(mock_downstream_llm):
128128
129129 # Should raise an assertion error
130130 with pytest .raises (AssertionError ):
131- FirstOccurrenceClassifier (llm = mock_downstream_llm , classes = invalid_classes )
131+ FirstOccurrencePredictor (llm = mock_downstream_llm , classes = invalid_classes )
132132
133133 with pytest .raises (AssertionError ):
134- MarkerBasedClassifier (llm = mock_downstream_llm , classes = invalid_classes )
134+ MarkerBasedPredictor (llm = mock_downstream_llm , classes = invalid_classes )
135135
136136
137137def test_marker_based_missing_markers (mock_downstream_llm ):
138- """Test MarkerBasedClassifier behavior when markers are missing."""
139- classifier = MarkerBasedClassifier (llm = mock_downstream_llm , classes = ["will" , "not" , "be" , "used" ])
138+ """Test MarkerBasedPredictor behavior when markers are missing."""
139+ classifier = MarkerBasedPredictor (llm = mock_downstream_llm , classes = ["will" , "not" , "be" , "used" ])
140140
141141 # When markers are missing, it should default to first class
142142 prompts = ["Classify:" ]
0 commit comments