-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use_tools: accept a variadic list of
Tool
(#374)
Co-authored-by: aisi-inspect <[email protected]>
- Loading branch information
1 parent
5b7f186
commit 9faa2c7
Showing
3 changed files
with
58 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from typing import Literal | ||
|
||
import pytest | ||
from test_helpers.tools import addition, read_file | ||
from test_helpers.utils import simple_task_state | ||
from typing_extensions import Unpack | ||
|
||
from inspect_ai.model import CachePolicy, GenerateConfigArgs | ||
from inspect_ai.solver import TaskState, use_tools | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_use_tools(): | ||
def generate( | ||
state: TaskState, | ||
tool_calls: Literal["loop", "single", "none"] = "loop", | ||
cache: bool | CachePolicy = False, | ||
**kwargs: Unpack[GenerateConfigArgs], | ||
) -> TaskState: | ||
return state | ||
|
||
state = simple_task_state() | ||
|
||
addition_tool = addition() | ||
read_file_tool = read_file() | ||
|
||
state = await (use_tools([addition_tool, read_file_tool]))(state, generate) | ||
assert state.tools == [addition_tool, read_file_tool] | ||
|
||
state = await (use_tools([addition_tool, read_file_tool]))(state, generate) | ||
assert state.tools == [addition_tool, read_file_tool] | ||
|
||
state = await (use_tools(addition_tool, read_file_tool))(state, generate) | ||
assert state.tools == [addition_tool, read_file_tool] | ||
|
||
state = await (use_tools([addition_tool]))(state, generate) | ||
assert state.tools == [addition_tool] | ||
|
||
state = await (use_tools(addition_tool))(state, generate) | ||
assert state.tools == [addition_tool] | ||
|
||
state = await (use_tools(tool_choice="auto"))(state, generate) | ||
assert state.tools == [addition_tool] | ||
assert state.tool_choice == "auto" |