fix(test): no need to specify tool prompt format explicitly in tests (#1295)

# What does this PR do?

No need to have complex tool prompt format related machinery in the
tests.

[//]: # (If resolving an issue, uncomment and update the line below)
[//]: # (Closes #[issue-number])

## Test Plan

```bash
LLAMA_STACK_CONFIG=ollama pytest -s -v tests/client-sdk/inference/test_text_inference.py --inference-model=meta-llama/Llama-3.2-3B-Instruct --vision-inference-model=""
```

[//]: # (## Documentation)
This commit is contained in:
Ashwin Bharambe 2025-02-27 10:09:57 -08:00 committed by GitHub
parent fc5aff3ccf
commit 981fc3c93c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,7 +9,6 @@ from pydantic import BaseModel
from llama_stack.models.llama.sku_list import resolve_model from llama_stack.models.llama.sku_list import resolve_model
from llama_stack.providers.tests.test_cases.test_case import TestCase from llama_stack.providers.tests.test_cases.test_case import TestCase
from llama_stack.providers.utils.inference.prompt_adapter import get_default_tool_prompt_format
PROVIDER_LOGPROBS_TOP_K = {"remote::together", "remote::fireworks", "remote::vllm"} PROVIDER_LOGPROBS_TOP_K = {"remote::together", "remote::fireworks", "remote::vllm"}
@ -40,13 +39,6 @@ def get_llama_model(client_with_models, model_id):
return model.metadata.get("llama_model", None) return model.metadata.get("llama_model", None)
def get_tool_prompt_format(client_with_models, model_id):
llama_model = get_llama_model(client_with_models, model_id)
if not llama_model:
return None
return get_default_tool_prompt_format(llama_model)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"test_case", "test_case",
[ [
@ -247,7 +239,6 @@ def test_text_chat_completion_streaming(client_with_models, text_model_id, test_
], ],
) )
def test_text_chat_completion_with_tool_calling_and_non_streaming(client_with_models, text_model_id, test_case): def test_text_chat_completion_with_tool_calling_and_non_streaming(client_with_models, text_model_id, test_case):
tool_prompt_format = get_tool_prompt_format(client_with_models, text_model_id)
tc = TestCase(test_case) tc = TestCase(test_case)
response = client_with_models.inference.chat_completion( response = client_with_models.inference.chat_completion(
@ -255,7 +246,6 @@ def test_text_chat_completion_with_tool_calling_and_non_streaming(client_with_mo
messages=tc["messages"], messages=tc["messages"],
tools=tc["tools"], tools=tc["tools"],
tool_choice="auto", tool_choice="auto",
tool_prompt_format=tool_prompt_format,
stream=False, stream=False,
) )
# some models can return content for the response in addition to the tool call # some models can return content for the response in addition to the tool call
@ -286,7 +276,6 @@ def extract_tool_invocation_content(response):
], ],
) )
def test_text_chat_completion_with_tool_calling_and_streaming(client_with_models, text_model_id, test_case): def test_text_chat_completion_with_tool_calling_and_streaming(client_with_models, text_model_id, test_case):
tool_prompt_format = get_tool_prompt_format(client_with_models, text_model_id)
tc = TestCase(test_case) tc = TestCase(test_case)
response = client_with_models.inference.chat_completion( response = client_with_models.inference.chat_completion(
@ -294,7 +283,6 @@ def test_text_chat_completion_with_tool_calling_and_streaming(client_with_models
messages=tc["messages"], messages=tc["messages"],
tools=tc["tools"], tools=tc["tools"],
tool_choice="auto", tool_choice="auto",
tool_prompt_format=tool_prompt_format,
stream=True, stream=True,
) )
tool_invocation_content = extract_tool_invocation_content(response) tool_invocation_content = extract_tool_invocation_content(response)
@ -310,8 +298,6 @@ def test_text_chat_completion_with_tool_calling_and_streaming(client_with_models
], ],
) )
def test_text_chat_completion_with_tool_choice_required(client_with_models, text_model_id, test_case): def test_text_chat_completion_with_tool_choice_required(client_with_models, text_model_id, test_case):
tool_prompt_format = get_tool_prompt_format(client_with_models, text_model_id)
tc = TestCase(test_case) tc = TestCase(test_case)
response = client_with_models.inference.chat_completion( response = client_with_models.inference.chat_completion(
@ -320,7 +306,6 @@ def test_text_chat_completion_with_tool_choice_required(client_with_models, text
tools=tc["tools"], tools=tc["tools"],
tool_config={ tool_config={
"tool_choice": "required", "tool_choice": "required",
"tool_prompt_format": tool_prompt_format,
}, },
stream=True, stream=True,
) )
@ -337,14 +322,13 @@ def test_text_chat_completion_with_tool_choice_required(client_with_models, text
], ],
) )
def test_text_chat_completion_with_tool_choice_none(client_with_models, text_model_id, test_case): def test_text_chat_completion_with_tool_choice_none(client_with_models, text_model_id, test_case):
tool_prompt_format = get_tool_prompt_format(client_with_models, text_model_id)
tc = TestCase(test_case) tc = TestCase(test_case)
response = client_with_models.inference.chat_completion( response = client_with_models.inference.chat_completion(
model_id=text_model_id, model_id=text_model_id,
messages=tc["messages"], messages=tc["messages"],
tools=tc["tools"], tools=tc["tools"],
tool_config={"tool_choice": "none", "tool_prompt_format": tool_prompt_format}, tool_config={"tool_choice": "none"},
stream=True, stream=True,
) )
tool_invocation_content = extract_tool_invocation_content(response) tool_invocation_content = extract_tool_invocation_content(response)