Find answers from the community

Updated 3 months ago

I am trying to extract structure data

I am trying to extract structure data from the unstructured text using structured_predict, but if my Pydantic model has a field with type as datetime.date, llama-index is not able to parse the string and throws an error saying "Invalid Date Format". How can this be rectified
L
d
11 comments
Seems like that LLM is writing a string that pydantic cant parse into a datetime format?

Have you tried writing a custom validator for that field? You could help format the field and create the proper type
thats write, LLM is writing a string that pydantic is not able to parse
Haven't tried to write a custom validator though.
while using instrcutor library, this parsing is done by the library right?
I would go the validator route, then you can handle it directly in the pydantic class
I'm not sure on instructor or how it works tbh
i was thinking may be this can be provided as out of box method for llama-index
since date is a pretty common format
@Logan M - by the way, would like to know why is llama-index expecting pydantic.v1 for BaseModels?
because v0.10.x and below is built entirely on pydantic v1, and uses the pydantic.v1 layer to maintain compatibility

We actually JUST released v0.11.x, with one of the main changes being full pdyantic v2 support (no more v1). You'd be surprised just how breaking of a change this was under the hood, it was a huge amount of work to migrate πŸ˜…
oh daam!!!
really appreciate all the hard work being done by you guys. You guys are too awesome
Add a reply
Sign up and join the conversation on Discord