def test_prepare_chat_with_tools_tool_required():
    """Test that tool_required is correctly passed to the API request when True."""
    llm = Anthropic()

    # Test with tool_required=True
    result = llm._prepare_chat_with_tools(tools=[search_tool], tool_required=True)

    assert result["tool_choice"]["type"] == "any"
    assert len(result["tools"]) == 1
    assert result["tools"][0]["name"] == "search_tool"
Test that tool_required is correctly passed to the API request when True.
llama-index-integrations/llms/llama-index-llms-anthropic/tests/test_llms_anthropic.py