@@ -227,27 +227,28 @@ def test_chat_completion_with_timings_per_token():
227227
228228
229229@pytest .mark .parametrize ("template_name,tool,argument_key" , [
230+ # TODO: fix special handling of python tool for these templates:
230231 ("meetkai-functionary-medium-v3.1" , TEST_TOOL , "success" ),
231- ("meetkai-functionary-medium-v3.1" , PYTHON_TOOL , None ),
232+ ("meetkai-functionary-medium-v3.1" , PYTHON_TOOL , None ), # "code"), # TODO: fix
232233 ("meetkai-functionary-medium-v3.1" , CODE_INTEPRETER_TOOL , None ),
233234 ("meetkai-functionary-medium-v3.2" , TEST_TOOL , "success" ),
234- ("meetkai-functionary-medium-v3.2" , PYTHON_TOOL , None ),
235+ ("meetkai-functionary-medium-v3.2" , PYTHON_TOOL , "code" ),
235236 ("meetkai-functionary-medium-v3.2" , CODE_INTEPRETER_TOOL , None ),
236237 ("NousResearch-Hermes-2-Pro-Llama-3-8B-tool_use" , TEST_TOOL , "success" ),
237- ("NousResearch-Hermes-2-Pro-Llama-3-8B-tool_use" , PYTHON_TOOL , None ),
238+ ("NousResearch-Hermes-2-Pro-Llama-3-8B-tool_use" , PYTHON_TOOL , "code" ),
238239 ("NousResearch-Hermes-2-Pro-Llama-3-8B-tool_use" , CODE_INTEPRETER_TOOL , None ),
240+ ("meta-llama-Llama-3.2-3B-Instruct" , TEST_TOOL , "success" ),
241+ ("meta-llama-Llama-3.2-3B-Instruct" , PYTHON_TOOL , "code" ),
242+ ("meta-llama-Llama-3.2-3B-Instruct" , CODE_INTEPRETER_TOOL , None ),
243+ ("mistralai-Mistral-Nemo-Instruct-2407" , TEST_TOOL , "success" ),
244+ ("mistralai-Mistral-Nemo-Instruct-2407" , PYTHON_TOOL , "code" ),
245+ ("mistralai-Mistral-Nemo-Instruct-2407" , CODE_INTEPRETER_TOOL , None ),
239246 ("NousResearch-Hermes-3-Llama-3.1-8B-tool_use" , TEST_TOOL , "success" ),
240- ("NousResearch-Hermes-3-Llama-3.1-8B-tool_use" , PYTHON_TOOL , None ),
247+ ("NousResearch-Hermes-3-Llama-3.1-8B-tool_use" , PYTHON_TOOL , None ), # "code"), # TODO: fix
241248 ("NousResearch-Hermes-3-Llama-3.1-8B-tool_use" , CODE_INTEPRETER_TOOL , None ),
242249 ("meta-llama-Meta-Llama-3.1-8B-Instruct" , TEST_TOOL , "success" ),
243- ("meta-llama-Meta-Llama-3.1-8B-Instruct" , PYTHON_TOOL , None ),
250+ ("meta-llama-Meta-Llama-3.1-8B-Instruct" , PYTHON_TOOL , None ), # "code"), # TODO: fix
244251 ("meta-llama-Meta-Llama-3.1-8B-Instruct" , CODE_INTEPRETER_TOOL , None ),
245- ("meta-llama-Llama-3.2-3B-Instruct" , TEST_TOOL , "success" ),
246- ("meta-llama-Llama-3.2-3B-Instruct" , PYTHON_TOOL , None ),
247- # # ("meta-llama-Llama-3.2-3B-Instruct", CODE_INTEPRETER_TOOL, None),
248- ("mistralai-Mistral-Nemo-Instruct-2407" , TEST_TOOL , "success" ),
249- ("mistralai-Mistral-Nemo-Instruct-2407" , PYTHON_TOOL , None ),
250- ("mistralai-Mistral-Nemo-Instruct-2407" , CODE_INTEPRETER_TOOL , None ),
251252])
252253def test_completion_with_required_tool (template_name : str , tool : dict , argument_key : str | None ):
253254 n_predict = 512
@@ -320,6 +321,15 @@ def test_completion_without_tool_call(template_name: str, n_predict: int, tools:
320321
321322@pytest .mark .slow
322323@pytest .mark .parametrize ("tool,expected_arguments,hf_repo,hf_file,template_override" , [
324+ # TODO: fix these models
325+ # (PYTHON_TOOL, {"code": "print('Hello, World!')"}, "bartowski/functionary-small-v3.2-GGUF", "functionary-small-v3.2-Q8_0.gguf", ("meetkai-functionary-medium-v3.2", None)),
326+ # (CODE_INTEPRETER_TOOL, {"code": "print('Hello, World!')"}, "bartowski/functionary-small-v3.2-GGUF", "functionary-small-v3.2-Q8_0.gguf", ("meetkai-functionary-medium-v3.2", None)),
327+ # # (PYTHON_TOOL, {"code": "print(\"Hello, World!\")"}, "bartowski/Llama-3.2-1B-Instruct-GGUF", "Llama-3.2-1B-Instruct-Q4_K_M.gguf", ("meta-llama-Llama-3.2-3B-Instruct", None)),
328+ # # (CODE_INTEPRETER_TOOL, {"code": "print(\"Hello, World!\")"}, "bartowski/Llama-3.2-1B-Instruct-GGUF", "Llama-3.2-1B-Instruct-Q4_K_M.gguf", ("meta-llama-Llama-3.2-3B-Instruct", None)),
329+ # (PYTHON_TOOL, {"code": "print("}, "bartowski/Llama-3.2-3B-Instruct-GGUF", "Llama-3.2-3B-Instruct-Q4_K_M.gguf", ("meta-llama-Llama-3.2-3B-Instruct", None)),
330+ # (CODE_INTEPRETER_TOOL, {"code": "print("}, "bartowski/Llama-3.2-3B-Instruct-GGUF", "Llama-3.2-3B-Instruct-Q4_K_M.gguf", ("meta-llama-Llama-3.2-3B-Instruct", None)),
331+ # (PYTHON_TOOL, {"code": "print(\"hello world\")"}, "lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF", "Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf", None),
332+ # (CODE_INTEPRETER_TOOL, {"code": "print("}, "lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF", "Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf", None),
323333 (PYTHON_TOOL , {"code" : "print('Hello, World!')" }, "bartowski/gemma-2-2b-it-GGUF" , "gemma-2-2b-it-Q4_K_M.gguf" , None ),
324334 (CODE_INTEPRETER_TOOL , {"code" : "print('Hello, World!')" }, "bartowski/gemma-2-2b-it-GGUF" , "gemma-2-2b-it-Q4_K_M.gguf" , None ),
325335 (PYTHON_TOOL , {"code" : "print('Hello, World!')" }, "bartowski/Phi-3.5-mini-instruct-GGUF" , "Phi-3.5-mini-instruct-Q4_K_M.gguf" , None ),
@@ -330,21 +340,12 @@ def test_completion_without_tool_call(template_name: str, n_predict: int, tools:
330340 (CODE_INTEPRETER_TOOL , {"code" : "print('Hello, world!')" }, "NousResearch/Hermes-2-Pro-Llama-3-8B-GGUF" , "Hermes-2-Pro-Llama-3-8B-Q4_K_M.gguf" , ("NousResearch-Hermes-2-Pro-Llama-3-8B" , "tool_use" )),
331341 (PYTHON_TOOL , {"code" : "print('Hello World!')" }, "NousResearch/Hermes-3-Llama-3.1-8B-GGUF" , "Hermes-3-Llama-3.1-8B.Q4_K_M.gguf" , ("NousResearch-Hermes-3-Llama-3.1-8B" , "tool_use" )),
332342 (CODE_INTEPRETER_TOOL , {"code" : "print('Hello World!')" }, "NousResearch/Hermes-3-Llama-3.1-8B-GGUF" , "Hermes-3-Llama-3.1-8B.Q4_K_M.gguf" , ("NousResearch-Hermes-3-Llama-3.1-8B" , "tool_use" )),
333- (PYTHON_TOOL , {"code" : "print(\" Hello, World!\" )" }, "bartowski/Llama-3.2-1B-Instruct-GGUF" , "Llama-3.2-1B-Instruct-Q4_K_M.gguf" , ("meta-llama-Llama-3.2-3B-Instruct" , None )),
334- (CODE_INTEPRETER_TOOL , {"code" : "print(\" Hello, World!\" )" }, "bartowski/Llama-3.2-1B-Instruct-GGUF" , "Llama-3.2-1B-Instruct-Q4_K_M.gguf" , ("meta-llama-Llama-3.2-3B-Instruct" , None )),
335- (PYTHON_TOOL , {"code" : "print(" }, "bartowski/Llama-3.2-3B-Instruct-GGUF" , "Llama-3.2-3B-Instruct-Q4_K_M.gguf" , ("meta-llama-Llama-3.2-3B-Instruct" , None )),
336- (CODE_INTEPRETER_TOOL , {"code" : "print(" }, "bartowski/Llama-3.2-3B-Instruct-GGUF" , "Llama-3.2-3B-Instruct-Q4_K_M.gguf" , ("meta-llama-Llama-3.2-3B-Instruct" , None )),
337- (PYTHON_TOOL , {"code" : "print(\" hello world\" )" }, "lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF" , "Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf" , None ),
338- (CODE_INTEPRETER_TOOL , {"code" : "print(" }, "lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF" , "Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf" , None ),
339343 (PYTHON_TOOL , {"code" : "print('Hello, World!')\n " }, "bartowski/Mistral-Nemo-Instruct-2407-GGUF" , "Mistral-Nemo-Instruct-2407-Q6_K_L.gguf" , None ),
340344 (CODE_INTEPRETER_TOOL , {"code" : "print('Hello, World!')\n " }, "bartowski/Mistral-Nemo-Instruct-2407-GGUF" , "Mistral-Nemo-Instruct-2407-Q6_K_L.gguf" , ("mistralai-Mistral-Nemo-Instruct-2407" , None )),
341- # TODO: fix this model
342- # (PYTHON_TOOL, {"code": "print('Hello, World!')"}, "bartowski/functionary-small-v3.2-GGUF", "functionary-small-v3.2-Q8_0.gguf", ("meetkai-functionary-medium-v3.2", None)),
343- # (CODE_INTEPRETER_TOOL, {"code": "print('Hello, World!')"}, "bartowski/functionary-small-v3.2-GGUF", "functionary-small-v3.2-Q8_0.gguf", ("meetkai-functionary-medium-v3.2", None)),
344345])
345346def test_hello_world_tool_call (tool : dict , expected_arguments : dict , hf_repo : str , hf_file : str , template_override : Tuple [str , str | None ] | None ):
346347 global server
347- server .n_slots = 1
348+ server .n_slots = 2
348349 server .jinja = True
349350 server .n_ctx = 8192
350351 server .n_predict = 128
@@ -359,8 +360,8 @@ def test_hello_world_tool_call(tool: dict, expected_arguments: dict, hf_repo: st
359360 "max_tokens" : 256 ,
360361 "messages" : [
361362 {"role" : "system" , "content" : "You are a coding assistant." },
362- # {"role": "user", "content": "say hello world with python"},
363- {"role" : "user" , "content" : "Print a hello world message with python" },
363+ {"role" : "user" , "content" : "say hello world with python" },
364+ # {"role": "user", "content": "Print a hello world message with python"},
364365 ],
365366 "tools" : [tool ],
366367 "temperature" : 0.5 ,
@@ -377,7 +378,8 @@ def test_hello_world_tool_call(tool: dict, expected_arguments: dict, hf_repo: st
377378 elif tool ["type" ] == "code_interpreter" :
378379 assert re .match ('i?python' , tool_call ["function" ]["name" ])
379380 actual_arguments = json .loads (tool_call ["function" ]["arguments" ])
380- assert json .dumps (expected_arguments ) == json .dumps (actual_arguments ), f"tool arguments: { json .dumps (actual_arguments )} , expected: { json .dumps (expected_arguments )} "
381+ code = actual_arguments ["code" ]
382+ assert re .match (r'''print\(("[Hh]ello,? [Ww]orld!?"|'[Hh]ello,? [Ww]orld!?')\)''' , code ), f'Expected hello world, got { code } '
381383
382384
383385def test_logprobs ():
0 commit comments