Code review

pull/19656/head
Tat Dat Duong 3 months ago
parent e6952b4ba1
commit 7b633b094f

@ -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()")

Loading…
Cancel
Save