mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
Litellm dev 01 01 2025 p3 (#7503)
* fix(utils.py): add new validate tool choice helper function Prevents https://github.com/BerriAI/litellm/issues/7483 * fix(main.py): add tool choice validation on .completion() prevents user error like - https://github.com/BerriAI/litellm/issues/7483 * fix(utils.py): fix return val of tool choice validation logic
This commit is contained in:
parent
f96f54a0f5
commit
45b93f2721
3 changed files with 51 additions and 0 deletions
|
@ -1085,6 +1085,26 @@ def test_validate_chat_completion_user_messages(messages, expected_bool):
|
|||
validate_chat_completion_user_messages(messages=messages)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"tool_choice, expected_bool",
|
||||
[
|
||||
({"type": "function", "function": {"name": "get_current_weather"}}, True),
|
||||
({"type": "tool", "name": "get_current_weather"}, False),
|
||||
(None, True),
|
||||
("auto", True),
|
||||
("required", True),
|
||||
],
|
||||
)
|
||||
def test_validate_chat_completion_tool_choice(tool_choice, expected_bool):
|
||||
from litellm.utils import validate_chat_completion_tool_choice
|
||||
|
||||
if expected_bool:
|
||||
validate_chat_completion_tool_choice(tool_choice=tool_choice)
|
||||
else:
|
||||
with pytest.raises(Exception):
|
||||
validate_chat_completion_tool_choice(tool_choice=tool_choice)
|
||||
|
||||
|
||||
def test_models_by_provider():
|
||||
"""
|
||||
Make sure all providers from model map are in the valid providers list
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue