mirror of
https://github.com/hwchase17/langchain.git
synced 2026-02-21 14:43:07 +00:00
Code review
This commit is contained in:
@@ -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()")
|
||||
|
||||
Reference in New Issue
Block a user