mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-30 08:42:00 +00:00 
			
		
		
		
	server : clean up built-in template detection (#11026)
* server : clean up built-in template detection * fix compilation * add chat template test * fix condition
This commit is contained in:
		| @@ -100,6 +100,23 @@ def test_chat_completion_with_openai_library(): | ||||
|     assert match_regex("(Suddenly)+", res.choices[0].message.content) | ||||
|  | ||||
|  | ||||
| def test_chat_template(): | ||||
|     global server | ||||
|     server.chat_template = "llama3" | ||||
|     server.debug = True  # to get the "__verbose" object in the response | ||||
|     server.start() | ||||
|     res = server.make_request("POST", "/chat/completions", data={ | ||||
|         "max_tokens": 8, | ||||
|         "messages": [ | ||||
|             {"role": "system", "content": "Book"}, | ||||
|             {"role": "user", "content": "What is the best book"}, | ||||
|         ] | ||||
|     }) | ||||
|     assert res.status_code == 200 | ||||
|     assert "__verbose" in res.body | ||||
|     assert res.body["__verbose"]["prompt"] == "<s> <|start_header_id|>system<|end_header_id|>\n\nBook<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nWhat is the best book<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n" | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize("response_format,n_predicted,re_content", [ | ||||
|     ({"type": "json_object", "schema": {"const": "42"}}, 6, "\"42\""), | ||||
|     ({"type": "json_object", "schema": {"items": [{"type": "integer"}]}}, 10, "[ -3000 ]"), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Xuan Son Nguyen
					Xuan Son Nguyen