-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_openai.py
More file actions
28 lines (20 loc) · 910 Bytes
/
test_openai.py
File metadata and controls
28 lines (20 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pytest
from thirdweb_ai.tools.tool import Tool
def test_get_openai_tools(test_tools: list[Tool]):
"""Test converting thirdweb tools to OpenAI tools."""
pytest.importorskip("openai")
from agents import FunctionTool
from thirdweb_ai.adapters.openai import get_openai_tools
# Convert tools to OpenAI tools
openai_tools = get_openai_tools(test_tools)
# Assert we got the correct number of tools
assert len(openai_tools) == len(test_tools)
# Check all required properties exist in the tools
for i, tool in enumerate(openai_tools):
assert isinstance(tool, FunctionTool)
assert hasattr(tool, "name")
assert hasattr(tool, "description")
assert hasattr(tool, "params_json_schema")
# Check name and description match
assert tool.name == test_tools[i].name
assert tool.description == test_tools[i].description