Code review

This commit is contained in:
Tat Dat Duong
2024-03-27 17:17:59 +01:00
parent e6952b4ba1
commit 7b633b094f

View File

@@ -71,21 +71,6 @@ def json_schema() -> Dict:
}
@pytest.fixture()
def json_schema_lax() -> Dict:
return {
"type": "object",
"properties": {
"arg1": {"description": "foo", "type": "integer"},
"arg2": {
"description": "one of 'bar', 'baz'",
"enum": ["bar", "baz"],
"type": "string",
},
},
}
def test_convert_to_openai_function(
pydantic: Type[BaseModel],
function: Callable,
@@ -114,7 +99,7 @@ def test_convert_to_openai_function(
assert actual == expected
def test_convert_lax_jsonschema_to_openai_function(json_schema_lax: Dict) -> None:
def test_convert_lax_jsonschema_to_openai_function() -> None:
expected = {
"name": "extract",
"description": "",
@@ -131,7 +116,22 @@ def test_convert_lax_jsonschema_to_openai_function(json_schema_lax: Dict) -> Non
},
}
assert convert_to_openai_function(json_schema_lax) == expected
assert (
convert_to_openai_function(
{
"type": "object",
"properties": {
"arg1": {"description": "foo", "type": "integer"},
"arg2": {
"description": "one of 'bar', 'baz'",
"enum": ["bar", "baz"],
"type": "string",
},
},
}
)
== expected
)
@pytest.mark.xfail(reason="Pydantic converts Optional[str] to str in .schema()")