We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 875e05f commit b85dd7bCopy full SHA for b85dd7b
splunklib/ai/tool_filtering.py
@@ -22,14 +22,14 @@
22
class ToolFilters:
23
"""Allowlists by which Tools are filtered."""
24
25
- allowed_names: Sequence[str]
26
- allowed_tags: Sequence[str]
+ allowed_names: Sequence[str] | None = None
+ allowed_tags: Sequence[str] | None = None
27
28
29
def _is_allowed(tool: Tool, filters: ToolFilters) -> bool:
30
return (
31
- tool.name in filters.allowed_names
32
- or len(set(filters.allowed_tags).intersection(tool.tags or [])) > 0
+ tool.name in (filters.allowed_names or [])
+ or len(set(filters.allowed_tags or []).intersection(tool.tags or [])) > 0
33
)
34
35
tests/unit/ai/test_tools.py
@@ -49,8 +49,9 @@ async def no_op() -> ToolResult:
49
@pytest.mark.parametrize(
50
("allowed_names", "allowed_tags", "initial_tools", "expected_tools"),
51
[
52
- (["test_tool_1"], [], TEST_TOOLS, [TEST_TOOL_1]),
53
- ([], ["test_tag_2"], TEST_TOOLS, [TEST_TOOL_2, TEST_TOOL_4]),
+ (None, None, [], []),
+ (["test_tool_1"], None, TEST_TOOLS, [TEST_TOOL_1]),
54
+ (None, ["test_tag_2"], TEST_TOOLS, [TEST_TOOL_2, TEST_TOOL_4]),
55
(
56
["test_tool_1"],
57
["test_tag_2"],
@@ -61,8 +62,8 @@ async def no_op() -> ToolResult:
61
62
],
63
64
def test_filtering(
- allowed_names: Sequence[str],
65
- allowed_tags: Sequence[str],
+ allowed_names: Sequence[str] | None,
66
+ allowed_tags: Sequence[str] | None,
67
initial_tools: Sequence[Tool],
68
expected_tools: Sequence[Tool],
69
) -> None:
0 commit comments