fix Pydantic model parsing #1087
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1048, #1043
Problem
When parsing json schemas generated from a Pydantic model, if the schema has references to other models, it contains a
$defs
key, which are referred to in the schema itself via$ref
. This$defs
key does not have atype
key, as it is actually defining the types - and so theSchemaConverter
throws an error, as it requires all schema keys to have a type. This assert is actually not required, as it is caught later on after iterating through the various options for schema_types here:https://github.com/abetlen/llama-cpp-python/compare/main...DeNeutoy:fix-model-parsing?expand=1#diff-22ae5683f6e444008ca0411a78851823be188bd8e7f287327397462c5671a1a4L1502
I've deleted it and added a test. Cool project, thanks!