mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-10 19:35:22 +08:00
Signed-off-by: Andrew Xia <axia@fb.com> Co-authored-by: Andrew Xia <axia@fb.com> Co-authored-by: Chauncey <chaunceyjiang@gmail.com>
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
|
|
from vllm.entrypoints.responses_utils import (
|
|
convert_tool_responses_to_completions_format,
|
|
)
|
|
|
|
|
|
class TestResponsesUtils:
|
|
"""Tests for convert_tool_responses_to_completions_format function."""
|
|
|
|
def test_convert_tool_responses_to_completions_format(self):
|
|
"""Test basic conversion of a flat tool schema to nested format."""
|
|
input_tool = {
|
|
"type": "function",
|
|
"name": "get_weather",
|
|
"description": "Get the current weather in a given location",
|
|
"parameters": {
|
|
"type": "object",
|
|
"properties": {
|
|
"location": {"type": "string"},
|
|
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
|
|
},
|
|
"required": ["location", "unit"],
|
|
},
|
|
}
|
|
|
|
result = convert_tool_responses_to_completions_format(input_tool)
|
|
|
|
assert result == {"type": "function", "function": input_tool}
|