add option to validate / not validate the model
Is your feature request related to a problem? Please describe. Even after several retries there are cases when the LLM is not able to return data that the validators will validate. For those case it would be nice to have a backdoor where the .create() does not return an error. Instead I would like to be returned what the LLM returned, even if the data has not been validated.
Describe the solution you'd like An option when calling .create() to choose whether the data is validated or not.
Describe alternatives you've considered
- Option where in case of error the values of each field are set to their default value defined in the Pydantic model.
Additional context
I would try prompting harder first of all.
Try strict=false
I'm fairly against the idea of allowing for failed validation
A database would not allow you to write data at that isn't valid.
You'd be asked to change the schema
A password would not allow you to create a password that didn't fit the rules.
Instead I would like to be returned what the LLM returned, even if the data has not been validated.
https://python.useinstructor.com/#returning-the-original-completion-create_with_completion
user, completion = client.chat.completions.create_with_completion(
model="gpt-4-turbo-preview",
messages=[
{"role": "user", "content": "Create a user"},
],
response_model=User,
)
user contains the Object validated (or not)
completion contains the raw response from LLM.
If you don't use max_retries, then only one validation will be attempted.