Skip to content

Commit 5c8209d

Browse files
committed
[fix] convert key-type error in test script
1 parent 182a075 commit 5c8209d

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

tests/python/serve/server/test_server_structural_tag.py

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import json
1212
import os
1313
import re
14-
from typing import Dict, List, Optional, Tuple
14+
from typing import Dict, List, Optional
1515

1616
import pytest
1717
import requests
@@ -20,13 +20,13 @@
2020

2121

2222
def check_openai_nonstream_response(
23-
response: Dict,
24-
*,
25-
model: str,
26-
object_str: str,
27-
num_choices: int,
28-
finish_reason: List[str],
29-
completion_tokens: Optional[int] = None,
23+
response: Dict,
24+
*,
25+
model: str,
26+
object_str: str,
27+
num_choices: int,
28+
finish_reason: List[str],
29+
completion_tokens: Optional[int] = None,
3030
):
3131
assert response["model"] == model
3232
assert response["object"] == object_str
@@ -68,16 +68,16 @@ def check_openai_nonstream_response(
6868

6969

7070
def check_openai_stream_response(
71-
responses: List[Dict],
72-
*,
73-
model: str,
74-
object_str: str,
75-
num_choices: int,
76-
finish_reason: str,
77-
echo_prompt: Optional[str] = None,
78-
suffix: Optional[str] = None,
79-
stop: Optional[List[str]] = None,
80-
require_substr: Optional[List[str]] = None,
71+
responses: List[Dict],
72+
*,
73+
model: str,
74+
object_str: str,
75+
num_choices: int,
76+
finish_reason: str,
77+
echo_prompt: Optional[str] = None,
78+
suffix: Optional[str] = None,
79+
stop: Optional[List[str]] = None,
80+
require_substr: Optional[List[str]] = None,
8181
):
8282
assert len(responses) > 0
8383

@@ -219,7 +219,6 @@ def check_format(name_beg: str, name_end: str, beg_tag: str, schema: str):
219219
You are a helpful assistant.""",
220220
}
221221

222-
223222
STRUCTURAL_TAGS = {
224223
"triggers": ["<CALL--->", "<call--->"],
225224
"tags": [
@@ -236,14 +235,14 @@ def check_format(name_beg: str, name_end: str, beg_tag: str, schema: str):
236235
"state": {
237236
"type": "string",
238237
"description": "the two-letter abbreviation for the state that the city is"
239-
" in, e.g. 'CA' which would mean 'California'",
238+
" in, e.g. 'CA' which would mean 'California'",
240239
},
241240
"unit": {
242241
"type": "string",
243242
"description": "The unit to fetch the temperature in",
244243
"enum": ["celsius", "fahrenheit"],
245244
},
246-
"hash_code": {"const": 1234},
245+
"hash_code": {"const": "1234"},
247246
},
248247
"required": ["city", "state", "unit", "hash_code"],
249248
}
@@ -260,7 +259,7 @@ def check_format(name_beg: str, name_end: str, beg_tag: str, schema: str):
260259
"type": "string",
261260
"description": "The timezone to fetch the current date and time for, e.g. 'America/New_York'",
262261
},
263-
"hash_code": {"const": 2345},
262+
"hash_code": {"const": "2345"},
264263
},
265264
"required": ["timezone", "hash_code"],
266265
}
@@ -280,14 +279,14 @@ def check_format(name_beg: str, name_end: str, beg_tag: str, schema: str):
280279
"state": {
281280
"type": "string",
282281
"description": "the two-letter abbreviation for the state that the city is"
283-
" in, e.g. 'CA' which would mean 'California'",
282+
" in, e.g. 'CA' which would mean 'California'",
284283
},
285284
"unit": {
286285
"type": "string",
287286
"description": "The unit to fetch the temperature in",
288287
"enum": ["celsius", "fahrenheit"],
289288
},
290-
"hash_code": {"const": 3456},
289+
"hash_code": {"const": "3456"},
291290
},
292291
"required": ["city", "state", "unit", "hash_code"],
293292
}
@@ -304,7 +303,7 @@ def check_format(name_beg: str, name_end: str, beg_tag: str, schema: str):
304303
"type": "string",
305304
"description": "The timezone to fetch the current date and time for, e.g. 'America/New_York'",
306305
},
307-
"hash_code": {"const": 4567},
306+
"hash_code": {"const": "4567"},
308307
},
309308
"required": ["timezone", "hash_code"],
310309
}
@@ -315,29 +314,28 @@ def check_format(name_beg: str, name_end: str, beg_tag: str, schema: str):
315314
}
316315

317316
CHECK_INFO = {
318-
1234: {
317+
"1234": {
319318
"name": "get_current_weather",
320319
"beg_tag": "CALL",
321320
"required": ["city", "state", "unit", "hash_code"],
322321
},
323-
2345: {
322+
"2345": {
324323
"name": "get_current_date",
325324
"beg_tag": "CALL",
326325
"required": ["timezone", "hash_code"],
327326
},
328-
3456: {
327+
"3456": {
329328
"name": "get_current_weather",
330329
"beg_tag": "call",
331330
"required": ["city", "state", "unit", "hash_code"],
332331
},
333-
4567: {
332+
"4567": {
334333
"name": "get_current_date",
335334
"beg_tag": "call",
336335
"required": ["timezone", "hash_code"],
337336
},
338337
}
339338

340-
341339
CHAT_COMPLETION_MESSAGES = [
342340
# messages #0
343341
[
@@ -369,10 +367,10 @@ def check_format(name_beg: str, name_end: str, beg_tag: str, schema: str):
369367
@pytest.mark.parametrize("stream", [False, True])
370368
@pytest.mark.parametrize("messages", CHAT_COMPLETION_MESSAGES)
371369
def test_openai_v1_chat_completion_structural_tag(
372-
served_model: str,
373-
launch_server, # pylint: disable=unused-argument
374-
stream: bool,
375-
messages: List[Dict[str, str]],
370+
served_model: str,
371+
launch_server, # pylint: disable=unused-argument
372+
stream: bool,
373+
messages: List[Dict[str, str]],
376374
):
377375
# `served_model` and `launch_server` are pytest fixtures
378376
# defined in conftest.py.

0 commit comments

Comments
 (0)