mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 00:58:30 +00:00
fix: use unquoted type names in model descriptions
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -327,9 +327,9 @@ def generate_model_description(model: Type[BaseModel]) -> str:
|
|||||||
elif isinstance(field_type, type) and issubclass(field_type, BaseModel):
|
elif isinstance(field_type, type) and issubclass(field_type, BaseModel):
|
||||||
return generate_model_description(field_type)
|
return generate_model_description(field_type)
|
||||||
elif hasattr(field_type, "__name__"):
|
elif hasattr(field_type, "__name__"):
|
||||||
return f'"{field_type.__name__}"'
|
return field_type.__name__
|
||||||
else:
|
else:
|
||||||
return f'"{str(field_type)}"'
|
return str(field_type)
|
||||||
|
|
||||||
fields = model.model_fields
|
fields = model.model_fields
|
||||||
field_descriptions = []
|
field_descriptions = []
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ def test_generate_model_description_with_empty_description():
|
|||||||
age: int = Field(..., description=None)
|
age: int = Field(..., description=None)
|
||||||
|
|
||||||
description = generate_model_description(ModelWithEmptyDescription)
|
description = generate_model_description(ModelWithEmptyDescription)
|
||||||
expected = '{\n "name": "str",\n "age": "int"\n}'
|
expected = '{\n "name": str,\n "age": int\n}'
|
||||||
assert description == expected
|
assert description == expected
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user