mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-05 17:22:36 +00:00
This fails before the PR and succeeds afterward:
```python
from pydantic import BaseModel
from typing import List, Optional
from crewai.utilities.pydantic_schema_parser import PydanticSchemaParser
class InnerModel(BaseModel):
inner_field: int
class TestModel(BaseModel):
simple_field: str
list_field: List[int]
optional_field: Optional[str]
nested_model: InnerModel
print(PydanticSchemaParser(model=InnerModel).get_schema()) # works
print(PydanticSchemaParser(model=TestModel).get_schema()) # fails
```
**Note.** Because the `main` branch currently doesn't support nested
schemas and the original code against which I made this PR months ago
drifted, I made a judgement call on how to format the nested
structurees. I chose the following, inferred from the current code:
````
>>> print(PydanticSchemaParser(model=InnerModel).get_schema())
{
inner_field: int
}
>>> print(PydanticSchemaParser(model=TestModel).get_schema())
{
simple_field: str,
list_field: List[int],
optional_field: Optional[str],
nested_model: InnerModel
{
inner_field: int
}
}