@@ -47,3 +47,28 @@ def test_date_inside_prompt(template_name: str, format: str, tools: list[dict]):
47
47
48
48
today_str = datetime .date .today ().strftime (format )
49
49
assert today_str in prompt , f"Expected today's date ({ today_str } ) in content ({ prompt } )"
50
+
51
+
52
+ @pytest .mark .parametrize ("add_generation_prompt" , [False , True ])
53
+ @pytest .mark .parametrize ("template_name,expected_generation_prompt" , [
54
+ ("meta-llama-Llama-3.3-70B-Instruct" , "<|start_header_id|>assistant<|end_header_id|>" ),
55
+ ])
56
+ def test_add_generation_prompt (template_name : str , expected_generation_prompt : str , add_generation_prompt : bool ):
57
+ global server
58
+ server .jinja = True
59
+ server .chat_template_file = f'../../../models/templates/{ template_name } .jinja'
60
+ server .start (timeout_seconds = TIMEOUT_SERVER_START )
61
+
62
+ res = server .make_request ("POST" , "/apply-template" , data = {
63
+ "messages" : [
64
+ {"role" : "user" , "content" : "What is today?" },
65
+ ],
66
+ "add_generation_prompt" : add_generation_prompt ,
67
+ })
68
+ assert res .status_code == 200
69
+ prompt = res .body ["prompt" ]
70
+
71
+ if add_generation_prompt :
72
+ assert expected_generation_prompt in prompt , f"Expected generation prompt ({ expected_generation_prompt } ) in content ({ prompt } )"
73
+ else :
74
+ assert expected_generation_prompt not in prompt , f"Did not expect generation prompt ({ expected_generation_prompt } ) in content ({ prompt } )"
0 commit comments