Add tool saving test (#389)

* Add tool saving test

* Format
This commit is contained in:
Aymeric Roucher 2025-01-28 10:58:53 +01:00 committed by GitHub
parent cc21135188
commit a4f89b68b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View File

@ -14,9 +14,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import re
import base64
import pickle
import re
import textwrap
from io import BytesIO
from typing import Any, List, Tuple
@ -47,7 +47,7 @@ class E2BExecutor:
self.custom_tools = {}
self.final_answer = False
self.final_answer_pattern = re.compile(r'^final_answer\((.*)\)$')
self.final_answer_pattern = re.compile(r"^final_answer\((.*)\)$")
self.sbx = Sandbox() # "qywp2ctmu2q7jzprcf4j")
# TODO: validate installing agents package or not
# print("Installing agents package on remote executor...")

View File

@ -25,9 +25,7 @@ class MethodChecker(ast.NodeVisitor):
self.class_attributes = class_attributes
self.errors = []
self.check_imports = check_imports
self.typing_names = {
'Any'
}
self.typing_names = {"Any"}
def visit_arguments(self, node):
"""Collect function arguments"""

View File

@ -12,6 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import tempfile
import unittest
from pathlib import Path
from textwrap import dedent
@ -399,7 +400,10 @@ class ToolTests(unittest.TestCase):
"""
return
with tempfile.TemporaryDirectory() as tmp_dir:
get_weather.save(tmp_dir)
assert get_weather.inputs["location"]["type"] == "any"
assert get_weather.output_type == "null"
def test_tool_supports_array(self):
@tool