From 7b633b094f1984b7976a86b501be6c0641e5a4b2 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Wed, 27 Mar 2024 17:17:59 +0100 Subject: [PATCH] Code review --- .../unit_tests/utils/test_function_calling.py | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libs/core/tests/unit_tests/utils/test_function_calling.py b/libs/core/tests/unit_tests/utils/test_function_calling.py index cbae44c5e09..6731cc4e432 100644 --- a/libs/core/tests/unit_tests/utils/test_function_calling.py +++ b/libs/core/tests/unit_tests/utils/test_function_calling.py @@ -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()")