Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from_pydantic AttributeError:` 'FieldInfo' object has no attribute 'field_info' #212

Closed
mandar-karhade opened this issue Sep 4, 2023 · 1 comment

Comments

@mandar-karhade
Copy link

mandar-karhade commented Sep 4, 2023

The from_pydantic function is broken,

class Action(enum.Enum):
    play = "play"
    stop = "stop"
    previous = "previous"
    next_ = "next"


class MusicRequest(BaseModel):
    song: Optional[List[str]] = Field(
        description="The song(s) that the user would like to be played."
    )
    album: Optional[List[str]] = Field(
        description="The album(s) that the user would like to be played."
    )
    artist: Optional[List[str]] = Field(
        description="The artist(s) whose music the user would like to hear.",
        examples=[("Songs by paul simon", "paul simon")],
    )
    action: Optional[Action] = Field(
        description="The action that should be taken; one of `play`, `stop`, `next`, `previous`",
        examples=[
            ("Please stop the music", "stop"),
            ("play something", "play"),
            ("play a song", "play"),
            ("next song", "next"),
        ],
    )
    
schema, validator = from_pydantic(MusicRequest)   
```
Ends up with error
AttributeError:` 'FieldInfo' object has no attribute 'field_info'

```

[49](file:///home/m/.venv/lib/python3.11/site-packages/kor/adapters.py?line=48) attributes: List[Union[ExtractionSchemaNode, Selection, "Object"]] = []
     [50](file:///home/m/.venv/lib/python3.11/site-packages/kor/adapters.py?line=49) for field_name, field in model_class.__fields__.items():
---> [51](file:///home/m/.venv/lib/python3.11/site-packages/kor/adapters.py?line=50)     field_info = field.field_info
     [52](file:///home/m/.venv/lib/python3.11/site-packages/kor/adapters.py?line=51)     extra = field_info.extra
     [53](file:///home/m/.venv/lib/python3.11/site-packages/kor/adapters.py?line=52)     if "examples" in extra:
```
@mandar-karhade
Copy link
Author

checked and found that this issue is already there #206
Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant