-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from Forethought-Technologies/feat/yi/tool_desp
Allow adding tool description using arg_description in Tool for function calling using openai
- Loading branch information
Showing
5 changed files
with
163 additions
and
9 deletions.
There are no files selected for viewing
3 changes: 1 addition & 2 deletions
3
autochain/agent/openai_funtions_agent/openai_functions_agent.py
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
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,47 @@ | ||
import pytest | ||
|
||
from autochain.tools.base import Tool | ||
|
||
|
||
def sample_tool_func(k, *arg, **kwargs): | ||
return f"run with {k}" | ||
|
||
|
||
def test_run_tool(): | ||
tool = Tool( | ||
func=sample_tool_func, | ||
description="""This is just a dummy tool""", | ||
) | ||
|
||
output = tool.run("test") | ||
assert output == "run with test" | ||
|
||
|
||
def test_tool_name_override(): | ||
new_test_name = "new_name" | ||
tool = Tool( | ||
name=new_test_name, | ||
func=sample_tool_func, | ||
description="""This is just a dummy tool""", | ||
) | ||
|
||
assert tool.name == new_test_name | ||
|
||
|
||
def test_arg_description(): | ||
valid_arg_description = {"k": "key of the arg"} | ||
|
||
invalid_arg_description = {"not_k": "key of the arg"} | ||
|
||
_ = Tool( | ||
func=sample_tool_func, | ||
description="""This is just a dummy tool""", | ||
arg_description=valid_arg_description, | ||
) | ||
|
||
with pytest.raises(ValueError): | ||
_ = Tool( | ||
func=sample_tool_func, | ||
description="""This is just a dummy tool""", | ||
arg_description=invalid_arg_description, | ||
) |