Skip to content

fix Pydantic model parsing#1087

Merged
abetlen merged 1 commit intoabetlen:mainfrom
DeNeutoy:fix-model-parsing
Jan 15, 2024
Merged

fix Pydantic model parsing#1087
abetlen merged 1 commit intoabetlen:mainfrom
DeNeutoy:fix-model-parsing

Conversation

@DeNeutoy
Copy link
Copy Markdown
Contributor

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 a type key, as it is actually defining the types - and so the SchemaConverter 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!

@abetlen
Copy link
Copy Markdown
Owner

abetlen commented Jan 15, 2024

@DeNeutoy thank you for the contribution!

@abetlen abetlen merged commit c689ccc into abetlen:main Jan 15, 2024
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

Successfully merging this pull request may close these issues.

Can't create grammar from JSON schema if referencing multiple definitions

2 participants