fix: use unquoted type names in model descriptions

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-02-21 11:53:58 +00:00
parent da0d37af03
commit f80fe7d4c1
2 changed files with 3 additions and 3 deletions

View File

@@ -327,9 +327,9 @@ def generate_model_description(model: Type[BaseModel]) -> str:
elif isinstance(field_type, type) and issubclass(field_type, BaseModel):
return generate_model_description(field_type)
elif hasattr(field_type, "__name__"):
return f'"{field_type.__name__}"'
return field_type.__name__
else:
return f'"{str(field_type)}"'
return str(field_type)
fields = model.model_fields
field_descriptions = []

View File

@@ -369,7 +369,7 @@ def test_generate_model_description_with_empty_description():
age: int = Field(..., description=None)
description = generate_model_description(ModelWithEmptyDescription)
expected = '{\n "name": "str",\n "age": "int"\n}'
expected = '{\n "name": str,\n "age": int\n}'
assert description == expected