eyurtsev / kor

LLM(😽)
https://eyurtsev.github.io/kor/
MIT License
1.6k stars 88 forks source link

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

Closed mandar-karhade closed 1 year ago

mandar-karhade commented 1 year ago

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 commented 1 year ago

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