@@ -20,8 +20,7 @@ def server():
2020
2121@pytest .mark .asyncio
2222@pytest .mark .parametrize ("model_name" , [MODEL_NAME ])
23- async def test_text_1_str_text_2_list (server : RemoteOpenAIServer ,
24- model_name : str ):
23+ def test_text_1_str_text_2_list (server : RemoteOpenAIServer , model_name : str ):
2524 text_1 = "What is the capital of France?"
2625 text_2 = [
2726 "The capital of Brazil is Brasilia." , "The capital of France is Paris."
@@ -45,8 +44,7 @@ async def test_text_1_str_text_2_list(server: RemoteOpenAIServer,
4544
4645@pytest .mark .asyncio
4746@pytest .mark .parametrize ("model_name" , [MODEL_NAME ])
48- async def test_text_1_list_text_2_list (server : RemoteOpenAIServer ,
49- model_name : str ):
47+ def test_text_1_list_text_2_list (server : RemoteOpenAIServer , model_name : str ):
5048 text_1 = [
5149 "What is the capital of the United States?" ,
5250 "What is the capital of France?"
@@ -73,8 +71,7 @@ async def test_text_1_list_text_2_list(server: RemoteOpenAIServer,
7371
7472@pytest .mark .asyncio
7573@pytest .mark .parametrize ("model_name" , [MODEL_NAME ])
76- async def test_text_1_str_text_2_str (server : RemoteOpenAIServer ,
77- model_name : str ):
74+ def test_text_1_str_text_2_str (server : RemoteOpenAIServer , model_name : str ):
7875 text_1 = "What is the capital of France?"
7976 text_2 = "The capital of France is Paris."
8077
@@ -91,3 +88,41 @@ async def test_text_1_str_text_2_str(server: RemoteOpenAIServer,
9188 assert score .data is not None
9289 assert len (score .data ) == 1
9390 assert score .data [0 ].score >= 0.9
91+
92+
93+ @pytest .mark .asyncio
94+ @pytest .mark .parametrize ("model_name" , [MODEL_NAME ])
95+ def test_score_max_model_len (model_name : str ):
96+
97+ args = ["--enforce-eager" , "--max-model-len" , "5" ]
98+
99+ with RemoteOpenAIServer (model_name , args ) as remote_server :
100+
101+ text_1 = "What is the capital of France?"
102+ text_2 = [
103+ "The capital of Brazil is Brasilia." ,
104+ "The capital of France is Paris."
105+ ]
106+
107+ score_response = requests .post (remote_server .url_for ("score" ),
108+ json = {
109+ "model" : model_name ,
110+ "text_1" : text_1 ,
111+ "text_2" : text_2 ,
112+ })
113+ assert score_response .status_code == 400
114+ # Assert just a small fragments of the response
115+ assert "Please reduce the length of the input." in \
116+ score_response .text
117+
118+ # Test truncation
119+ score_response = requests .post (remote_server .url_for ("score" ),
120+ json = {
121+ "model" : model_name ,
122+ "text_1" : text_1 ,
123+ "text_2" : text_2 ,
124+ "truncate_prompt_tokens" : 10
125+ })
126+ assert score_response .status_code == 400
127+ assert "Please, select a smaller truncation size." in \
128+ score_response .text
0 commit comments